

$(document).ready(function(){



	/* Sponsor animasyonu */



	//$('#sponsorSub1,#sponsorSub2,#sponsorSub3,#sponsorSub4').cycle({fx: 'curtainX',delay:  -5000});







	/* Error Div Back Set */



	var doHeight=$(document).width();



	var scWidth=$(window).width();



	var scHeight=$(window).height();



	var eDivWidth= $("#errorDiv").width();



	var eDivHeight= $("#errorDiv").height();	



	var eDivLeft=(scWidth-eDivWidth)/2;



	var eDivTop=(scHeight-eDivHeight)/2;



	



	$("#errorBackDiv").css("height",doHeight).css("width",scWidth);



	$("#errorDiv").css("top",eDivTop+'px').css("left",eDivLeft+'px');







	/* Error Div Position Finder */



	$(window).scroll(function () {



		var sct=$(window).scrollTop();					



		if (jQuery.browser.msie && jQuery.browser.version<7) {



			$("#errorDiv").css("top",sct+eDivTop+'px').css("left",eDivLeft+'px');



			$("#compareAjaxDiv").css("top",sct+200);



			}



	});


	/* Star Rating START*/



	$('.auto-submit-star').rating({



		callback: function(value, link){



		$.ajax({



			   type: "GET",



			   url: siteName+"Ajax/starRatingSubmit/"+value,	



			   success: function(msg){



			    var newmsg=msg.replace(/[\n\r\t]/g,'');



					errorDivStart(newmsg);



			   }



			 });



		  }



		});



	/* Star Rating END */



	



	/* Light box Function START*/



	//$('a[rel*=lightbox]').lightBox();



	/* Light box Function END*/



	



	$("#compareAjaxDivButton").toggle(



    	      function () {   



    	    		$.ajax({type: "POST",url: siteName+"Ajax/compareLoad/",



    	    			   success: function(msg){



    	    				if( !msg ){



    	    					msg = "<div style='color:#98ABC5;font-size:14px;font-weight:bold;text-align:center;padding:61px 0 12px 17px;'>Fiyat karşılaştırma sepetine henüz ürün eklemediniz.</div>";



    	    					$("#compareAjaxButtonContainer").hide();    	    					



    	    				}



	    					$("#compareAjaxRowContainer").html(msg);



    	    				$("#compareAjaxDiv").animate({"left": "-5px"}, "slow");}



    	    				



    	    			 });



    	      },



    	      function () {



    	    	  $("#compareAjaxDiv").animate({"left": "-596px"}, "slow"); 



    	    	  $("#compareAjaxDivButton").css("background-image","url("+siteName+"images/sepet_button_ileri.gif)");







    	      }



    	    );



	$("#compareAjaxDiv").animate({"left": "-596px"}, 1000);



	



	 $('a[href*=#]').click(function() {



	    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')



	    && location.hostname == this.hostname) {



	      var $target = $(this.hash);



	      $target = $target.length && $target



	      || $('[name=' + this.hash.slice(1) +']');



	      if ($target.length) {



	        var targetOffset = $target.offset().top;



	        $('html,body')



	        .animate({scrollTop: targetOffset-30}, 800);



	       return false;



	      }



	    }



	  });







	 /* Otomatik Ortalama */



	 $("(*)[rel='ortala']").each(function (i) {



	   	  var xLen = $(this).width();



	   	  var pLen = $(this).parent().width(); 



	   	  var son=(pLen-xLen)/2;



	   	  if (jQuery.browser.msie && jQuery.browser.version<7){son=son-106;}



	   	  $(this).css("margin-left",son+"px");



     });











});



function resizeAnasayfaMagazalar() {

	

	$('.populerurunbolumleri img').each(function() {



    	

    		var maxWidth = 65; // Max width for the image



    		var maxHeight = 55;    // Max height for the image



    	



        var ratio = 0;  // Used for aspect ratio



        var width = $(this).width();    // Current image width



        var height = $(this).height();  // Current image height



 



        // Check if the current width is larger than the max



        if(width > maxWidth){



            ratio = maxWidth / width;   



            //$(this).css("width", maxWidth); // Set new width



            //$(this).css("height", height * ratio);  // Scale height based on ratio



            height = height * ratio;    // Reset height to match scaled image



            width = width * ratio;    // Reset width to match scaled image



        }



 



        // Check if current height is larger than max



        if(height > maxHeight){



            ratio = maxHeight / height; 



            //$(this).css("height", maxHeight);   // Set new height



            //$(this).css("width", width * ratio);    // Scale width based on ratio



            width = width * ratio;    // Reset width to match scaled image



        }



    });







	

}





