var selectedTab = 0;

function pdegistir(id, resim) {
    var fr = document.getElementById(id);
    var w = fr.width;
    var h = fr.height; 
    fr.src = 'thump.aspx?h=' + h + '&w=' + w + '&fix=1&dosya=' + resim;
}

function tabclick(n) {
  if (n === selectedTab) return; // nothing to do.
    var li = document.getElementById('tab' + selectedTab);
    li.className = "";
   li = document.getElementById('page' + selectedTab);
  li.style.display = 'none';                // hide the currently selected sub-page
  
  li = document.getElementById('page' + n);
  li.style.display = 'block';               // show the new sub-page
  li = document.getElementById('tab' + n);  // get the new (clicked) tab
  li.className = "select" ;
  selectedTab = n;              // store for future reference
}



function qs(xkey) {
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) 
	{
		var pos = parms[i].indexOf('=');
		if (pos > 0) 
		{
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			if (xkey == key ) 
			{
				return val;
			}
		}
	}
} 


function uyari(myform, windowname)
{
	if (! window.focus)return true;
	window.open('', windowname, 'top=250,left=350,height=200,width=300,scrollbars=yes');
	myform.target=windowname;
	return true;
}


function popupform(myform, windowname)
{
	if (! window.focus)return true;
	window.open('', windowname, 'top=250,left=350,height=200,width=300,scrollbars=yes');
	myform.target=windowname;
	return true;
}


function WindowOpen1(urls) 
{ 
	window.open(urls, 'Window1', 'location=no;directories=no;menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no,resizable=0,height=518,width=740,top=50,left=100'); 
	this.target='Window1';
	return true;
} 


function popupdetay(urls) 
{ 
	urls = "display.aspx?img=" + urls ;
	Our_Window = window.open(urls, 'Windowd', 'location=no;directories=no;menubar=no,scrollbars=1,status=no,titlebar=no,toolbar=no,resizable=1,height=400,width=400,top=50,left=50'); 
	Our_Window.focus();
	return true;
} 

