var siteName ="http://www.fiyatdedektifi.com/";
function onloadFunctions(mode) {
	
imageResizeFonk(mode);


}
function imageResizeFonk(mode){
	
		
    jQuery('.productPic img').each(function() {
    
		
	 if(mode=="departmanGenel") {
			var maxWidth = 110; 
			var maxHeight = 85;   
	}
	else if(mode=="compare") {
			var maxWidth = 115; 
			var maxHeight = 100;   
	}
	else if(mode=="detay") {
			var maxWidth = 225; 
			var maxHeight = 150;   
	}
	else {
		var maxWidth = 118; 
    	var maxHeight = 104;   
	
	}
    	
    	
        var ratio = 0;
        var width = jQuery(this).width();    
        var height = jQuery(this).height(); 
       
        if(width > maxWidth){
            ratio = maxWidth / width;   // get ratio for scaling image
            jQuery(this).css("width", maxWidth); 
            jQuery(this).css("height", height * ratio); 
            height = height * ratio;   
            width = width * ratio;    
        }
 
       
        if(height > maxHeight){
            ratio = maxHeight / height; 
            jQuery(this).css("height", maxHeight);  
            jQuery(this).css("width", width * ratio);    
            width = width * ratio;    
			 height = height * ratio;
        }
			var marginLeft=maxWidth-width;
			var marginTop=maxHeight-height;
			jQuery(this).css("margin-top", marginTop/2);  
           	jQuery(this).css("margin-left", marginLeft/2); 
			 
    });
	
	
	jQuery('.productPic img').show();
	
	
}


function fiyatReset(url,fiyat) {
	
	if(fiyat && fiyat!="tum-fiyatlar") {
		
					newurl=url.replace(fiyat, 'tum-fiyatlar');
					window.location=newurl;
		
	}
	else {
		errorDivStart("Fiyat Filtresi zaten uygulanmamış");
	}
}

function fiyatTest(url,fiyat) {
	
	var minFiyat=jQuery("#input_minPrice").val();
	var maxFiyat=jQuery("#input_maxPrice").val();
	if(minFiyat=="") minFiyat=0;
	if(maxFiyat=="") maxFiyat=0;
	minFiyat=parseInt(minFiyat);
	maxFiyat=parseInt(maxFiyat);
	
			if(maxFiyat>0 && minFiyat==0) {
				if(fiyat) {
					newurl=url.replace(fiyat, '0-'+maxFiyat);
					window.location=newurl;
				}
				else {
					newurl=url+'/0-'+maxFiyat+'/default/azalan';
					window.location=newurl;
				}
			}
			
			if(minFiyat>0 && maxFiyat==0) {
				if(fiyat) {
					newurl=url.replace(fiyat, minFiyat+'-0');
					window.location=newurl;
				}
				else {
					
					newurl=url+'/'+minFiyat+'-0/default/azalan';
					window.location=newurl;
				}
			}
			
			if(minFiyat>0 && maxFiyat>0) {
				if(minFiyat <= maxFiyat) {
					if(fiyat) {
						newurl=url.replace(fiyat, minFiyat+'-'+maxFiyat);
						window.location=newurl;
					}
					else {
						newurl=url+'/'+minFiyat+'-'+maxFiyat+'/default/azalan';
						window.location=newurl;
					}
				}
				else {
					errorDivStart("Maksimum fiyat,minimum fiyattan büyük olmalıdır");
				}
			
			}
			if(minFiyat==0 && maxFiyat==0) {
				errorDivStart("En az bir fiyat giriniz");
			}
			
			
		
}