function imageResizeFonk(whichPage){

	resizeAnasayfaMagazalar();

	



    $('.story-small img').each(function() {



    	if(whichPage == 1){



    		var maxWidth = 225; // Max width for the image



            var maxHeight = 126;    // Max height for the image



    	}

		

		else if(whichPage == 3) {

		

			var maxWidth = 140; // Max width for the image



            var maxHeight = 160;    // Max height for the image

			

		}

		

		

		else{



    		var maxWidth = 150; // Max width for the image



    		var maxHeight = 145;    // Max height for the image



    	}



        var ratio = 0;  // Used for aspect ratio



        var width = $(this).width();    // Current image width



        var height = $(this).height();  // Current image height



 



        // Check if the current width is larger than the max



        if(width > maxWidth){



            ratio = maxWidth / width;   // get ratio for scaling image



            $(this).css("width", maxWidth); // Set new width



            $(this).css("height", height * ratio);  // Scale height based on ratio



            height = height * ratio;    // Reset height to match scaled image



            width = width * ratio;    // Reset width to match scaled image



        }



 



        // Check if current height is larger than max



        if(height > maxHeight){



            ratio = maxHeight / height; // get ratio for scaling image



            $(this).css("height", maxHeight);   // Set new height



            $(this).css("width", width * ratio);    // Scale width based on ratio



            width = width * ratio;    // Reset width to match scaled image



        }



    });



	



}







function compareRowLoadOrDelete(rowID){



	$("#compareRow1_"+rowID).css("background-color","gray").slideUp("slow");



	$("#compareRow2_"+rowID).slideUp("slow");



	$("#compareAjaxCompButton").fadeIn("slow");



	  $.ajax({



		   type: "POST",



		   url: siteName+"Ajax/compareLoad/"+rowID,



		   success: function(msg){



			var newmsg=msg.replace(/[\n\r\t]/g,'');



			



			if( !msg ){



				msg = "<div style='color:#98ABC5;font-size:14px;font-weight:bold;text-align:center;padding:61px 0 12px 17px;'>Fiyat karşılaştırma sepetine henüz ürün eklemediniz.</div>";



				$("#compareAjaxButtonContainer").hide();



			} else {



				$("#compareAjaxButtonContainer").show();



			}



			$("#compareAjaxRowContainer").html(msg);



		



	  		}



		 }); 	



	



}





var $slk;

function selectImageTab(sira,stopper){



	



	companyTabChange(sira);



    var yeniSira=parseInt(sira)+1;



    if (yeniSira>4){yeniSira=1;}



    if (stopper==1){



    	clearTimeout($slk);



    }else{    



    	$slk=setTimeout("selectImageTab("+yeniSira+")", 8000);    

		

    }



}











function compare(productID){



	 var cadrOffset=$("#compareAjaxDivResult").offset();



	 $.ajax({



		   type: "GET",



		   url: siteName+"Ajax/compare/"+productID,



		   success: function(msg){



		 	  var newmsg=msg.replace(/[\n\r\t]/g,'');



		 	  if (cadrOffset.left<-5){



		 		  errorDivStart(newmsg);		 	  



		 	  }



		   }



		 });



	  compareRowLoadOrDelete('');



}







function ajaxMenu(divWidth,divHeight,divLeft,divTop,divNo){	



	$("#ajaxMenuDiv_"+divNo).css({ width: divWidth+"px", height: divHeight+"px", marginLeft: divLeft+"px", marginTop: divTop+"px"});



	if ($("#ajaxMenuDiv_"+divNo).attr("rel")==1){



		$("div[id*='ajaxMenuDiv_']").slideUp("slow").attr("rel","1");



		$("#ajaxMenuDiv_"+divNo).slideDown("slow").attr("rel","2");



		}else{



		$("#ajaxMenuDiv_"+divNo).slideUp("slow").attr("rel","1");	



		}



}











