﻿/*
*
*
*/

	
	var cilek = {
		load: function(){
		
			var Labels = {
				"TR" : ["Favoriden Çıkart", "Favorilerime Ekle", "Arkadaşına Gönder", "1"],
				"EN" : ["Remove", "Add to Favorites", "Send to Friend", "2"],
				"DE" : ["Entfernen", "Hinzufügen Fav.", "An Freund senden", "3"],
				"GR" : ["Κατάργηση", "Προσθήκη στα αγαπημένα", "Αποστολή σε φίλο", "4"],
				"RU" : ["Удалить", "Добавить в избранное", "Отправить другу", "5"],
				"UA" : ["Видалити", "Додати в обране", "Надіслати другу", "6"],
				"AE" : ["إزالة", "أضف إلى المفضلة", "ارسل الى صديق", "7"],
				"PR" : ["گزارش", "افزودن به علاقه مندیها", "ارسال به دوستان", "8"],
				"BO" : ["Remove", "Add to Favorites", "Send to Friend", "11"]
			};
			
			LabelsObj = Labels;
			
			
if (langID == "TR")
{
    imageName="/i/Assets/KDV-INDIRIMI-POPUP-600x609.png";
    homeUrlStr="cilek.com/";
 /*}
else
{
    imageName="/i/Assets/NEW-YEAR-05.jpeg";
    homeUrlStr="cilek.com/"+langID;
    homeUrlStr=homeUrlStr.toLowerCase();
 }*/
    var topY=($(window).height()-700)/2;
    if (topY < 10) topY=10;
	var Options = {
		SiteScreen: 530,
		EffectSpeed: 1000,
		EffectEasing: 'easeOutCubic',
		FixParameter: ($.browser.msie)? 1 : 0,
		CurrentPage : '#page2',
		DisplayEventCount : 3,
		floating : {
			lang: langID,
			homeUrl : homeUrlStr,
			active : true,
			cookie : false,
			image : imageName,
			delay : "none", //4x2 = 8sn or none
			width : 600, //px
			height : 609, //px
			left : "auto", //px or page center for auto
			top : topY,			
			url : ""
		},
		
		
		GlobalCufonFont : function(){
			if (langID == "GR"){
				return "Arial";
			}else if (langID == "DE") {
				return "Arial";
			}else{
				return "DINbek"
			};
		}
	};
} else {//if (langID == "TR")
	var Options = {
		SiteScreen: 530,
		EffectSpeed: 1000,
		EffectEasing: 'easeOutCubic',
		FixParameter: ($.browser.msie)? 1 : 0,
		CurrentPage : '#page2',
		DisplayEventCount : 3,
		floating : {
			lang: "DE",
			homeUrl : "cilek.com/de",
			active : false,
			cookie : false,
			image : "/i/Assets/donkart_banner-2.jpg",
			delay : "none", //4x2 = 8sn or none
			width : 720, //px
			height : 480, //px
			left : "auto", //px or page center for auto
			top : 45,
			url : ""
		},
		GlobalCufonFont : function(){
			if (langID == "GR"){
				return "Arial";
			}else if (langID == "DE") {
				return "Arial";
			}else{
				return "DINbek"
			};
		}
	};//var Options = {
};//if (langID == "TR"),else

/*if (langID == "TR"){
    var topY=($(window).height()-700)/2;
    if (topY < 10) topY=10;
	var Options = {
		SiteScreen: 530,
		EffectSpeed: 1000,
		EffectEasing: 'easeOutCubic',
		FixParameter: ($.browser.msie)? 1 : 0,
		CurrentPage : '#page2',
		DisplayEventCount : 3,
		floating : {
			lang: "TR",
			homeUrl : "cilek.com/",
			active : true,
			cookie : false,
			image : "/i/Assets/NEW-YEAR-03.jpeg",
			delay : "none", //4x2 = 8sn or none
			width : 422, //px
			height : 640, //px
			left : "auto", //px or page center for auto
			top : topY,			
			url : ""
		},
		GlobalCufonFont : function(){
			if (langID == "GR"){
				return "Arial";
			}else if (langID == "DE") {
				return "Arial";
			}else{
				return "DINbek"
			};
		}
	};
	
}
else if (langID == "DE"){

	var Options = {
		SiteScreen: 530,
		EffectSpeed: 1000,
		EffectEasing: 'easeOutCubic',
		FixParameter: ($.browser.msie)? 1 : 0,
		CurrentPage : '#page2',
		DisplayEventCount : 3,
		floating : {
			lang: "DE",
			homeUrl : "cilek.com/de",
			active : true,
			cookie : false,
			image : "/i/Assets/donkart_banner-2.jpg",
			delay : "none", //4x2 = 8sn or none
			width : 720, //px
			height : 480, //px
			left : "auto", //px or page center for auto
			top : 45,
			url : ""
		},
		GlobalCufonFont : function(){
			if (langID == "GR"){
				return "Arial";
			}else if (langID == "DE") {
				return "Arial";
			}else{
				return "DINbek"
			};
		}
	};

}else{

	var Options = {
		SiteScreen: 530,
		EffectSpeed: 1000,
		EffectEasing: 'easeOutCubic',
		FixParameter: ($.browser.msie)? 1 : 0,
		CurrentPage : '#page2',
		DisplayEventCount : 3,
		floating : {
			lang: "DE",
			homeUrl : "cilek.com/de",
			active : false,
			cookie : false,
			image : "/i/Assets/donkart_banner-2.jpg",
			delay : "none", //4x2 = 8sn or none
			width : 720, //px
			height : 480, //px
			left : "auto", //px or page center for auto
			top : 45,
			url : ""
		},
		GlobalCufonFont : function(){
			if (langID == "GR"){
				return "Arial";
			}else if (langID == "DE") {
				return "Arial";
			}else{
				return "DINbek"
			};
		}
	};

}*/

	
	var SettingsFn = {
		TopOffsetFn: function (){
			TopOffsetFn = ((document.documentElement.clientHeight-Options.SiteScreen)/2 < 30)? 30:(document.documentElement.clientHeight-Options.SiteScreen)/2;
			return TopOffsetFn;
		}
	};
	
	var SettingsEx = {
		TopOffset: SettingsFn.TopOffsetFn()
	};
	
	var Settings = jQuery.extend(Options, SettingsFn, SettingsEx || {});



			$("table tr:even").not("table.favtable tr").addClass("even");
			if (getCookie("favorites"+langID) != null){
				favArr = getCookie("favorites"+langID).split(',');
				for (i = 0; i < favArr.length; i++){
					ActionID = favArr[i];
					$(".detail[href*='-" + ActionID +"-']").parent(".item").addClass("favoriover").children(".favori").removeClass("favori").addClass("favori-drop").html(""+  eval("Labels."+langID+"[0]"));
				};
			};
			Labels = LabelsObj;
			$(".prod-options-list ul").prepend('<li class="stf"><a title="'+ Labels[langID][2] +'" onclick="return openSTF('+ Labels[langID][3] +','+ stfzoneid +','+ stfarticleid +'),false;" href="javascript:void(0);" id="site-option-stf-lnk"><span>'+ Labels[langID][2] +'</span></a></li>');
			
				HomeControl = false;
				if (window.location.href.replace("http://","").replace("www.","") == Settings.floating.homeUrl){
					HomeControl = true;
				}else{
					if (Settings.floating.cookie){
						if (getCookie('floating') != 'false'){
							HomeControl = true;
						};
					};
				};
				
				if (Settings.floating.active && HomeControl && langID == Settings.floating.lang){
					
					
					var firstime = false;
					var floatingstyle = "position:absolute;overflow:hidden;z-index:9999;";
						floatingstyle += "top:" + Settings.floating.top + "px;";
						if (Settings.floating.left == "auto"){
							windowinnerWidth = $("body").width();
							floatingstyle += "left:" + ((windowinnerWidth-Settings.floating.width)/2) + "px;";
							//floatingstyle += "left:" + ((window.innerWidth - 977 - 20)/2 + "px;";
						}else{
							floatingstyle += "left:" + Settings.floating.left + ";";
						};
						floatingstyle += "height:" + Settings.floating.height + ";";
						floatingstyle += "width:" + Settings.floating.width + ";";
						
					var floatingCloseStyle = 'background:url("/i/assets/i/close_floating_dum.png") no-repeat;height:20px;overflow:hidden;position:absolute;right:15px;text-indent:-9000px;top:15px;width:20px;';

					var floatingObj = $('<div/>', {id: 'floating', 'class':'FloatingContainer', style : floatingstyle});
					
					if (Settings.floating.url == ""){
						floatingimage = $('<img/>', {id: 'floatingimg', src: Settings.floating.image,usemap:'#bannermap'});
					}else{
						floatingimage = '<a href="' + Settings.floating.url + '"> <img id="floatingimg" src="' + Settings.floating.image + '" style="cursor: pointer;" border="0"></a>'
					};
						
					
					var floatingclose = $('<a/>', {id: 'floatingClose', text: 'Closess', style: floatingCloseStyle});
					$(floatingObj).append(floatingimage);
					$(floatingObj).append(floatingclose);
					
					$("body").prepend('<div id="floatingbg" style="width: 99.9%; position: absolute; z-index: 999; opacity: 0.9;filter: alpha(opacity = 90);background: none repeat scroll 0pt 0pt #EFEFEF; height: '+$("body").height() +'px;"></div>');
					$("body").append(floatingObj);
					//$("body").append('<map name="bannermap"><area shape="rect" coords="134,78,202,104" href="http://www.facebook.com/cilekodasi" target="_blank" alt="" /><area shape="rect" coords="228,78,313,104" href="https://twitter.com/#!/cilekodasi" target="_blank" alt="" /></map>');
					$("#floatingClose,#floatingbg").live("click", function(){CloseFn();CloseFn();});
					
					if (Settings.floating.cookie){
						setCookie('floating',"false",365,'/');
					};
					
					CloseFn = function(){
						if(firstime){
							$("#floating").hide();
							$("#floatingbg").hide();
							
							if(Settings.floating.delay != "none"){
								clearInterval(floatingInterval);
							};
							
							if (Settings.floating.cookie){
								setCookie('floating',"false",365,'/');
							};
						}
						firstime = true;
					};
					
					if(Settings.floating.delay != "none"){
						floatingInterval = setInterval(CloseFn,Settings.floating.delay);
					};
					
				};
				
				
			
		},
		resize: function (){
			
			
		},
		galeri: function(GallerySettings){
			
			var itemHeight = $(GallerySettings.Gallery).find(GallerySettings.Item).eq(0).height();
			
			$(GallerySettings.Gallery).find(GallerySettings.UpBtn).click(function () {
				goAnnouncement("next");
				//alert(itemHeight);
				return false;
			});	
			$(GallerySettings.Gallery).find(GallerySettings.DownBtn).click(function () {
				goAnnouncement("previous");
				return false;
			});				
			
			
			function goAnnouncement(Action){
				if($(GallerySettings.Gallery+":animated").attr("id")==undefined) {
				
					switch(Action){
						case 'next':
							var count = $(GallerySettings.Gallery).find(GallerySettings.Item + ":last-child").index();
							var indexNO  = $(GallerySettings.Gallery).find(GallerySettings.Item + ".active").index() + 1;
							if (indexNO > count) {indexNO = 0;}
							GoIndex = $(GallerySettings.Gallery).find(GallerySettings.Item).eq(indexNO).index();
							break;
						case 'previous':
							var count = $(GallerySettings.Gallery).find(GallerySettings.Item + ":last-child").index();
							var indexNO  = $(GallerySettings.Gallery).find(GallerySettings.Item + ".active").index() - 1;
							if (indexNO > count) {indexNO = 0;}
							GoIndex = $(GallerySettings.Gallery).find(GallerySettings.Item).eq(indexNO).index();
							break;
						default :
							GoIndex = Action;
							break;
						}
						
						var PageObj = $(GallerySettings.Gallery).find(GallerySettings.Item).eq(GoIndex);
						var PagePosition = PageObj.position();
						$(GallerySettings.Gallery).find(GallerySettings.Item).removeClass("active");
						$(GallerySettings.Gallery).find(GallerySettings.Item).eq(GoIndex).addClass("active");
						$(GallerySettings.Gallery ).find(GallerySettings.Container).animate({top: PagePosition.top*-1}, Settings.EffectSpeed/2, Settings.EffectEasing);
						$(this).addClass("active");
					
					}
				return false
			}	
		}
	};	
	
