﻿function VeriOpen() {
	window.open("https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=WWW.HEPSIBURADA.COM&lang=en" , null, "height=480,width=550,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

function updatecartonfly(VariantID,ProductID,Catalog,VariantGroup,CampaignPanelID,WishListProductID)
{
	var url = "/SpeedCart.aspx?s=" + VariantID + "&p=" + ProductID + "&c=" + Catalog + "&paid=" + CampaignPanelID + "&v=" + VariantGroup + "&w=" +  WishListProductID;
	var ly = document.getElementById("cartonthefly");
	var screensize = GetBrowserSize();
	var screenperc = 80;
	var screenleft = (screensize[0] - (screensize[0] * (screenperc / 100))) / 2;
	var screenwidth = (screensize[0] * (screenperc / 100));
	ly.style.display='block';
	ly.style.top = "150px";
	ly.style.left = screenleft + "px";
	ly.style.zIndex = 200;
	ly.style.width =  screenwidth + "px";
	ly.style.height = "520px";	
	ly.style.backgroundColor = "white";			
	var f_Basket = $("#frmBasket").get(0);		
	try
	{
		if (parent.frmBasket.location.href.toLowerCase().indexOf("speedcart.aspx") > -1)
		{
			var campaignPanel = CampaignPanelID;
			if (campaignPanel == null)
				campaignPanel = '';
			parent.frmBasket.addToCart(VariantID,ProductID,Catalog,'',campaignPanel,WishListProductID);
		}
		else
		{ 
			f_Basket.src = url;
		}
	}
	catch(e)
	{
		f_Basket.src = url;
	}	
	
	return false;	
}
 

			
function ShowAdd()
{
	var ly = document.getElementById("rightProductBanner");
	if (ly)
	{
		ly.style.position='absolute';
		ly.style.display='block';
		ly.style.top = findPosY(ly) + 'px';
		ly.style.left = findPosX(ly) + 'px' ;
	}

}

function OpenLayer(urllink,t)
{
	if (urllink==null || urllink=='')
	{
		return;
	}
	
	if (urllink.startsWith('/LayerInfo.aspx')==false && urllink.startsWith('LayerInfo.aspx')==false && 
		urllink.startsWith('/yorumekle.aspx')== false && urllink.startsWith('yorumekle.aspx')== false &&
		urllink.startsWith('/AddToProfileList.aspx')== false && urllink.startsWith('AddToProfileList.aspx')== false)
	{
		return;
	}
	
	if (t=='imgHaberVerLink')
	{
		t='aListeyeEkle';
	}
	
	var bt=	document.getElementById(t);
	var ly = document.getElementById("ServiceLayer");
	var screenperc = 100;
	ly.style.display='block';
	if (bt.style.width==''){w=145;}else{w=Px(bt.style.width,5);}
	ly.style.top=findPosY(bt)-200+ 'px';
	ly.style.left=findPosX(bt) - 510 + 'px' ;
	ly.style.width = '500px';
	ly.style.zIndex = 200;
	ly.style.height = 250;	
	ly.style.backgroundColor = "white";		
		
	if (t=='aStokAlarmListem')
	{
		var cwidth = 500;
		ly.style.width = cwidth + 'px';
		ly.style.height = 600;	
		ly.style.top = findPosY(bt)-250 + 'px';
	}
	
	if (t=='yorumlink2' || t=='_ctl0_linkYorum')
	{ 
		var cwidth = 800;
		ly.style.width = cwidth + 'px';
		ly.style.height = 480;	
		ly.style.top = findPosY(bt)-220 + 'px';
		ly.style.left = findPosX(bt) - 700 + 'px' ;
	}
	
	if (t=='LinkProfileList')
	{
		var cwidth = 550;
		ly.style.width = cwidth + 'px';
		ly.style.height = 485;	
		ly.style.top = findPosY(bt)- 300 + 'px';
		ly.style.left=findPosX(bt) - 700 + 'px' ;
	}
	
	try
	{
		var scroll='auto';
		if(urllink.startsWith('yorumekle.aspx')== true)
		{
			scroll='no';
		}
		
		if (urllink.startsWith('/')==false)
		{
			urllink= '/' + urllink	;
		}
		
		ly.innerHTML = '<iframe src="http://' + document.domain + urllink + '" frameborder="0" id="frmService" scrolling="' + scroll +'" class="FloatingFrame"></iframe>';
		
	}
	catch(e)
	{
		
	}	
	return false;	
}


	function center(mylayer)
    {
       mylayer.style.left=document.body.offsetWidth/2-mylayer.offsetWidth/2;
       mylayer.style.top=(document.body.offsetHeight/2-mylayer.offsetHeight/2)+document.body.scrollTop ;
	}	
			
	function GoRedirect(page)
	{
		
		var obj=document.getElementById('drCatalogs');
		var url=page;
		if (obj[obj.selectedIndex].value!=0)
		{
			url += "?catID=" + obj[obj.selectedIndex].value;
		}
		
		location.assign(url);
		
	}
	
    
   
   	function clickButton(e, buttonid)
   	{ 
		var bt = document.getElementById(buttonid); 
		if (typeof bt == 'object')
		{ 
			if(navigator.appName.indexOf("Netscape")>(-1))
			{ 
				if (e.keyCode == 13)
				{ 
					bt.click(); 
					return false; 
				} 
			} 
			
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
			{ 
				if (event.keyCode == 13)
				{ 
					bt.click(); 
					return false; 
				} 
			} 
		} 
	}


	function PreloadImage()
	{
		try
		{
			var preload_image;
			preload_image = new Image(16,16); 
			preload_image.src="images/tabs/spinner.gif"; 
		}
		catch(e)
		{
		}
		
  	}	

	function Loading(obj)
	{	
		if (typeof(Page_ClientValidate) == 'function')
		{
			if (!Page_ClientValidate())
			{
				return false;
			}
		}
			
		var lod=document.getElementById('loading');
		var bt=go(obj);
		var lText='<table class="loading" border="0" width="100%" cellspacing="0" cellpadding="3"><tr><td width="20"><IMG border="0" SRC="images/tabs/spinner.gif"></td><td>��leminiz Ger�ekle�iyor. L�tfen bekleyiniz.</td></tr></table>'							
		if (lod)
		{
			lod.style.display='block';
		}
		else
		{
			lod=document.createElement('<div>');
			lod.setAttribute('id','loading');
			lod.style.position='absolute';
			var w=0;
			if (bt.style.width==''){w=120;}else{w=Px(bt.style.width,5);}
			lod.style.top=findPosY(bt) + 'px';
			lod.style.left=findPosX(bt) + w + 'px';
			lod.innerHTML=lText;
			lod.style.display='block';
			document.body.appendChild(lod);
		}
	}

	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
		curleft += obj.x;
		
		return curleft;
	}

	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

	function go(id)
	{
		var obj = document.getElementById(id);
		return obj;
	}

	function Px(v,a)
	{
 		return  parseInt(v.replace('px','')) + a ;
	}					
	

	function MySplit(v,c)
	{
		var a =v.split(';');
		for (var i=0;i<c;i++){if (typeof(a[i])=='undefined'){	a[i]='';}}
		return a;
	}
			
	
	  
  function OpenWishList(url)
	{
		var bt=go('lnkAddToWishList');
	
		var ly = document.getElementById("ServiceLayer");
		var screenperc = 80;
		ly.style.display='block';
		if (bt.style.width==''){w=145;}else{w=Px(bt.style.width,5);}
		ly.style.top='20px';//findPosY(bt)-5 + 'px';
		ly.style.left=findPosX(bt) + w + 'px';
		ly.style.width = '500px';
		ly.style.zIndex = 200;
		ly.style.height = 600;	
		ly.style.backgroundColor = "white";			
		var f_Basket = $("#frmService").get(0);	
		try
		{
			f_Basket.src = url;
		}
		catch(e)
		{
		
		}	
		return false;			
	}
	
	function ShowHelp(obj,hid,dist)
	{
				var cont=document.getElementById('helpTT');
				if (hid==0)
				{
					cont.style.display='none';
					return;
				}
				if (cont)
				{
					cont.style.left=findPosX(obj) + dist  + 'px';
					cont.style.display= cont.style.display=='none' ? 'block' : 'none'; 
					cont.style.top=findPosY(obj) + 'px';
				}
				else
				{
					var cont= document.createElement('<div>');
					cont.setAttribute('id','helpTT');
					cont.style.position='absolute';
					cont.style.left=findPosX(obj) + dist + 'px';
					cont.style.top=findPosY(obj) + 'px';
					cont.style.width = '200px';
					cont.style.zindex=300;
					//cont.className='HText';
					document.body.appendChild(cont);
				}
				
				cont.innerHTML='<table cellpadding=2 border=0><tr><td class="HText">' + eval('ht' + hid) + '</td></tr></table>';
	}
	
	function ShowDesc(obj,text,dist)
	{
				
				var cont=document.getElementById('helpTT');
				if (text=='')
				{
					cont.style.display='none';
					return;
				}
				if (cont)
				{
					cont.style.left=findPosX(obj) + dist  + 'px';
					cont.style.position='absolute';
					cont.style.display= cont.style.display=='none' ? 'block' : 'none'; 
					cont.style.top=findPosY(obj) + 'px';
					cont.style.width = '300px';
					cont.style.zindex=300;
				}

				
				cont.innerHTML='<table cellpadding=2 border=0><tr><td class="HText">' + text + '</td></tr></table>';
	}	
	
	function SortRedirect(id)
	{
		var obj=document.getElementById(id);
		var pageName=window.location.pathname;//.substring(1); //bsaka20091223
		var Query=window.location.search.substring(1);
		var pos=Query.indexOf('sorting=');
		
		if (pos!=-1)
		{
			var freplace=Query.substring(pos,pos+9);
			var treplace='sorting=' + obj[obj.selectedIndex].value ;
			Query=Query.replace(freplace,treplace) ;
		}
		else
		{
			Query=Query + '&sorting=' + obj[obj.selectedIndex].value;
		}

		
		var PagingPos=Query.indexOf('record=');
		if (PagingPos!=-1)
		{
			var record='record=' + getQueryVariable('record'); 
			Query=Query.replace(record,'') ;
		}
		
		if (Query!='' )
		{
			Query = '?' + Query;
		}
		
		var url=pageName + Query;
		
		location.assign(url);
	}	
	

	function InStockRedirect(id)
	{
		var obj=document.getElementById(id);
		var pageName=window.location.pathname;//.substring(1); //bsaka20091223
		var Query=window.location.search.substring(1);

		var Sel='';
		if (obj.checked){Sel='stockinfo=1'}

		var pos=Query.indexOf('stockinfo=');
		
		if (pos!=-1)
		{
			Query=Query.replace('&stockinfo=1','') ;
			Query=Query.replace('stockinfo=1','') ;
		}
		else
		{
			Query=Query + '&' + Sel ;
		}
		
		var PagingPos=Query.indexOf('record=');
		if (PagingPos!=-1)
		{
			var record='record=' + getQueryVariable('record'); 
			Query=Query.replace(record,'') ;
		}
		
		if (Query!='' )
		{
			Query = '?' + Query;
		}
		
		var url=pageName + Query;
		
		location.assign(url);
	}	
			
	function DisableDblClick(obj)
	{	
		if (typeof(Page_ClientValidate) == 'function')
		{
			if (!Page_ClientValidate())
			{
				return false;
			}
		}
		
		var lod=document.getElementById('dvDisableLayer');
		var bt=go(obj);
		var lText='<table class="disableBtnlayer" border="0" width="100%" cellspacing="0" cellpadding="3"><tr><td width="20"><IMG border="0" SRC="images/tabs/spinner.gif"></td><td>İşleminiz gerçekleşiyor.<br> Lütfen bekleyiniz...</td></tr></table>'							
		lod.style.position='absolute';
		lod.style.top=findPosY(bt) + -1 + 'px';
		lod.style.left=findPosX(bt) + -1 + 'px';
		lod.innerHTML=lText;
		lod.style.display='block';

	}				

	function GoToURL(Query)
	{
		var pageName=window.location.pathname;//.substring(1); //bsaka20091223
		var url=pageName + Query;
		url=url.replace('besiktas/','');
		url=url.replace('galatasaray/','');
		location.assign(url);
	}

	function UseCheck()
	{
		var cd=$("#TxCekNo").attr('value');
		if (cd.length>8)
		{
			GoToURL('?giftcode=' + cd);
		}
		else
		{
			alert('Çek kodunuzu giriniz ya da sağdaki çeklerim tuşuna tıklayınız');
		}
	}

	
	var LastCatOID=0;
	var LastCatalogName;
	var ProductAdded=false;
	
	function AddToMyCompareList(obj,oid,catalogName,CatOID)
	{
		LastCatOID=CatOID;
		LastCatalogName=catalogName;
		Microsoft.CommerceServer.Site.Department.AddToCompareList(oid,catalogName,AddToMyCompareList_CallBack,obj)
	}


	function AddToMyCompareList_CallBack(res)
	{
		if (res)
		{
			var r=res.value;
			if (r && r>0)
			{
				ProductAdded=true;
				var Cont=$(res.context);
				
				if (r==1)
				{
					Cont.html('Ürün kıyaslama listenize eklendi. Kıyaslamak istediğiniz diğer ürünleri de ekleyiniz.');
				}
				else
				{
					Cont.html('Listenizdeki ' + r + ' ürünü kıyaslamak için tıklayınız');
				}
				
				Cont[0].onclick=null;
				Cont.click(function() {
				
					ShowKiyaslamaLayer();
					
				});
				
			}
		}
	}
	
	function SwtichToMyCompareList(obj,SKU)
	{
		if (obj)
		{
			var act=obj.checked;
			Microsoft.CommerceServer.Site.product_compare.SwitchToCompareList(SKU,act,SwtichToMyCompareList_CallBack,obj)
		}
		
	}
	
	function SwtichToMyCompareList_CallBack(res)
	{
		if (res)
		{
			//alert('changed');
		}
	}
	
	function ShowKiyaslamaLayer()
	{
		if (ProductAdded==false)
		{
			alert('Kıyaslamak istediğiniz ürünleri işaretleyiniz.');
		}
		else
		{
			//$("#divCompare").html('<table class="disableBtnlayer" border="0" width="100%" cellspacing="0" cellpadding="3"><tr><td width="20"><IMG border="0" SRC="images/tabs/spinner.gif"></td><td>İşleminiz gerçekleşiyor.<br> Lütfen bekleyiniz...</td></tr></table>')
			
			var myWidth = 0, myHeight = 0;
			  if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
			  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
			  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
			  }
			  //window.alert( 'Width = ' + myWidth );
			  //window.alert( 'Height = ' + myHeight );
			  
			var lyrHeight = myHeight - 100;
			
			$("#divCompare").show();
			$("#divCompare").dialog({ 
				modal:true,
				overlay: { opacity: 0.5, background: "black"},
				width:'80%',
				height:lyrHeight,
				title:"Ürün Kıyaslama",
				dialogClass:"flora"
			});	
		
			$("#frmBasket").attr('src','/product_compare.aspx?cid=' + LastCatOID + "&CatalogName=" + LastCatalogName);			
			
			
			
		}
	}
	 
	function fnKiyaslamaExtend()
	{
		var obj=document.getElementById('kiyaslamaExtend');
		var pageName=window.location.pathname;//.substring(1); //bsaka20091223
		var Query=window.location.search.substring(1);

		if (obj.checked)
		{
			Query=Query + '&sh=1';
		}
		else
		{
			Query=Query.replace('&sh=1','') ;
		}
		
		if (Query!='' )
		{
			Query = '?' + Query;
		}
		
		var url=pageName + Query;
		
	
		location.assign(url);
	}	
	
	function ShowCaptionHelp()
	{
		if ($('#helpme').css('display')=='block')
		{
			$('#helpme').hide();
		}
		else
		{
			$('#helpme').slideDown('fast');
		}
	}	
	