function animator(position,gets) {
	
	var minValue=jQuery("#input_minPrice").val();
	var maxValue=jQuery("#input_maxPrice").val();
	
	minValue=parseInt(minValue);
	maxValue=parseInt(maxValue);
	var containerWidth=6;
	
	if(maxValue) {
		if(minValue>maxValue) {
			return false;
		}
	}
	
	if(minValue) {
		if(maxValue>0) {
			if(maxValue<minValue) {
				return false;
			}
		}
	}
	if(position=="Left") {
		
	jQuery.ajax({
		   type: "GET",
		   url: siteName+"Ajax/fiyatFiltre/"+gets+"*"+minValue,
		   success: function(msg){
			  	
				var newmsg=msg.replace(/[\n\r\t]/g,'');
				newmsg=parseFloat(newmsg);
				if(newmsg>=0) {
					newmsg=newmsg+0;
					jQuery("#imlec1").animate({"marginLeft":newmsg+'px'},300);
					var leftMargin2=jQuery("#imlec2").css("margin-left");
					leftMargin2=parseFloat(leftMargin2);
			
					leftMargin2=leftMargin2+0;
					
					if(leftMargin2<150) {
						var width=leftMargin2-newmsg;
					}
				
					else {
						var width=150-newmsg;
					}
				
				
				jQuery("#yataycizgi2").animate({"marginLeft":newmsg+3+'px',"width":width+'px' },300);
				}
				
			}
		 }); 
	
	}
	
		if(position=="Right") {
	
	
	jQuery.ajax({
		   type: "GET",
		   url: siteName+"Ajax/fiyatFiltre/"+gets+"*"+maxValue,
		   success: function(msg){
			   
				var newmsg=msg.replace(/[\n\r\t]/g,'');
				newmsg=parseFloat(newmsg);
				newmsg=newmsg+0;
				if(newmsg>=0) {
					jQuery("#imlec2").animate({"marginLeft":newmsg },300);
					
					var leftMargin1=jQuery("#imlec1").css("margin-left");
					leftMargin1=parseFloat(leftMargin1);
					leftMargin1=leftMargin1+0;
					
					if(leftMargin1>0) {
						var width=newmsg-leftMargin1;
					}
					else {
						var width=newmsg;
					}
				
					jQuery("#yataycizgi2").animate({"width":width },300);
				}
			}
		 }); 
	}
	
	
	
	/*
	
	var leftMargin2=jQuery("#imlec2").css("margin-left");
	leftMargin1=parseFloat(leftMargin1);
	leftMargin2=parseFloat(leftMargin2);
	var araBolge=leftMargin2-leftMargin1;

	jQuery("#yataycizgi2").css("margin-left",leftMargin1+containerWidth/2);
	jQuery("#yataycizgi2").css("width",araBolge);
	*/
}

function olceklendirme(data) {

jQuery("#fiyatFiltreMinFiyat").load(siteName+"Ajax/fiyatFiltre/"+data+"*0 #priceMinFilter");
jQuery("#fiyatFiltreMaxFiyat").load(siteName+"Ajax/fiyatFiltre/"+data+"*0 #priceMaxFilter");
var i=1;

while(i<10) {
	
	jQuery("#olcekPop_"+i).load(siteName+"Ajax/fiyatFiltre/"+data+"*noMin #olcekFiyat_"+i);
	i=i+1;
}

}
function fiyatDoldur(num) {
var theNumber=document.getElementById('olcekFiyat_'+num).innerHTML;
theNumber=parseFloat(theNumber);
var minPriceBox=document.getElementById("input_minPrice").value;
		if(minPriceBox=="") {
			document.getElementById("input_minPrice").value=theNumber;
		}
		if(minPriceBox!="")  {
			if(theNumber>=minPriceBox) {
			document.getElementById("input_maxPrice").value=theNumber;
			}
			else {
			document.getElementById("input_minPrice").value=theNumber;
			}
		}
}
function olcekAct(action,id) {
	if(action=='goster') {
		
		jQuery("#olcekPop_"+id).fadeIn('slow');
		
	}
	if(action=='kapat') {
		jQuery("#olcekPop_"+id).fadeOut('slow');
	}
	
}
function savePriceAlert(productID) {
	
	var email=jQuery("#priceAlertEmail").val();
	var price=jQuery("#priceAlertPrice").val();
	var guvenlik=jQuery("#paGuvenlik").val();
	
	var email = email.split(" ").join("");
	var price = price.split(" ").join("");
	var guvenlik = guvenlik.split(" ").join("");
	
	if(email=="" ||  price== "" ||  guvenlik== "" ) {
		
		jQuery("#priceAlertError").html("Alanları boş bırakmayınız");
		jQuery("#priceAlertError").fadeIn('slow');
		setTimeout(jQuery("#priceAlertError").fadeOut('slow'), 10000);  
		return false;
	}
	
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) {
       jQuery("#priceAlertError").html("Lütfen geçerli bir E-Posta adresi giriniz");
		jQuery("#priceAlertError").fadeIn('slow');
		setTimeout(jQuery("#priceAlertError").fadeOut('slow'), 10000);  
      return false;
   }
	
	var data=productID+'*,'+email+'*,'+price+'*,'+guvenlik;
	
		jQuery.ajax({
		   type: "GET",
		   url: siteName+"Ajax/savePriceAlert/"+data,
		   cache: false,
		   success: function(msg){
			   
				var newmsg=msg.replace(/[\n\r\t]/g,'');
				
				
					var priceFormW=jQuery("#priceForm").width();
					
					jQuery("#priceResult").html(newmsg);
					jQuery("#priceResult").width(priceFormW);
					jQuery("#priceResult").show();
			}
		 }); 
	
	
	
}
function bookmark() {
		
 		
			pageURL=document.location.href
			pageTitle=document.title
			
			if(document.all){
				window.external.AddFavorite(pageURL,pageTitle)
				}
			else{
				if(window.sidebar){
					window.sidebar.addPanel(pageTitle,pageURL,"")
					}
				}
 

} 	