/*End Cilek Object*/
$(window).resize(function() {cilek.resize();});

$(document).ready(function(){
	
	cilek.load();
	
	
	
	
	var gallery = cilek.galeri({
		Gallery : ".announcement",
		Mask : ".item-mask",
		Container : ".item-container",
		Item : ".item",
		UpBtn : ".up-btn",
		DownBtn : ".down-btn"
	});
	
	$(".navigation ul li").not(".navigation ul li ul li").hover(
	  function () {
		$(".navigation ul li").removeClass("over");
	  	$(this).addClass("over");
		//Cufon.replace(['.navigation ul li ul li a'], {fontFamily: 'DINbek',hover:true});
	  }, 
	  function () {
		$(this).removeClass("over");
		//Cufon.replace(['.navigation ul li ul li a'], {fontFamily: 'DINbek',hover:true});
	  }
	);
	
	$("#lang_bar .lng-btn").hover(
	  function () {
		$("#language-dropdown").show();
	  }
	);
	
	$("#language-dropdown").mouseleave(
	  function () {
		$("#language-dropdown").hide();
	  }
	);	
		
	$(".product-img .zoom .zoom-tool,.product-img").hover(
	  function () {
		$(".product-img .zoom .zoom_title").show();
		if($("#photogallery li").length != 0){
			$(".product-img").append('<div class="product-zoom-icon"></div>');
		};
	  }, 
	  function () {
		$(".product-img .zoom .zoom_title").hide();
		$(".product-zoom-icon").remove();
	  }
	);
		
	$(".share-btn a").click(function(){
	
		Action = $(this).attr("class");
		Title = document.title;
		PageUrl= window.location.href;
		fbURL = 'http://www.facebook.com/share.php?v=4&src=bm&u=##PageURL##&t=##Title##';
		ffURL = 'http://www.friendfeed.com/share?title=##Title##&link=##PageURL##';
		tURL = 'http://twitter.com/home?status=##Title##-##PageURL##';
		
		switch(Action){
			case 'fb':
				shareUrl = fbURL
				break;
			case 't':
				shareUrl = tURL
				break;
			case 'ff':
				shareUrl = ffURL
				break;				
			default :
				break;
			};
		
		shareUrl = shareUrl.replace("##Title##",Url.encode(Title));
		shareUrl = shareUrl.replace("##PageURL##",Url.encode(PageUrl));
		
		window.open(shareUrl,'share');
		
		return false;
	});	
	

	$(".navigation ul li ul li a").hover(function(){
		imgPath = 'http://' + window.location.host + '/i/Assets/i/nav/over/' + $("html").attr("lang") + '/' + $(this).parent().attr("id").replace("article_","") + ".jpg";
		$(this).parent().parent().parent().children(".dropdownbg").children(".product-bg").css("background-image","url("+imgPath+")");
	});
	
	if($("#photogallery li").length == 0){
		$(".product-img .zoom").css("display", "none");
		$(".product-img").css("cursor", "default");
	};
	
	$(".navigation #zone_23, #zone_46").append("<li></li>");
	
	
	$('.prod-prop-list li img[alt]').qtip({
		position: {
			corner: {
				tooltip: 'bottomMiddle',
				target: 'topMiddle'
			},
			adjust: {
				resize: true,
				scroll: true
			}
		},
		style: {
			name: 'light',
			padding: '7px 13px',
			fontSize:'12px',
			width: {
				max: 210,
				min: 0
			},
		tip: true
		}
	});

	$(".ebulten-btn").click(function(){
		etext = $(".ebulten-txt").val();
		locationID = $(".ebulten-btn").parent().attr("action");
		location.href = locationID+"?EMAIL="+etext
		return false;
	})

	if ($get("EMAIL") != "") {
		$("#FORM-INPUT-EMAIL").val($get("EMAIL"))
	};

	if (getCookie("favorites"+langID)) {
		for (var i = 0; i <= getCookie("favorites"+langID).split(",").length - 1; i++) {
	        if (stfarticleid == getCookie("favorites"+langID).split(",")[i]) {
				Labels = LabelsObj;
	            $(".prod-options-list .favori").addClass("favori-drop").removeClass("favori").html("<span>"+ eval("Labels."+langID+"[0]") +"</span>");
	        }
	    }	
	};
    
	$("input[name='email']").focus(function(){
		if($(this).val() == "e-posta adresiniz" || $(this).val() == "your e-mail" || $(this).val() == "e-mail"){
			$(this).val("");
		}
	}).blur(function(){
		if($(this).val() == ""){
			$(this).val($(this)[0].defaultValue);
		}
	});	
	
	$("input[name='EMAIL']").focus(function(){
		if($(this).val() == "e-posta adresiniz" || $(this).val() == "your e-mail" || $(this).val() == "e-mail"){
			$(this).val("");
		}
	}).blur(function(){
		if($(this).val() == ""){
			$(this).val($(this)[0].defaultValue);
		}
	});	
	
	
	$("input[name='q']").focus(function(){
		if($(this).val() == "Ürün arama" || $(this).val() == "Product Search" || $(this).val() == "Produkt Suche" || $(this).val() == "Aναζήτηση Προϊόντων"){
			$(this).val("");
		}
	}).blur(function(){
		if($(this).val() == ""){
			$(this).val($(this)[0].defaultValue);
		}
	});
	$("input[name='ara']").focus(function(){
		if($(this).val() == "Ara" || $(this).val() == "Search" || $(this).val() == "Suche" || $(this).val() == "Aναζήτηση"){
			$(this).val("");
		}
	}).blur(function(){
		if($(this).val() == ""){
			$(this).val($(this)[0].defaultValue);
		}
	});	

	$("#tab1").click(function(){
		$(".tabs-content .content").css("display", "none");
		$(".tabs-content .tab1").css("display", "block");
		$(".tabs li").removeClass("active");
		$(this).addClass("active");
		return false;
	});
	
	$("#tab2").click(function(){
		$(".tabs-content .content").css("display", "none");
		$(".tabs-content .tab2").css("display", "block");
		$(".tabs li").removeClass("active");
		$(this).addClass("active");
		if($(".tabs-content .tab2").find(".jScrollPaneContainer").attr("class") == undefined){
			$(".scroll-pane").jScrollPane({scrollbarWidth:5, scrollbarMargin:10, reinitialiseOnImageLoad: true});
		};
		return false;
	});
	
	$("#tab3").click(function(){
		$(".tabs-content .content").css("display", "none");
		$(".tabs-content .tab3").css("display", "block");
		$(".tabs li").removeClass("active");
		$(this).addClass("active");
		
		$(".scroll-pane").jScrollPane({scrollbarWidth:5, scrollbarMargin:10, reinitialiseOnImageLoad: true});
		
		if($(".tabs-content .tab3").find(".jScrollPaneContainer").attr("class") == undefined){
			//$(".scroll-pane-h").jScrollHorizontalPane({scrollbarHeight:5, scrollbarMargin:10});
			$(".scroll-pane").jScrollPane({scrollbarWidth:5, scrollbarMargin:10, reinitialiseOnImageLoad: true});
			
		};
		//$(".jScrollPaneContainer").jScrollPane({scrollbarWidth:5, scrollbarMargin:10, reinitialiseOnImageLoad: true});
		
		$(".fiyat-table tr:eq(2) td:eq(1)").each(function(){
			ObjText = $(this).text().replace(",",".");
			ObjText1 = parseFloat(ObjText);
			ObjText2 = Math.round(ObjText1*100)/100 + " TL";
			$(this).text(ObjText2);
		});

		return false;
	});
	
	$("#renks span").click(function(){
	if($(this).attr("id") != "active"){
			$("#renks span").attr("id", "");
			$(this).attr("id", "active");
			$("#renkinput").attr("value", $(this).attr('value'));
		}else{
			$("#renks span").attr("id", "");
			$("#renkinput").attr("value", "");
		}
	});
//	$("#renks span:first").attr("id", "active");

	
	$(".zoom-tool,.product-img").click(function(){
		if($("#photogallery li").length != 0){
			$("#gallery_splash").css({display: 'block',height: $(document).height()});
		//	$("#gallery_splash_content").css({display: 'block'});
			$("#gallery_splash_content").fadeIn("slow");
			$("#photogallery li:first-child img").trigger("click");
			galleriaoff();
			gallkey();
		};
		return false;
	});
	$("#photogallery li img").click(function() {
		setTimeout("galleriaoff()", 100);
		$('html,body').animate({scrollTop: 70}, 700);
	});
	
	$(".galleria_wrapper img").live('click', function() {
		setTimeout("galleriaoff()", 100);
		$('html,body').animate({scrollTop: 70}, 700);
	});
	
	$("#gallery_splash").click(function(){
		$(this).css("display","none");
	//	$("#gallery_splash_content").css({display: 'none'});
		$("#gallery_splash_content").fadeOut("slow");
	});
	$("a#close_gallery").click(function(){
		$("#gallery_splash").css("display","none");
	//	$("#gallery_splash_content").css({display: 'none'});
		$("#gallery_splash_content").fadeOut("slow");
		return false;
	});

	$('.preview').live('click', function() {
		goURL = $(this).attr("rel");
		location.href = goURL;
		return false;
	});
	
//	$('#habercont').innerfade({ speed: 'slow', timeout: 5000, type: 'sequence', containerheight: '80px' }); 

	$('.gallery_ul').galleria({
		history   : false, // activates the history object for bookmarking, back-button etc.
		clickNext : true, // helper for making the image clickable
		insert    : '#main_image', // the containing selector for our main image
		onImage   : function(image, caption, thumb) { // let's add some image effects for demonstration purposes
							
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// fade out inactive thumbnail
			_li.siblings().children('img.selected').fadeTo(500,0.3);
			
			// fade in active thumbnail
			thumb.fadeTo('fast',1).addClass('selected');
			
			// add a title for the clickable image
			image.attr('title','Next image >>');
		},
		onThumb : function(thumb) { // thumbnail effects goes here
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// if thumbnail is active, fade all the way.
			var _fadeTo = _li.is('.active') ? '1' : '0.3';
			
			// fade in the thumbnail when finnished loading
			thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
			
			// hover effects
			thumb.hover(
				function() { thumb.fadeTo('fast',1); },
				function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
			)
		}
	});	
	
	$(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'});

	
});

function galleriaoff() {
var name = "#gallery_splash_content";
	menuYloc = 0;
	$(name).css("margin", "0 0 0 0");
	function offy(){
			offset = 100;
			if ($(document).scrollTop() < 100){
				offset= "100px";
				$(name).animate({top:offset},{duration:500,queue:false});
			}else{
				if ($.browser.mozilla) {
					offset= "100px";
					$(name).animate({top:offset},{duration:500,queue:false});
				}else{
					offset= "100px";
					$(name).animate({top:offset},{duration:500,queue:false});
				};
			};
		}
	
	k = ($(window).width()/2) - (parseInt(parseFloat($("#splash").css("width"))))/2 + "px";
	$(name).animate({left:k},{duration:500,queue:false});
	menuXloc = 0;
	function offx() {
		if ($(document).scrollLeft() == 0){
				$(name).css("width", $(name).width);
				offsetx = ($(window).width()/2) - (parseInt(parseFloat($(name).css("width"))))/2 + "px";
				$(name).animate({left:offsetx},{duration:500,queue:false});
			}else{
				$(name).css("width", $(name).width);
				offsetx = ($(window).width()/2) - (parseInt(parseFloat($(name).css("width"))))/2 +$(document).scrollLeft() +"px";
				$(name).animate({left:offsetx},{duration:500,queue:false});
			};
	};

offx();
offy();	
};

function getCookie(c_name){if (document.cookie.length>0){c_start=document.cookie.indexOf(c_name + "=");if (c_start!=-1){c_start=c_start + c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if (c_end==-1) c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end));};};return "";};
function _setCookie(c_name,value,expiredays,path){var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());};