function popup_privacy(policy_id) 
{
	Our_Window=window.open("privacy.asp?id="+policy_id,"WindowA","width=820,height=750,scrollbars=yes"); 
	Our_Window.focus();
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var oldul;
function ugoster(id) {

		if (document.getElementById('u_' + id).style.display == 'none') {
		    document.getElementById(id).className = "lion";
		    document.getElementById('u_' + id).style.display = 'block';
		    if (oldul > '' &  oldul != id ) {
		        document.getElementById(oldul).className = "liof";
		        document.getElementById('u_' + oldul).style.display = 'none';
		    }
    }
		else {
			document.getElementById(id).className = "liof";
			document.getElementById('u_' + id).style.display = 'none';

    }
    oldul = id;

}





//  yeni
function printpage() {
      window.print();  
  }

 function postBack() {
     return confirm('Bu kaydi silmek istiyormusunuz ?');
 }


function onay(msg)
{
   if(msg == null || msg == "") { msg = "Bu kaydi silmek istiyormusunuz ?" ;  } 
   return confirm(msg);

}

function onay_cik(msg)
{
   if(msg == null || msg == "") { msg = "Bu kaydi silmek istiyormusunuz ?" ;  } 
   var rt ;
   rt = confirm(msg) ;
   if (rt == true) 
   {
       window.returnValue = true;
       window.close();
   }
   else
   {
       return false ;
   }
}

function putweekday(tarih,cbox)
{
    var str = document.getElementById(tarih).value ;
    if(str == null || str == "") { return ;  }
    
    if (str.indexOf(".",0) > 0)
    {
        var d1 = str.indexOf(".",0) + 1 ;
        var d2 = str.indexOf(".",d1) + 1 ;
    }
    else
    {
        var d1 = str.indexOf("/",0) + 1 ;
        var d2 = str.indexOf("/",d1) + 1 ;
    }
    
    Stamp = new Date() ;
    Stamp.setFullYear(str.substring(d2,10),str.substring(d1,d2-1) -1,str.substring(0,d1-1)) ;
    var dx = Stamp.getDay();
    if ( dx == 0 ) { dx = 7 ;}
    var cx = cbox + dx ;
      
    for (i=1;i<=7;i++)
    {
       document.getElementById(cbox + i).checked = false ; 
    }

    document.getElementById(cx).checked = true ; 
   
}

function fnSetValues(){
   var iHeight=oForm.oHeight.options[
      oForm.oHeight.selectedIndex].text;
   if(iHeight.indexOf("Random")>-1){
      iHeight=fnRandom(document.body.clientHeight);
   }
   var sFeatures="dialogHeight: " + iHeight + "px;";
   return sFeatures;
}


function check() {
if (win.document.readyState=='complete'){
win.document.execCommand("SaveAs");
win.close();
} else {
window.setTimeout('check();',1000);
}
}

function SaveAs(URL) {
win = window.open(URL,'win');
window.setTimeout('check();',1000);
}




function OpenModalDialog(url,btnName,diaHeight,diaWidth)
                {
                        
                    var vReturnValue;
                    if(diaHeight == null || diaHeight == "")
                        diaHeight = "300";
                        
                    
                    if(diaWidth == null || diaWidth == "")
                        diaWidth = "300";           
                        
                        
 

                // var xleft = (screen.availWidth - diaWidth) / 2;
                // var xtop = (screen.availHeight - diaHeight) / 2;
                                     
                    if(url != null)
                    {
                        Stamp = new Date();
                        var ix =   Stamp.getHours() * 60 * 600 + Stamp.getMinutes() * 600 + Stamp.getSeconds() + Stamp.getMilliseconds()  ;
                        url = url + "&ix=" + ix;
                        vReturnValue = window.showModalDialog(url,"#1","dialogHeight: " + diaHeight +"px; dialogWidth: " + diaWidth +"px;  edge: Raised; center: Yes; help: No; resizable: No; status: No;");
                        // vReturnValue = window.showModalDialog(url,"#1","dialogHeight: " + diaHeight +"px; dialogWidth: " + diaWidth +"px; dialogTop: " + xtop +"px; dialogLeft: " + xleft +"px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");
                        // vReturnValue = window.showModalDialog(url,"#1"," edge: sunken; center: Yes; help: No; resizable: no; status: No; scroll: yes; unadorned:Yes");
                    }
                    else
                    {
                        alert("Açılacak bir popup bulunamadı !");
                    }
                    if(vReturnValue == null)
                    {
                       return false
                    }
                    else
                    {  
                       if (btnName > "") 
                       {
                           document.getElementById(btnName).value = vReturnValue;
                       }
                       
                       return true;
                    }
 }
                

function tamam(retval) {
    var ParmA 
    if (retval == null )
        {
           ParmA = true;
         }
         else {
           ParmA = retval;
         }
         
    var MyArgs = new Array(ParmA);
    window.returnValue = ParmA;
    window.close();
}


function iptal() {
    var ParmA = null ;
    var MyArgs = new Array(ParmA);
    window.returnValue = ParmA;
    window.close();
}

function doInit() {
    var ParmA = "Aparm";
    var ParmB = "Bparm";
    var ParmC = "Cparm";
    var MyArgs = new Array(ParmA, ParmB, ParmC);
    MyArgs =  window.dialogArguments;
    //tbParamA.value = MyArgs[0].toString();
    //tbParamB.value = MyArgs[1].toString();
    //tbParamC.value = MyArgs[2].toString();
}

function CallPrint( strid ) {
var prtContent = document.getElementById( strid );
// var strOldOne=prtContent.innerHTML;
var WinPrint = window.open('', '', 'left=0,top=0,width=800,height=600,status=0');
WinPrint.document.write( prtContent.innerHTML );
WinPrint.document.close();
WinPrint.focus(); 
WinPrint.print();
WinPrint.print();
WinPrint.close();
// prtContent.innerHTML=strOldOne;
}

function jPrint( strid ) {
// var strOldOne=prtContent.innerHTML;
var WinPrint = window.open('', '', 'left=100,top=100,width=400,height=300,status=0');
WinPrint.document.write( strid );
WinPrint.document.close();
WinPrint.focus(); 
WinPrint.print();
WinPrint.close();
// prtContent.innerHTML=strOldOne;
}



function OnDateChange(sec)
{
    var cnum ;
    y = 1;
      
        cnum = document.getElementById('child_' + y).value;
        if (cnum < 1) {  document.getElementById('lca_' + y  ).style.display = 'none'; }
        else {document.getElementById('lca_' + y  ).style.display = 'inline'; }
        
        for(i = 1; i <= 4; i++) {
            if (i > cnum ) {
			    document.getElementById('c_' + y  + '_' + i).style.display = 'none';
		    }
		    else
		    {
                document.getElementById('c_' + y  + '_' + i).style.display = 'inline';
		    }
	    }
	
}



var oswitchs = 1;
var bindok = 0;
function otels() {
    if (oswitchs == 0) {
        $("div.otelpan").show().animate({ height: 0 }, "fast");
        oswitchs = 1;
    }
    else {
        $("div.otelpan").show().animate({ height: 252 }, "fast");
        oswitchs = 0;
        if (bindok == 0) {
            bindok = 1;
            $("div.otelpan").bind("mouseleave", function () {
                $("div.otelpan").show().animate({ height: 0 }, "slow");
                oswitchs = 1;
            });
        }
    }
    // $('#ilkmenu').click(function (event) { event.stopPropagation(); }); 



}




/*
$(document).click(function () {
if (oswitchs == 0) {
$("div.otelpan").show().animate({ height: 0 }, "slow");
oswitchs = 1;
}
});
*/

var oldexpand;

function comexpand(id) {
    if (id == oldexpand) {
        document.getElementById('comdiv_' + id).style.overflow = 'hidden';
        document.getElementById('comdiv_' + id).style.height = '45px';
        $("#combox_" + id).show().animate({ height: 85 }, "fast");
        document.getElementById('comexpand_' + id).src = 'images/www2/down.png';
        oldexpand = '';
    }
    else {
        if (oldexpand > '') {
            document.getElementById('comdiv_' + oldexpand).style.height = '45px';
            document.getElementById('comdiv_' + oldexpand).style.overflow = 'hidden';
            $("#combox_" + oldexpand).show().animate({ height: 85 }, "fast");
            document.getElementById('comexpand_' + oldexpand).src = 'images/www2/down.png';
          //  $("#comexpand_" + oldexpand).show();
        }
        document.getElementById('comdiv_' + id).style.height = '160px';
        document.getElementById('comdiv_' + id).style.overflow = 'auto';
        $("#combox_" + id).show().animate({ height: 200 }, "fast");
        document.getElementById('comexpand_' + id).src = 'images/www2/up.png';
        // $("#comexpand_" + id).hide(); 
        oldexpand = id;
    }

}

var mapok = 0;
function mapgoster() {

    if (mapok == 0) {
            document.getElementById('mappanel').style.visibility = 'visible';
            $("#mappanel").show().animate({ height: 298 , width: 630 }, "fast");
            mapok = 1;
        } else {
            $("#mappanel").animate({ height: 0, width: 0}, "fast");
            document.getElementById('mappanel').style.visibility = 'hidden';
            mapok=0;
    }

    }

    // ************** popup Ajax Functions ***********************

    function panel_close(panel) {
        var pan = '#' + panel;
        $(pan).animate({ height: 0, width: 0 }, "fast").hide();
        panelswitch = 0;
    }

    function ajaxr(url, panel) {
        document.getElementById(panel).innerHTML = "<img style='position:absolute; top:40%;left:45%' src='images/arrows/loader.gif' />";
        randomnumber = Math.floor(Math.random() * 10000);
        ajax_request(url + '&rnd=' + randomnumber, panel);
    }

    function ajax_request(url, panel) {
        if (window.XMLHttpRequest) {
            AjaxReq = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            AjaxReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (AjaxReq != undefined) {
            AjaxReq.onreadystatechange = function () { ajax_request_done(url, panel); };
            AjaxReq.open("GET", url, true);
            AjaxReq.send("");
        }
    }

    function ajax_request_done(url, panel) {
        if (AjaxReq.readyState == 4)  // only if req is "loaded"
        {
            if (AjaxReq.status == 200)  // only if "OK"
            {
                ukey = AjaxReq.responseText;
                if (ukey > '') {
                    document.getElementById(panel).innerHTML = ukey;
                }
            } else { }
        } else {
        }
        return false;
    }
    // ************** Shopping List Box Ajax Functions END ***********************