function kSlider(direction,totalBoxNumber,act){

	

	if(act=="dur") clearTimeout(kur);



	var boxWidth=420;



	var defaultValue = new Number($("#slide").attr("rel"));	



	



	$("#slide").css("width",(boxWidth*totalBoxNumber));







	



	if (direction=="right"){



		$("#slideLeftButton").show();



		var zx=defaultValue+1; var sign="-";



		$(".slideContainer").css("margin-left","11px");



		if( totalBoxNumber > (zx - 1))



			$("#slide").attr("rel",zx).animate({"left": sign+"="+boxWidth+"px"}, "slow");



		if ( totalBoxNumber == zx )



			$("#slideRightButton").hide();



	}



	



	if (direction=="left"){



		$("#slideRightButton").show();



		var zx=defaultValue-1; var sign="+";



		if ( zx > 0 )



			$("#slide").attr("rel",zx).animate({"left": sign+"="+boxWidth+"px"}, "slow");	



		if( zx == 1){



			if (jQuery.browser.version == "6.0")



				$(".slideContainer").css("margin-left","33px");



			else



				$(".slideContainer").css("margin-left","73px");



			$("#slideLeftButton").hide();



		}



	}



	







}



function sendSearch(){



	var searchName=$("#searchName").val();



	searchName = trim(searchName);



	if (searchName){



	    if (searchName.length<2){



				errorDivStart("Arama kelimesi en az 2 karakter olmalıdır.");



		}else {



			$("body, input").css("cursor","wait");

			

			document.location.href=siteName+"ARA/"+searchName+",1";



	    }



	} else {



		errorDivStart("Lütfen aramak için bir kelime giriniz");



	}



}







function kTextCount(ID){



	var limit=2000;



	var textLength=$("#"+ID).attr("value").length;



	var text=$("#"+ID).val();



	var result=limit-textLength;



	var finalWord="<b>"+result+"</b> karakter daha yazabilirsiniz.";



	if (textLength>limit-1){



		var newText=text.substr(0,limit);



		$("#"+ID).val(newText);



		result=0;



		finalWord="<b>Yazma limitiniz doldu.</b>"



	}



	$("#remainingLinesText").html(finalWord);	



}







function kUpperCaseConvert(inputID){



	var text= $("#"+inputID).val();



	var newText= text.toUpperCase();



	$("#"+inputID).val(newText);



}







function userFormControl(formID){



	var control=0;



	if ($("#commentText").val()==""){control++;}



	if ($("#commentTitleX").val()==""){control++;}



	if ($("#code").val()==""){control++;}



	if (control>0){



		errorDivStart("Lütfen formu eksiksiz doldurunuz.");



		return;



	} else {



		$("#"+formID).submit();



	}



}


/* Error div functions */

function errorDivStart(message){

	setTimeout("errorDivShow('"+message+"')",300);

}

function errorDivShow(message){

	$("#errorMain").html(message);

	$("#errorBackDiv").show();

	$("#errorDiv").fadeIn("slow");

	setTimeout("errorDivHide()",2000);

	

}

function errorDivHide(){	

	$("#errorDiv").fadeOut("slow");

	$("#errorBackDiv").hide();

}

function removeSpaces(string) {

	return string.split(' ').join('');

}

function showGeneralAjaxResultsDiv(divWidth,title,message){

	var titleWidth=divWidth-40;

	var buttonDivWidth=divWidth-titleWidth-5;

	$("#generalAjaxResultsTitle").css("width",titleWidth+"px").html(title);

	$("#generalAjaxResultsClose").css("width",buttonDivWidth+"px");

	$("#generalAjaxResultsMain").html(message);

	$("#errorBackDiv").show();

	$("#generalAjaxResultsDiv").css({ width: divWidth}).fadeIn("slow");

}


function generalAjaxResultsDivHide(){

	$("#errorBackDiv").hide();

	$("#generalAjaxResultsDiv").fadeOut("slow");

}



function LoginControl(formId){



	



	var error = "";



	if ($("#companyPassword").val()==""){error="Şifre alanı boş olmamalıdır";}



	if ($("#companyEmail").val()==""){error="E-Posta alanı boş olmamalıdır";}



	if(error!=""){



		errorDivStart(error);



		



	}else{



		$("#"+formId).submit();



	}



}



function userLoginControl(formId){



	



	var error = "";



	if ($("#userPassword").val()==""){error="Şifre alanı boş olmamalıdır";}



	if ($("#userEmail").val()==""){error="E-Posta alanı boş olmamalıdır";}



	if(error!=""){



		errorDivStart(error);



		



	}else{



		$("#"+formId).submit();



	}



}