function setCookie(szName, szValue, szExpires, szPath, szDomain, bSecure){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+szExpires);
 	var szCookieText = 	   escape(szName) + '=' + escape(szValue);
	szCookieText +=	 	   (szExpires ? '; EXPIRES=' + exdate.toUTCString() : '');
	szCookieText += 	   (szPath ? '; PATH=' + szPath : '');
	szCookieText += 	   (szDomain ? '; DOMAIN=' + szDomain : '');
	szCookieText += 	   (bSecure ? '; SECURE' : '');
	document.cookie = szCookieText;
};

function _getCookie(szName){
 	var szValue =	  null;
	if(document.cookie)	   //only if exists
	{	
       	var arr = document.cookie.split((escape(szName) + '=')); 
       	if(2 <= arr.length)
       	{
           	var arr2 = 	   arr[1].split(';');
       		szValue  = 	   unescape(arr2[0]);
       	}
	}
	return szValue;
}


function addFavoriteBtn(objID,obj){
	if ($(obj).hasClass("favori")){
		fav = getCookie("favorites"+langID);

		if(fav != null && fav != ""){		
			var a = setCookie("favorites"+langID,getCookie("favorites"+langID)+','+objID,365,'/');
			}else{
			var a = setCookie("favorites"+langID,objID,365,'/');
		};

		if(getCookie("favorites"+langID)){
			var s = document.getElementById('BasketCount').innerHTML = getCookie("favorites"+langID).split(",").length;
		}else{
		    var s = document.getElementById('BasketCount').innerHTML = "0";
		};
		if (langID  != "GR"){
		Cufon.replace(['.top-navigation a'], { fontFamily: Settings.GlobalCufonFont(), hover: true });
		};
		$(obj).removeClass("favori").addClass("favori-drop");
		$(obj).children("span").html(" "+  eval("Labels."+langID+"[0]") +"");
	}else{
		fav = getCookie("favorites"+langID);
		var re = new RegExp(objID, "g");fav = fav.replace(re,'');
		var re = new RegExp(",,", "g");fav = fav.replace(re,',').replace(re,',');
		if (fav.substring(0,1) == ","){fav=fav.substring(1,fav.length)}
		if (fav.substring(fav.length,1) == ","){fav=fav.substring(1,fav.length)}
		if (fav.substring(fav.length-1,fav.length) == ","){fav=fav.substring(0,fav.length-1)}
		setCookie("favorites"+langID,fav,365,'/');

		if(getCookie("favorites"+langID)){
			var s = document.getElementById('BasketCount').innerHTML = getCookie("favorites"+langID).split(",").length;
		}else{
		    var s = document.getElementById('BasketCount').innerHTML = "0";
		};
		if (langID  != "GR"){
		Cufon.replace(['.top-navigation a'], {fontFamily: Settings.GlobalCufonFont() ,hover:true});
		};
		$(obj).removeClass("favori-drop").addClass("favori");
		$(obj).children("span").html(Labels[langID][1]);
	};
	return false;
};