function textAreaReset() {
   var textArea=jQuery("#commentText").val();
  
  if(textArea=="Yorumunuzu buraya yazınız") {
	  jQuery("#commentText").val("");
   
		
  }
  
}
function textArea2Reset() {
   var textArea=jQuery("#commentTitle").val();
  
  if(textArea=="Yorum başlığını buraya yazınız") {
	  jQuery("#commentTitle").val("");
   
		
  }
}
function imageView(url,w1,h1) {
	
	var getImgHeight=h1;
	var getImgWidth =w1;
	var maxHeight=400;
	if(getImgHeight>maxHeight) {
			jQuery("#lightImg").attr('height',maxHeight);
			getImgHeight=maxHeight;
			
			}
	
	var y=document.body.clientWidth ;

	var x=document.body.scrollTop;
	var sayfaYuks=document.body.clientHeight ;
	var topBosluk=(y-(getImgWidth+80));  // 80 değeri karakterin çıkıntı kısmı. komple divi ortalamk istediğimizi çin gerekl
	var left_right=topBosluk/2;

	
	document.getElementById('imgDv').style.left=left_right;
	document.getElementById('imgBackDv').style.top=x;
	document.getElementById('imgBackDv').style.height=sayfaYuks;
	document.getElementById('imgDv').style.top=(sayfaYuks/2)+x-(getImgHeight/2);
	

	jQuery("#imgBackDv").show();
	jQuery("#imgDv").fadeIn('slow');
	jQuery("#lightImg").show();
	
}
function popup(container,inner) {

	
	var y=document.body.clientWidth ;

	var x=document.body.scrollTop;
	var sayfaYuks=document.body.clientHeight ;
	var getImgWidth=jQuery("#"+container).width();
	var getImgHeight=jQuery("#"+container).height();
	var topBosluk=(y-(getImgWidth)); 
	var left_right=topBosluk/2;

	
	document.getElementById(container).style.left=left_right;
	document.getElementById('popupBackDv').style.top=x;
	document.getElementById('popupBackDv').style.height=sayfaYuks;
	document.getElementById(container).style.top=(sayfaYuks/2)+x-(getImgHeight/2);
	

	jQuery("#popupBackDv").show();
	jQuery("#"+container).fadeIn('slow');
	jQuery("#"+inner).show();
	
}
function hideImage() {
	jQuery("#imgBackDv").hide();
	jQuery("#imgDv").hide();
}
function hidePopup(container) {
	jQuery("#popupBackDv").hide();
	jQuery("#"+container).hide();
}

function test() {
	var val=document.searchForm.key.value;
	var uzunluk=val.length;
if((val!="") && (uzunluk>2)) {
	gonder();
}
else{
	errorDivStart("Arama yapabilmek için en az 3 karakter giriniz");
<!--document.getElementById('large').src=siteName+'productimage/Avea_100_Kontr_en_ucuz_avea_kont__r_xmlseries_100_kont__r__217.jpg';document.getElementById('large').style.height='1000px';document.getElementById('large').innerHTML='Bu bir denemedir'; -->
	return false;

}
}
function gonder() {
	
var value=document.searchForm.key.value;


document.searchForm.action=siteName+'ARAMA/'+value+'/1';

}