function sendContact(){

	

		var error = "";

		

	if ($("#code").val()==""){error="Güvenlik Kodu alanı boş olmamalıdır";}

	

	if ($("#message").val()==""){error="Mesaj alanı boş olmamalıdır";}



	if ($("#email").val()==""){error="E-Posta alanı boş olmamalıdır";}

	

	if ($("#soyad").val()==""){error="Soyad alanı boş olmamalıdır";}



	if ($("#ad").val()==""){error="Ad alanı boş olmamalıdır";}



	if(error!=""){



		errorDivStart(error);



		



	}else{



		$("#contactForm").submit();



	}



	

}


function updateFirmUser(formID){

	var error = "";
	
	if ($("#userPassword").val()!=$("#new_pass_repeat").val()){error="Yeni şifreler aynı olmalıdır";}
	if ($("#new_pass_repeat").val()==""){error="Yeni şifrenizi tekrar ediniz";}
	if ($("#userPassword").val()==""){error="Yeni şifrenizi girmediniz.";}
	if ($("#old_pass").val()==""){error="Eski şifrenizi girmediniz";}
	if ($("#userName").val()==""){error="Kullanıcı adınız boş olmamalıdır";}

	if(error!=""){

		errorDivStart(error);

	} else {

		document.getElementById(formID).submit();

	}
}

function newCompanyControl(formID){



	var error="";



	 



	if ($("#userSName").val()==""){error="Firma Yetkilisinin Soyadı boş olmamalıdır";}



	if ($("#userName").val()==""){error="Firma Yetkilisinin Adı boş olmamalıdır";}



	if ($("#companyTel").val()==""){error="Firma Telefon alanı boş olmamalıdır";}



	if ($("#companyURL").val()=="http://" || $("#companyURL").val()==""){error="Firma Url alanı boş olmamalıdır";}



	if ($("#companyName").val()==""){error="Firma Adı alanı boş olmamalıdır";}



 	



/*	if (error==""){



		if (emailCheck($("#userEmail2").val())== false){error="Hatalı email adresi girdiniz";}



		if ($("#userPassword2").val()!=$("#reuserPassword").val()){error="Şifreler aynı olmalıdır";}



		if ($("#userEmail2").val()!=$("#reuserEmail").val()){error="Email adresleri aynı olmalıdır";}



	} */



	



	if(error!=""){



		errorDivStart(error);



		return false;



	}else{



		document.getElementById(formID).submit();



	}	



}







function newUserFormControl(formID){



	var error="";



	if ($("#code").val()==""){error="Güvenlik Kodu alanı boş olmamalıdır";}



	if ($("#reuserEmail2").val()==""){error="E-Posta tekrarı alanı boş olmamalıdır";}



	if ($("#userEmail2").val()==""){error="E-Posta alanı boş olmamalıdır";}

	

	if ($("#userEmail2").val()!=$("#reuserEmail2").val()){error="E-Posta adresleri aynı olmalıdır";}

	

	if (emailCheck($("#userEmail2").val())== false){error="Lütfen geçerli bir E-Posta adresi giriniz.";}

	

	if ($("#userPassword2").val()!=$("#reuserPassword2").val()){error="Şifreler aynı olmalıdır";}

	

	if ($("#userPassword2").val().length<6){error="Şifreniz en az 6 karakter içermelidir";}

	

	if ($("#reuserPassword2").val()==""){error="Şifre tekrarı alanı boş olmamalıdır";}



	if ($("#userPassword2").val()==""){error="Şifre alanı boş olmamalıdır";}

	

	if ($("#userSurname2").val()==""){error="Soyad alanı boş olmamalıdır";}



 	if ($("#userName2").val()==""){error="Ad alanı boş olmamalıdır";}



	





	

	



	if(error!=""){



		errorDivStart(error);



		return false;



	}else{



		document.getElementById(formID).submit();



	}	



		



}







function emailCheck(str) {



	var at="@";



	var dot=".";



	var lat=str.indexOf(at);



	var lstr=str.length;



	var ldot=str.indexOf(dot);



	if (str.indexOf(at)==-1){return false;}



	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false;}



	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false;}



	if (str.indexOf(at,(lat+1))!=-1){return false;}



	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false;}



	if (str.indexOf(dot,(lat+2))==-1){return false;}



	if (str.indexOf(" ")!=-1){return false;}



	return true;					



}







function forgotPasswordFormControl(emailInputID,formID){

	

	var errorMsg;



	var email=$("#"+emailInputID).val();

	var code=$("#code").val();

	

	if(code=="") errorMsg="Güvenlik Kodunu giriniz";

	if(email=="") errorMsg="E-Posta Adresinizi giriniz";

	

	if(!errorMsg){



		if(emailCheck(email)){



		  $("#"+formID).submit();



		} else {



		   errorDivStart("Geçerli bir E-Posta adresi giriniz");



		}



	} else {



		errorDivStart(errorMsg);		



	}



}