function addFavorite(objID,obj){
	if ($(obj).hasClass("favori")){
		fav = getCookie("favorites"+langID);
		if(fav != null && fav != ""){
			var a = setCookie("favorites"+langID,getCookie("favorites"+langID)+','+objID,365,'/');
			}else{
			var a = setCookie("favorites"+langID,objID,365,'/');
		};
		
		if(getCookie("favorites"+langID)){
			var s = document.getElementById('BasketCount').innerHTML = getCookie("favorites"+langID).split(",").length;
		}else{
		    var s = document.getElementById('BasketCount').innerHTML = "0";
		};
		
		Cufon.replace(['.sepetcount'], {fontFamily: 'DINbek',hover:true});
		//Cufon.replace(['.top-navigation a'], {fontFamily: Settings.GlobalCufonFont() ,hover:true});

		$(obj).removeClass("favori").addClass("favori-drop");
		$(obj).html(""+ Labels[langID][0] +"");
		$(obj).parent(".item").addClass("favoriover");
	}else{
		fav = getCookie("favorites"+langID);
		var re = new RegExp(objID, "g");fav = fav.replace(re,'');
		var re = new RegExp(",,", "g");fav = fav.replace(re,',').replace(re,',');
		if (fav.substring(0,1) == ","){fav=fav.substring(1,fav.length)}
		if (fav.substring(fav.length,1) == ","){fav=fav.substring(1,fav.length)}
		if (fav.substring(fav.length-1,fav.length) == ","){fav=fav.substring(0,fav.length-1)}
		setCookie("favorites"+langID,fav,365,'/');
		
		if(getCookie("favorites"+langID)){
			var s = document.getElementById('BasketCount').innerHTML = getCookie("favorites"+langID).split(",").length;
		}else{
		    var s = document.getElementById('BasketCount').innerHTML = "0";
		};
		
		Cufon.replace(['.sepetcount'], {fontFamily: 'DINbek',hover:true});
		
		//Cufon.replace(['.top-navigation a'], {fontFamily: Settings.GlobalCufonFont() ,hover:true});
	
		$(obj).removeClass("favori-drop").addClass("favori");
		$(obj).html( eval("Labels."+langID+"[1]"));
		$(obj).parent(".item").removeClass("favoriover");
	};
	
return false;
}
/** /
function RemoveFavorite(objID,obj){

	$(this).parents("table").eq(0).parent("td").fadeOut(150);
	fav = getCookie("favorites"+langID);

	var re = new RegExp(objID, "g");fav = fav.replace(re,'');
	var re = new RegExp(",,", "g");fav = fav.replace(re,',').replace(re,',');
	if (fav.substring(0,1) == ","){fav=fav.substring(1,fav.length)}
	if (fav.substring(fav.length,1) == ","){fav=fav.substring(1,fav.length)}
	if (fav.substring(fav.length-1,fav.length) == ","){fav=fav.substring(0,fav.length-1)}
	setCookie("favorites"+langID,fav,365);

	if(getCookie("favorites"+langID)){
		var s = document.getElementById('BasketCount').innerHTML = getCookie("favorites"+langID).split(",").length;
	}else{
	    var s = document.getElementById('BasketCount').innerHTML = "0";
	};
		
	Cufon.replace(['.top-navigation a'], {fontFamily: 'DINbek',hover:true});

	ComputeTotalPrice();

	$("table.favtable > tr").each(function(i){
	   var n =  $("table.favtable > tr:eq("+ i +") > td:visible").length;
	   if(n <= 2)
		  $(this).remove();
	});
	
	return false;
}
/**/

	
function getPriceList(Series,ProductID){
	Lang = $("html").attr("lang");
	Vers = '10.3';
	FileType = '.pdf';
	Prefix = '-Cilek_Fiyat_';
	TrFolder = 'FIYAT_URUNLER_TR';
	EnFolder = 'FIYAT_URUNLER_EN';
	
	FriSeries  = Series.replace(' ','_').replace('Å','S').replace('Ã–','O').replace('Ã¶','o').replace('ÅŸ','s').replace('Ã§','c').replace('Ä°','i').replace('Ã‡','C').replace('ÄŸ','g').replace('Ã¼','u').replace('Ãœ','U').replace(/Ş/gi,'S').replace(/Ö/gi,'O').replace(/ö/gi,'o').replace(/Ş/gi,'s').replace(/Ç/gi,'c').replace(/İ/gi,'i').replace(/Ç/gi,'C').replace(/ğ/gi,'g').replace(/ü/gi,'u').replace(/Ü/gi,'U').replace(/I/gi,'i').replace(/Ğ/gi,'G').replace(/ı/gi,'i');
	//FriSeries  = Series.replace(' ','_').replace('Ã?ï¿½z','S').replace('Ã?ï¿½Ã?Â±','i').replace('Ã?ï¿½Ã?Â¸','s').replace('Ã?ï¿½Ã?Â§','c').replace('Ã?ï¿½Ã?Â±','i');
	
	if (Lang == "tr"){
		DownloadUrl = 'http://' + window.location.host + '/i/assets/pdf/' + TrFolder + '/' + FriSeries + Prefix + Vers + FileType;
		}else{
		DownloadUrl = 'http://' + window.location.host + '/i/assets/pdf/' + EnFolder + '/' + FriSeries + Prefix + Vers + FileType;
	};
	
	window.open(DownloadUrl,'pdf');
return false;
}