function companyTabChange(tabID){
	
	
jQuery(document).ready(function() {
	jQuery ("div[id*='companyHomeTabLogo_']").removeClass("logoSelect").addClass("logoNone");
	jQuery ("#companyHomeTabLogo_"+tabID).removeClass("logoNone").addClass("logoSelect");
		
	jQuery("div[id*='productsCompanyHome_']").hide();
	jQuery("#productsCompanyHome_"+tabID).show();
	
		
		
		var k=1;
		while(k<37) {
				var width=jQuery("#companyPrThumbs_"+k).width();
				var height=jQuery("#companyPrThumbs_"+k).height();
				var maxWidth = 140; 
				var maxHeight = 60;   
				var ratio = 0;
		   
       
														   
				if(width > maxWidth){
					ratio = maxWidth / width;   // get ratio for scaling image
				    jQuery("#companyPrThumbs_"+k).css("width", maxWidth); 
					jQuery("#companyPrThumbs_"+k).css("height", height * ratio); 
					height = height * ratio;   
					width = width * ratio;    
				}
 
       
				if(height > maxHeight){
					ratio = maxHeight / height; 
					jQuery("#companyPrThumbs_"+k).css("height", maxHeight);  
					jQuery("#companyPrThumbs_"+k).css("width", width * ratio);    
					width = width * ratio;    
					height = height * ratio;
				}
					var marginLeft=maxWidth-width;
					var marginTop=maxHeight-height;
					jQuery("#companyPrThumbs_"+k).css("margin-top", marginTop/2+"10");  
					jQuery("#companyPrThumbs_"+k).css("margin-left", marginLeft/2); 
				
					jQuery("#companyPrThumbs_"+k).show();
									k++;
									}
								
								});
}
function selectImageTab(sira,stopper){
	
	companyTabChange(sira);
    var yeniSira=parseInt(sira)+1;
    if (yeniSira>6){yeniSira=1;}
    if (stopper==1){
    	clearTimeout($slk);
    }else{    
    	$slk=setTimeout("selectImageTab("+yeniSira+")", 5000);    
    }
}

function departmanTabChange(tabID){
	
	jQuery(document).ready(function() {

jQuery ("div[id*='tabLeft_']").removeClass("depTabLeftSelected").addClass("depTabLeftNoneSelected");
jQuery ("div[id*='tabRight_']").removeClass("depTabRightSelected").addClass("depTabRightNoneSelected");
jQuery ("div[id*='tabHead_']").removeClass("activeMenuCenter").addClass("passiveMenuCenter");
	
jQuery ("#tabLeft_"+tabID).addClass("depTabLeftSelected");
jQuery ("#tabRight_"+tabID).addClass("depTabRightSelected");
jQuery ("#tabHead_"+tabID).removeClass("passiveMenuCenter").addClass("activeMenuCenter");


jQuery("div[id*='tabBody_']").hide();

jQuery("#tabBody_"+tabID).show();
var width=jQuery("#depTab_"+tabID).width();
var height=jQuery("#depTab_"+tabID).height();		
		var maxWidth = 235; 
    	var maxHeight = 175;   
		var ratio = 0;
       
       
        if(width > maxWidth){
            ratio = maxWidth / width;   // get ratio for scaling image
            jQuery("#depTab_"+tabID).css("width", maxWidth); 
            jQuery("#depTab_"+tabID).css("height", height * ratio); 
            height = height * ratio;   
            width = width * ratio;    
        }
 
       
        if(height > maxHeight){
            ratio = maxHeight / height; 
            jQuery("#depTab_"+tabID).css("height", maxHeight);  
            jQuery("#depTab_"+tabID).css("width", width * ratio);    
            width = width * ratio;    
			 height = height * ratio;
        }
			var marginLeft=maxWidth-width;
			var marginTop=maxHeight-height;
			jQuery("#depTab_"+tabID).css("margin-top", marginTop/2);  
           	jQuery("#depTab_"+tabID).css("margin-left", marginLeft/2); 
			jQuery("#depTab_"+tabID).show();
									});
}