function enterSubmit(evt,formID) {



    evt = (evt) ? evt : event;



    var charCode = (evt.charCode) ? evt.charCode :



        ((evt.which) ? evt.which : evt.keyCode);



    if (charCode == 13 || charCode == 3) {



        return true;



    } else {



        return false;



    }



}







function trim(stringToTrim){



	return stringToTrim.replace(/^\s+|\s+$/g,"");



}







function isNumberKey(evt)



{



   var charCode = (evt.which) ? evt.which : event.keyCode



   if (charCode > 31 && (charCode < 48 || charCode > 57))



      return false;







   return true;



}







function ieDownload(){



	document.location.href="http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=tr&SrcCategoryId=&SrcFamilyId=341c2ad5-8c3d-4347-8c03-08cdecd8852b&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fC%2fB%2f7%2fCB7C2809-EB9C-4640-90CE-8E98E641BA64%2fIE8-WindowsXP-x86-TRK.exe";



	}







function companyTabChange(tabID,act){

	if(act=="dur") clearTimeout($slk);

resizeAnasayfaMagazalar();

	$("div[id*='companyTab_']").removeClass("logoHover").addClass("logoStandart");



	$("#companyTab_"+tabID).addClass("logoHover");



		



	$("div[id*='companyProductTabBox_']").hide();



	$("#companyProductTabBox_"+tabID).show();







}







function setBookmark() {



  url=document.location.href;



  if (window.sidebar) { // Mozilla Firefox Bookmark



    window.sidebar.addPanel(url, url,"");



  } else if( window.external ){ // IE Favorite



    window.external.AddFavorite( url, url);



  } else if(window.opera && window.print) { // Opera Hotlist



    return true;



  }



}







function cerezClose(){



	



	var sor = confirm('Kapatmak istediğinizden emin misiniz ?');



	if(sor){



		$.ajax({



			type: "GET",



			url: siteName+"Ajax/Cookies/",	



			success: function(msg){



				if(msg == "ok") {



					$("#cerezSabit").hide();



				}



		   	}



		 });



	}



}





var kur;

function SliderRun(sira,direction,totalBoxNumber){



		



	var yeniSira;







    if (sira == 10){



    	direction = "left";



    } else if (sira == 1){



    	direction = "right";



    }



    



    if(direction == "left"){



    	yeniSira = parseInt(sira)-1;



    } else {



    	yeniSira = parseInt(sira)+1;



    }



    



    if (sira != 0)



    	kSlider(direction,totalBoxNumber);



    



    kur=setTimeout("SliderRun('"+yeniSira+"','"+direction+"','"+totalBoxNumber+"')", 3000);



}

function cleanLastVisitedCookie() {

	

	$.ajax({

		type:"POST",

		url:siteName+"Ajax/cleanLastVisitedCookie/",

		success:function() {

			

				$("#alanimiz2").remove();

				

		}

		

	});

	

}



function rateComment(value,commentID) {



		$.ajax({

			type:"GET",

			url:	siteName+"Ajax/rateComment/save-"+commentID+"-"+value,

			success:function(msg) {

				var newmsg=msg.replace(/[\n\r\t]/g,'');

				

				errorDivStart(newmsg);

			}

			

		});

		

	

}



function commentValues(commentID) {

	

			$.ajax({

					type:"GET",

					url:	siteName+"Ajax/rateComment/read-"+commentID,

					success:function(msg) {

						var newmsg=msg.replace(/[\n\r\t]/g,'');

						

						var parcala=newmsg.split("-");

						

						var liked=parcala[0];

						var disliked=parcala[1];

						

						$("#commentRateVal_1").html(liked);

						$("#commentRateVal_2").html(disliked);

					}

					

				});

	

	

}


function  productCompareDetailTabChange(no) {

	var gorunebilirHangisi;

	

	$('#productCompareComments').hide();

	$('#productCompareAttributes').hide();

	$('#productCompareDetails').hide();

	$('#pricesMenuInfoBar').hide();

		

			if(no==1)  {

			

				$('#productCompareDetails').fadeIn('1000')	;

				$('#pricesMenuInfoBar').fadeIn('1000')	;

				}

			if(no==2)  {

				$('#productCompareAttributes').fadeIn('1000')	;

			}

			if(no==3)  {

				$('#productCompareComments').fadeIn('1000');

			}

}