function getProductGraphics(Series,ProductID){
	Lang = $("html").attr("lang");
	Vers = '10.1';
	FileType = '.pdf';
	Prefix = '-Cilek_Details_';
	TrFolder = 'DETAYLAR';
	EnFolder = 'DETAYLAR';
	FriSeries  = Series.replace(' ','_').replace('Ã?ï¿½','S').replace('Ã?Â°','i').replace('Ã?ï¿½','s').replace('Ã?Â§','c').replace('Ã?Â±','i');
	
	if (Lang == "tr"){
		DownloadUrl = 'http://' + window.location.host + '/i/assets/pdf/' + TrFolder + '/' + FriSeries + Prefix + Vers + FileType;
		}else{
		DownloadUrl = 'http://' + window.location.host + '/i/assets/pdf/' + EnFolder + '/' + FriSeries + Prefix + Vers + FileType;
	};
	
	window.open(DownloadUrl,'pdf');
return false;
};


function Mod(a, b) { return Math.floor(a/b)*b };


function IsEmail(email) {
	var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (regex.test(email)) return true;
	else return false;
} 

function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
};

function fixElement(obj,mess){alert(mess);obj.focus();}

function $get(key,url){  
 if(arguments.length < 2) url =location.href;  
 if(arguments.length > 0 && key != ""){  
     if(key == "#"){  
         var regex = new RegExp("[#]([^$]*)");  
     } else if(key == "?"){  
         var regex = new RegExp("[?]([^#$]*)");  
     } else {  
         var regex = new RegExp("[?&]"+key+"=([^&#]*)");  
     }  
     var results = regex.exec(url);  
     return (results == null )? "" : results[1];  
 } else {  
     url = url.split("?");  
     var results = {};  
         if(url.length > 1){  
             url = url[1].split("#");  
             if(url.length > 1) results["hash"] = url[1];  
             url[0].split("&").each(function(item,index){  
                 item = item.split("=");  
                 results[item[0]] = item[1];  
             });  
         }  
     return results;  
 }  
};