function selectDepartmanTab(sira,stopper){
	 
									 


	departmanTabChange(sira);
    var yeniSira=parseInt(sira)+1;
    if (yeniSira>5){yeniSira=1;}
    if (stopper==1){
    	clearTimeout($slk);
    }else{    
    	$slk=setTimeout("selectDepartmanTab("+yeniSira+")", 4000);    
    }
}
function acilirMenuFonk(action,layout) {
	
	
	
	if(action=="ac") { 
		jQuery("div[id*='kategoriListMenu_']").hide();
		jQuery("#kategoriListMenu_"+layout).show();
		jQuery("#menu_ac"+layout).removeClass("menu_ac"+layout).addClass("menu_kapat"+layout);
		
	}
	if(action=="kapat") { 
		jQuery("div[id*='kategoriListMenu_']").hide();
		jQuery("#menu_ac"+layout).removeClass("menu_kapat"+layout).addClass("menu_ac"+layout);
	}
}
function acSagKategoriler(action,layout) {
	
	
	
	if(action=="ac") { 
		jQuery("div[id*='kategoriler_']").hide();
		jQuery("#kategoriler_"+layout).show();
		jQuery(	"div[id*='headMenuDepLay_']").removeClass("depMenuAktif").addClass("depMenuPasif");
		jQuery(	"#headMenuDepLay_"+layout).removeClass("depMenuPasif").addClass("depMenuAktif");
		
	}
	if(action=="kapat") { 
		jQuery("div[id*='kategoriler_']").hide();
		jQuery(	"#headMenuDepLay_"+layout).removeClass("depMenuAktif").addClass("depMenuPasif");
	}
}

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,'');
			$("#compareAjaxRowContainer").html(msg);		 	  
	   		}
		 }); 	
	
}
function sepetSay() {
	
	jQuery.ajax({
		   type: "GET",
		   url: siteName+"Ajax/sepetSay/",
		   success: function(msg){
			var newmsg=msg.replace(/[\n\r\t]/g,'');
			jQuery("#sepetSayaci").html(newmsg);		 	  
	   		}
		 }); 	
	
}
function compare(productID){
	
jQuery.ajax({
		   type: "GET",
		   url: siteName+"Ajax/basketActions/"+productID,
		   success: function(msg){
			var newmsg=msg.replace(/[\n\r\t]/g,'');
			errorDivStart(newmsg);		 	  
	   		}
		 }); 	
	 
	 
	
	sepetSay();
}
function cleanBasket() {
jQuery.ajax({
			type: "GET",
			url: siteName+"Ajax/cleanSession/",
			success: function(msg) {
				var newmsg=msg.replace(/[\n\r\t]/g,'');
				history.go(-1);
				errorDivStart(newmsg);
			}
			});

}

function removeProductFromBasket(productID) {
jQuery.ajax({
			type: "GET",
			url: siteName+"Ajax/removeProduct/"+productID,
			success: function(msg) {
				var newmsg=msg.replace(/[\n\r\t]/g,'');
				
				errorDivStart(newmsg);
				location.reload(true);
			}
			});

}

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){
	var boxWidth=470;	
	var defaultValue = new Number($("#slide").attr("rel"));	
	
	$("#slide").css("width",(boxWidth*totalBoxNumber));
	$("#slideLeftButton,#slideRightButton").show();	

	if (direction=="right"){
		var zx=defaultValue+1; var sign="-";
		if (zx>(totalBoxNumber-1)){$("#slideRightButton").hide();}
	}

	if (direction=="left"){
		var zx=defaultValue-1; var sign="+";
		if (zx<2){$("#slideLeftButton").hide();}
		}
	
	$("#slide").attr("rel",zx).animate({"left": sign+"="+boxWidth+"px"}, "slow");

}

function sendSearch(link){
	var searchName=$("#searchTextbox").val();
	searchName = trim(searchName);
	if (searchName){
	    if (searchName.length<3){
				
		}else {
			$("body, input").css("cursor","wait");
			document.location.href=link+searchName+"-1.html";
	    }
	} 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 (control>0){
		errorDivStart("Lütfen formu eksiksiz doldurunuz.");
		return;
	} else {
		$("#"+formID).submit();
	}
}

/* Error div functions */
function errorDivStart(message){
	setTimeout("errorDivShow('"+message+"')",100);
	var x=document.body.scrollTop;
	
	document.getElementById('errorDiv').style.top=x+250;
	document.getElementById('errorBackDiv').style.top=x;
	
}

function errorDivShow(message){
	jQuery("#errorMain").html(message);
	jQuery("#errorBackDiv").show();
	jQuery("#errorDiv").fadeIn("slow");
	setTimeout("errorDivHide()",1000);
	
}

function errorDivHide(){
	jQuery("#errorDiv").fadeOut("slow");
	jQuery("#errorBackDiv").hide();
}

function removeSpaces(string) {
	//splitstring = string.split(' ');
	return string.split(' ').join('');
}