/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Url = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}

}

function openfav() {
    $('#plc').css("width", '400px');
    $('#plc').css("height", '400px');
    balanceFlatField();
    var getURL = '/i/assets/stfav.html';
    $.ajax({
        method: 'get',
        url: getURL,
        success: function (data) {
            $('#plc').html(data);
            $('#plbg').fadeIn({ complete: function () {
                $('#pl').slideDown();
				if (langID  != "GR"){
                Cufon.replace(['h1.stf-title'], { fontFamily: Settings.GlobalCufonFont(), hover: true });
				};
            } 
            });

        }
    });
    return true;
}


function openfaven() {
    $('#plc').css("width", '400px');
    $('#plc').css("height", '400px');
    balanceFlatField();
    var getURL = '/i/assets/stfaven.html';
    $.ajax({
        method: 'get',
        url: getURL,
        success: function (data) {
            $('#plc').html(data);
            $('#plbg').fadeIn({ complete: function () {
                $('#pl').slideDown();
				if (langID  != "GR"){
                Cufon.replace(['h1.stf-title'], { fontFamily: Settings.GlobalCufonFont(), hover: true });
				};
            }
            });

        }
    });
    return true;
}
function gallkey(){
	if ($("#gallery_splash").css("display") == "block"){
		$('body').keypress(function(event) {
			if (event.keyCode == '39') {
				$.galleria.next();
				setTimeout("galleriaoff()", 300);
		   }else if (event.keyCode == '37') {
				$.galleria.prev();
				setTimeout("galleriaoff()", 300);
			}
		});
	}
}