function newUserFormControl(formID){
	var error="";
	
	if ($("#reuserEmail2").val()==""){error="E-Posta tekrarı alanı boş olmamalıdır";}
	if ($("#userEmail2").val()==""){error="E-Posta alanı boş olmamalıdır";}
	if ($("#reuserPassword2").val()==""){error="Şifre tekrarı alanı boş olmamalıdır";}
	if ($("#userPassword2").val()==""){error="Şifre alanı boş olmamalıdır";}
	if ($("#userName2").val()==""){error="Kullanıcı adı boş olmamalıdır";}
 	
	if (error==""){
		if (emailCheck($("#userEmail2").val())== false){error="Hatalı e-posta adresi girdiniz";}
		if ($("#userPassword2").val()!=$("#reuserPassword2").val()){error="Şifreler aynı olmalıdır";}
		if ($("#userEmail2").val()!=$("#reuserEmail2").val()){error="E-Posta adresleri aynı olmalı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 email=$("#"+emailInputID).val();
	if(email){
		if(emailCheck(email)){
		  $("#"+formID).submit();
		} else {
		   errorDivStart("Lütfen e-posta adresinizi kontrol ediniz.");
		}
	} else {
		errorDivStart("Lütfen e-posta adresinizi yazınız.");		
	}
}

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 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 getInfos(keyword,depID) 
{
	$("#divID").load(siteName+"admin/homeProductData.php?keyword="+keyword+"&depID="+depID+" #urunAdi");
	$("#productDetail").load(siteName+"admin/homeProductData.php?keyword="+keyword+"&depID="+depID+" #urunDetay");
	$("#productCategory").load(siteName+"admin/homeProductData.php?keyword="+keyword+"&depID="+depID+" #urunKategori");
	$("#productMark").load(siteName+"admin/homeProductData.php?keyword="+keyword+"&depID="+depID+" #urunMarka");
	$("#productImage").load(siteName+"admin/homeProductData.php?keyword="+keyword+"&depID="+depID+" #urunResim");
	$("#msg").load(siteName+"admin/homeProductData.php?keyword="+keyword+"&depID="+depID+" #msg");
}

function onay(msg) {
var answer = confirm(msg)
if (answer){

return true;
} else {

return false;
}
}

function getAdminMarkInfos(keyword) 
{
	$("#markaAdi2") .load(siteName+"admin/homeMarkData.php?keyword="+keyword+" #markaAdi");
	
	$("#markaID").load(siteName+"admin/homeMarkData.php?keyword="+keyword+" #markaID1");
	
	$("#markaLogo") .load(siteName+"admin/homeMarkData.php?keyword="+keyword+" #markaLogo"); 
	
	
	
	$("#msg").load(siteName+"admin/homeMarkData.php?keyword="+keyword+" #msg");
}

function getAdminMarkCategories(markID,catID,layNo) {
	if(catID=="") {
	$("#homeMarkCategories").load(siteName+"admin/homeMarkData.php?markID="+markID+" #vitrinMarksCats");
	}
	else {
		$("#MarksCatNameAjax_"+layNo).load(siteName+"admin/homeMarkData.php?markaID="+markID+"&catID="+catID+" #vitrinMarksCats");
	
	}
}

function updateAdminMarkCategories(markID,layNo,hmcID) {
	var boxValue=document.getElementById('markaCat_'+layNo).value;
	
$("#msg").load(siteName+"admin/homeMarkData.php?action=update&marka="+markID+"&cat="+boxValue+"&hmcID="+hmcID+" #vitrinMarksCats");
	
}
function getAdminCompanyInfos(keyword) 
{
	$("#firmaAdi") .load(siteName+"admin/homeCompaniesData.php?keyword="+keyword+" #firmaAdi");
	
	$("#firmaID").load(siteName+"admin/homeCompaniesData.php?keyword="+keyword+" #firmaID");
	
	$("#firmaLogo") .load(siteName+"admin/homeCompaniesData.php?keyword="+keyword+" #firmaLogo"); 
	
	
	
	$("#msg").load(siteName+"admin/homeCompaniesData.php?keyword="+keyword+" #msg");
}
function changeMarksOrder(key,action) {
	if(key=="" && action=="") 
	$("#marksOrder") .load(siteName+"admin/homeMarksOrder.php  #listMarkas");
	else {
	$("#marksOrder") .load(siteName+"admin/homeMarksOrder.php?grandBrandID="+key+"&action="+action+"  #listMarkas");
	}
}

function tagsIslem(action,tagID) {
		if(tagID=='') {
			
				var newUrl=document.getElementById('newUrl').value;
				var newTag=document.getElementById('newTag').value;
				var newFont=document.getElementById('newFont').value;
				reg = /\s+/;
				newUrl=newUrl.split(' ').join('%20');
				newUrl=newUrl.split('&').join('-');
				var newTag=newTag.split(' ').join('%20');
				
				$("#sonucGoster").load(siteName+"admin/tagData.php?action="+action+"&label="+newTag+"&fontSize="+newFont+"&url="+newUrl+" #islemSonuc");
		}
		
	
		if(tagID!="") {
				var url=document.getElementById('url_'+tagID).value;
				var fontSize=document.getElementById('font_'+tagID).value;
				
				$("#sonucGoster").load(siteName+"admin/tagData.php?action="+action+"&tagID="+tagID+"&fontSize="+fontSize+"&url="+url+" #islemSonuc");
		}
	
}



function changeCompaniesOrder(key,action) {
	if(key=="" && action=="") {
	$("#companiesOrder") .load(siteName+"admin/homeCompaniesData.php  #listCompanies");
	}
	else {
	$("#companiesOrder") .load(siteName+"admin/homeCompaniesData.php?companyID="+key+"&action="+action+"  #listCompanies");
	}
}



function  vitrinCompanyProducts(companyID) {
	$("#vitrinUrunleri").load(siteName+"admin/homeCompaniesProducts.php?companyID="+companyID+" #vitrinProducts");
}

function  AdmingetProducts(companyID,productID,layNo) {
	$("#productName_"+layNo).load(siteName+"admin/homeCompaniesProducts.php?firmaID="+companyID+"&productID="+productID+" #productNames");
	$("#msg").load(siteName+"admin/homeCompaniesProducts.php?firmaID="+companyID+"&productID="+productID+" #msg");
}
function updateCompanyProduct(productID,action) {
var newValue=document.getElementById("input_"+productID).value;
	$("#msg").load(siteName+"admin/homeCompaniesProducts.php?action="+action+"&productID="+productID+"&productValue="+newValue+" #updateProduct");
	
}
function changeRedirectReportTag(id) {

jQuery("div[id*='sol']").hide();
jQuery("div[id*='sag']").hide();
jQuery ("#sol"+id).show();
jQuery ("#sag"+id).show();
jQuery ("div[id*='orta']").removeClass("ud14").addClass("ud17");
jQuery ("#orta"+id).removeClass("ud17").addClass("ud14");

	
jQuery ("div[id*='tarihRapor_']").hide();
jQuery ("#tarihRapor_"+id).show();
jQuery ("div[id*='firstFilter_']").hide();
jQuery("#firstFilter_"+id).show();
}
function tagTypeSelect() {
var x=document.getElementById("typeSelect").value;							
window.location=siteName+'admin/index.php?view=labels&type='+x;
}
function depLabelDiv() { 
var x=document.getElementById("depSelect").value;							
window.location=siteName+'admin/index.php?type=department&view=labels&depID='+x;
}
function catLabelDiv() { 
var x=document.getElementById("catSelect").value;							
window.location=siteName+'admin/index.php?type=category&view=labels&catID='+x;
}
function markaLabelDiv() { 
var x=document.getElementById("markaSelect").value;							
window.location=siteName+'admin/index.php?type=marka&view=labels&markaID='+x;
}
function labelTo() { 
var x=document.getElementById("labelToSelect").value;							
window.location=siteName+'admin/index.php?view=labels&actionTo='+x;


}

function catBrandGet(type) { 

jQuery("#listBrands").load(siteName+"Ajax/labelCatBrands/"+type);
}
function whichLabelEdit(type) { 

jQuery("#labelRelating").load(siteName+"Ajax/labelSyncAjax/"+type);
}
function editRelatedField() {
	var typeName=document.getElementById("labelToSelectt").value;
	var typeID=	 jQuery("#labelSyncDep").val();
	window.location=siteName+'admin/index.php?view=labels&syncEdit='+typeName+'&typeID='+typeID;
}
function listLabels(type) {
	
	var typeAdd="";
	if(type!="") { typeAdd=type; }
	var inputValue=document.getElementById('labelInput').value;
				inputValue=inputValue.split(' ').join('%20');
				
	
	jQuery("#listLabels1").load(siteName+'Ajax/labelList/'+inputValue+'*'+typeAdd+'');
		
}
function listProducts() {
	
	var inputValue=document.getElementById('productInput').value;
	inputValue=inputValue.split(' ').join('%20');
	inputValue=inputValue.split('/').join('***');
	
	jQuery("#listProducts1").load(siteName+'Ajax/labelProductList/'+inputValue);
		
}

function removeSelectedOption() {
		var selectedNameArray = new Array();
		var selectedIdArray = new Array();
		var listMenu=document.getElementById('listLabels2');
		var countOpt=listMenu.options.length;
			
		for(i=0;i<countOpt;i++) {
				if(listMenu.options[i].selected) {
					listMenu.remove(i)
					
				}
		}
	
}
function removeSelectedProduct() {
		var selectedNameArray = new Array();
		var selectedIdArray = new Array();
		var listMenu=document.getElementById('listProducts2');
		var countOpt=listMenu.options.length;
			
		for(i=0;i<countOpt;i++) {
				if(listMenu.options[i].selected) {
					listMenu.remove(i)
					
				}
		}
	
}
function addOtherList(selectedNameArray,selectedIdArray) {
	var sayArray=selectedNameArray.length;
	var listMenu=document.getElementById('listLabels1');
	var countOpt=listMenu.options.length;
		
	
	for(i=0;i<sayArray;i++) {
		
				
		var secenek = document.createElement("option");
		secenek.text = selectedNameArray[i];
		secenek.value = selectedIdArray[i];
		secenek.selected=true;
			document.labelSelecter.listLabels2.options.add(secenek);
		
	}
	for(i=0;i<countOpt;i++) {
				if(listMenu.options[i].selected) {
					listMenu.remove(i)
					
				}
		}

}
function addProductList(selectedNameArray,selectedIdArray) {
	var sayArray=selectedNameArray.length;
	var listMenu=document.getElementById('listProducts1');
	var countOpt=listMenu.options.length;
		
	
	for(i=0;i<sayArray;i++) {
		
				
		var secenek = document.createElement("option");
		secenek.text = selectedNameArray[i];
		secenek.value = selectedIdArray[i];
		secenek.selected=true;
			document.labelSelecter.listProducts2.options.add(secenek);
		
	}
	for(i=0;i<countOpt;i++) {
				if(listMenu.options[i].selected) {
					listMenu.remove(i)
					
				}
		}

}
function attributeSelectedList() {
		var selectedNameArray = new Array();
		var selectedIdArray = new Array();
		var listMenu=document.getElementById('listLabels1');
		var countOpt=listMenu.options.length;
			var k=0;
		for(i=0;i<countOpt;i++) {
				if(listMenu.options[i].selected) {
					selectedNameArray[k]=listMenu.options[i].innerHTML;
					selectedIdArray[k]=listMenu.options[i].value;
					k++;
				}
		}
		addOtherList(selectedNameArray,selectedIdArray);
}
function attributeSelectedProduct() {
		var selectedNameArray = new Array();
		var selectedIdArray = new Array();
		var listMenu=document.getElementById('listProducts1');
		var countOpt=listMenu.options.length;
			var k=0;
		for(i=0;i<countOpt;i++) {
				if(listMenu.options[i].selected) {
					selectedNameArray[k]=listMenu.options[i].innerHTML;
					selectedIdArray[k]=listMenu.options[i].value;
					k++;
				}
		}
		addProductList(selectedNameArray,selectedIdArray);
}
function selectAllOption() {
	var listMenu=document.getElementById('listLabels2');
		var countOpt=listMenu.options.length;

		for(i=0;i<countOpt;i++) {
				listMenu.options[i].selected =true
		}
	
}

function ajaxStarClass(layID) {
	
	jQuery ("div[id*='oy_']").removeClass();
	for(i=1;i<=layID;i++) {
		
		jQuery("#oy_"+i).addClass("focusStar");
	}
	j=i;
	
	while(j<=5){
		jQuery("#oy_"+j).addClass("pasifStar");
		j++;
	}
}
function getProductDetailRates(productID) {
	
	jQuery.ajax({
		   type: "GET",
		   url: siteName+"Ajax/getProductRating/"+productID,
		   success: function(msg){
			   var newmsg=msg.replace(/[\n\r\t]/g,'');
			   				
									jQuery ("div[id*='oy_']").removeClass();
									for(i=1;i<=newmsg;i++) {
										
										jQuery("#oy_"+i).addClass("aktifStar");
									}
									j=i;
									while(j<=5){
										jQuery("#oy_"+j).addClass("pasifStar");
										j++;
									}
							
							}
					});
}

function rateProduct(ratingID,productID,vote,ip) {
		var data=ratingID+","+productID+","+vote+","+ip;
		jQuery.ajax({
		   type: "GET",
		   url: siteName+"Ajax/rateProduct/"+data,
		   success: function(msg){
			   var newmsg=msg.replace(/[\n\r\t]/g,'');
			   				
					
					errorDivStart(newmsg);		
			   				}
					});
		
	
}