var websiterootaddress;
websiterootaddress = "/"

//=================================================================================================================

function stockProp(prop, prodID, div, indirim)
{
	var xmlHttp;
	document.getElementById(div).innerHTML = "";
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if (xmlHttp.responseText!="")
			{
				document.getElementById(div).innerHTML = xmlHttp.responseText;
				document.getElementById("prodDetailInfo_prodStockProp_alert").style.display="none";
				if (document.getElementById("prodDetailInfo_prodStockProp_alertForList"))
				{
					document.getElementById("prodDetailInfo_prodStockProp_alertForList").style.display="none";
				}
				if (document.getElementById("txtStockAmount_"+prodID).value!="")
				{
					if (Number(document.getElementById("txtStockAmount_"+prodID).value)>0)
					{
						document.getElementById("trAddBasket_0").style.display="";
						document.getElementById("trAddBasket_1").style.display="none";
						document.getElementById("btnSepeteEkle").setAttribute("onclick", "addBasket("+prodID+",1,"+document.getElementById("txtStockID_"+prodID).value+")"); 
						if (document.getElementById("btnListAdd"))
						{
							document.getElementById("btnListAdd").setAttribute("onclick", "addToList(1,"+prodID+",1,"+document.getElementById("txtStockID_"+prodID).value+")"); 
						}
					}
					else
					{
						document.getElementById("trAddBasket_1").style.display="";
					}
				}
			}
			else
			{
				document.getElementById("divProdProps").innerHTML = "&nbsp;"
			}
		}
	}
	
	var newDate = new Date();
	xmlHttp.open("POST",websiterootaddress+"ajaxProdProps.asp",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send("prop="+prop+"&prod="+prodID+"&div="+div+"&indirim="+indirim);
}

//=================================================================================================================

function stockPropOther(prop, prodID, div, indirim)
{
	var xmlHttp;
	document.getElementById(div).innerHTML = "";
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if (xmlHttp.responseText!="")
			{
				document.getElementById(div).innerHTML = xmlHttp.responseText;
			}
			else
			{
				document.getElementById(div).innerHTML = "&nbsp;"
			}
		}
	}
	
	var newDate = new Date();
	xmlHttp.open("POST",websiterootaddress+"ajaxProdPropsOther.asp",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send("prop="+prop+"&prod="+prodID+"&div="+div+"&indirim="+indirim);
}

//=================================================================================================================

function addToList(listID,prodID,trans,stock)
{
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if (xmlHttp.responseText!="")
			{
				if (xmlHttp.responseText!="ERROR")
				{
					document.getElementById("tdListButton_"+listID).innerHTML = xmlHttp.responseText;
				}
			}
		}
	}

	var newDate = new Date();

	xmlHttp.open("POST",websiterootaddress+"functions/ajax_listActions.asp",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(listID+","+prodID+","+trans+","+stock);
}

//=================================================================================================================

function openListsForProd()
{
	if (document.getElementById("divListsForProd").style.display=="none")
	{
		document.getElementById("divListsForProd").style.display="";
	}
	else
	{
		document.getElementById("divListsForProd").style.display="none";
	}
}

//=================================================================================================================

function addBasket(prodID,piece,propStockID)
{
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if (xmlHttp.responseText!="")
			{

				for (var i=0; i<document.getElementsByName("chkKampanyaliUrun").length; i++)	
				{

					if (document.getElementsByName("chkKampanyaliUrun").item(i).checked)
					{
						addBasketCamp(document.getElementsByName("chkKampanyaliUrun").item(i).value,1,document.getElementById("txtStockID_"+document.getElementsByName("chkKampanyaliUrun").item(i).value).value);
					}
				}

				basket();
				Modalbox.show(websiterootaddress+"functions/lightbox_basket.asp", {title: "", width: 933, method: 'post'});

			}
		}
	}
	var newDate = new Date();

	xmlHttp.open("GET",websiterootaddress+"functions/ajax_addBasket.asp?t="+newDate.getTime()+"&prodID="+prodID+"&piece="+piece+"&propStockID="+propStockID,true);
	xmlHttp.send(null);
}

//=================================================================================================================

function addBasketCamp(prodID,piece,propStockID)
{
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if (xmlHttp.responseText!="")
			{
			}
		}
	}
	var newDate = new Date();
	xmlHttp.open("GET",websiterootaddress+"functions/ajax_addBasket.asp?t="+newDate.getTime()+"&prodID="+prodID+"&piece="+piece+"&propStockID="+propStockID+"&campID="+document.getElementById("txtCampID").value,false);
	xmlHttp.send(null);
}

//=================================================================================================================

function delBasket(basketID,piece)
{
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if (xmlHttp.responseText!="")
			{
				basket();
			}
		}
	}
	var newDate = new Date();
	
	xmlHttp.open("GET",websiterootaddress+"functions/ajax_delBasket.asp?t="+newDate.getTime()+"&basketID="+basketID+"&piece="+piece,true);
	xmlHttp.send(null);
}

//=================================================================================================================

function basket()
{
	try
	{
		xmlHttpx=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttpx=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttpx=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttpx.onreadystatechange=function()
	{
		if(xmlHttpx.readyState==4)
		{
			if (xmlHttpx.responseText!="")
			{
				showBasket(xmlHttpx.responseText);
				showBasketDetail(xmlHttpx.responseText);
			}
		}
	}
	var newDate = new Date();
	
	xmlHttpx.open("GET",websiterootaddress+"functions/ajax_Basket.asp?t="+newDate.getTime(),true);
	xmlHttpx.send(null);
}

//=================================================================================================================

function showBasket(basketArray)//SEPET UFAK MODÜLÜ
{
	var prodCount = 0;
	var prodID = 0;
	var prodName = "";
	var piece = 0;
	var price = 0;
	var pbir = 0;
	var kdv = 0;
	var totalBasket = 0;
	var basketID = 0;
	var	strHTML = "";
	var pbirCaption;
		
	if (basketArray !=0)
	{
		var basketArry = basketArray.split("$#$");
		
		strHTML = "<table width='96%' cellpadding='0' cellspacing='0'>";
		for (var i = 0; i < basketArry.length-1; i++ )
		{
			prodCount = prodCount + 1
			
			prodID = basketArry[i].split("|")[0];
			prodName = basketArry[i].split("|")[1];
			piece = basketArry[i].split("|")[2];
			piecePrice = basketArry[i].split("|")[3];
			totalPrice = basketArry[i].split("|")[4];
			pbirCaption = basketArry[i].split("|")[5];
			totalBasket  = basketArry[i].split("|")[6];
			basketID  = basketArry[i].split("|")[7];
			
			strHTML += "<tr>";
			strHTML += "<td colspan='2' class='modSepet_urunAdi'>";
			strHTML += "<table width='100%' cellpadding='0' cellspacing='0'>";
			strHTML += "</tr>";
			strHTML += "<td align='left'>" + prodName + "<td>";
			strHTML += "<td align='right'><img src='images/themes/morbi/sepet_sil.gif' style='cursor:pointer' onClick=\"delBasket(" + basketID + ",1)\" /></td>";
			strHTML += "<tr>";
			strHTML += "</table>";
			strHTML += "</td>";
			strHTML += "</tr>";
			strHTML += "<tr>";
			strHTML += "<td width='%50 class='modSepet_adetFiyat''>" + piece +" x " + piecePrice + " " + pbirCaption + "</td>";
			strHTML += "<td width='%50' class='modSepet_araToplamFiyat'>" + totalPrice + " " + pbirCaption + "</td>";
			strHTML += "</tr>";
			
			strHTML += "<tr>";
			strHTML += "<td colspan='2' class='modSepet_divider'></td>";
			strHTML += "</tr>";
		}
			strHTML += "<tr>";
			strHTML += "<td colspan='2' class='modSepet_sepetToplam'>" + totalBasket + " " + pbirCaption + "</td>";
			strHTML += "</tr>";
			strHTML += "</table>";
			if (document.getElementById("sepetIcerik"))
			{
				document.getElementById("sepetIcerik").innerHTML = strHTML;
			}
	}
	else
	{
		strHTML = "<table width='96%' cellpadding='0' cellspacing='0'>";
		strHTML += "<tr>";
		strHTML += "<td id='modSepet_bos'></td>";
		strHTML += "</tr>";
		strHTML += "</table>";		
		if (document.getElementById("sepetIcerik"))
		{
			document.getElementById("sepetIcerik").innerHTML = strHTML;
			transText(17,"modSepet_bos");
		}
		
	}
	
	if (document.getElementById("basketProdCount"))
	{
		document.getElementById("basketProdCount").innerHTML = prodCount + " ";
	}
}

//=================================================================================================================

function showBasketDetail(basketArray)//SEPET ADIM 1 (ÜRÜN LİSTELEME)
{
	if (basketArray !=0)
	{
		var basketArry = basketArray.split("$#$");
		var prodID = 0;
		var prodName = "";
		var piece = 0;
		var price = 0;
		var pbir = 0;
		var kdv = 0;
		var totalBasket = 0;
		var basketID = 0;
		var	strHTML = ""; 
		var pbirCaption;
		
		strHTML += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%; border:1px solid #cccccc;\">";
		strHTML += "<tr>";
		strHTML += "<td style=\"background-color:#EEEEEE; font-weight:bold; height:25px; width:35px;\">&nbsp;</td>";
		strHTML += "<td id=\"modBasketStep1_prodName\" style=\"background-color:#EEEEEE; font-weight:bold;\"></td>";
		strHTML += "<td id=\"modBasketStep1_piece\" style=\"background-color:#EEEEEE; font-weight:bold; width:70px; text-align:center\"></td>";
		strHTML += "<td id='modBasketStep1_piecePrice' style=\"background-color:#EEEEEE; font-weight:bold; width:100px; text-align:right\"></td>";
		strHTML += "<td id=\"modBasketStep1_totalPrice\" style=\"background-color:#EEEEEE; font-weight:bold; width:100px; text-align:right; padding-right:3px;\"></td>";
		strHTML += "</tr>";
		
		transText(166,"modBasketStep1_prodName");
		transText(167,"modBasketStep1_piece");
		transText(168,"modBasketStep1_piecePrice");
		transText(169,"modBasketStep1_totalPrice");
		
		for (var i = 0; i < basketArry.length-1; i++ )
		{
			prodID = basketArry[i].split("|")[0];
			prodName = basketArry[i].split("|")[1];
			piece = basketArry[i].split("|")[2];
			piecePrice = basketArry[i].split("|")[3];
			totalPrice = basketArry[i].split("|")[4];
			pbirCaption = basketArry[i].split("|")[5];
			totalBasket  = basketArry[i].split("|")[6];
			basketID  = basketArry[i].split("|")[7];
			
			strHTML += "<tr>";
			strHTML += "<td style=\"height:25px;text-align:center\"><img src='images/themes/morbi/sepet_sil.gif' style='cursor:pointer' onClick=\"delBasket(" + basketID + ",1)\" /></td>";
			strHTML += "<td>" + prodName + "</td>";
			strHTML += "<td style=\"text-align:center\"><input type=\"text\" name=\"intPiece\" value=\""+ piece + "\" style=\"border:1px solid #cccccc; width:50px;\"/></td>";
			strHTML += "<td style=\"text-align:right\">" + piecePrice +" " + pbirCaption + "</td>";
			strHTML += "<td style=\"text-align:right; padding-right:3px;\">" + totalPrice +" " + pbirCaption + "</td>";
			strHTML += "</tr>";
			
			
//			strHTML += "<td colspan='2' class='modSepet_sepetToplam'></td>";

		}
		strHTML += "<tr><td colspan=\"5\" style=\"font-weight:bold; height:25px; text-align:right;\">" + totalBasket + " " + pbirCaption + "</td></tr>"
		strHTML += "</table>";

		if (document.getElementById("basketDetailGrid"))
		{
			document.getElementById("basketDetailGrid").innerHTML = strHTML;
		}
	

	}
	else
	{
		strHTML = "<tr>";
		strHTML += "<td colspan='5' id='modSepet_bos'></td>";
		strHTML += "</tr>";
		if (document.getElementById("basketDetailGrid"))
		{
			document.getElementById("basketDetailGrid").innerHTML = strHTML;
			transText(17,"modSepet_bos");
		}
		
	}
}

//=================================================================================================================

function transText(textID,divID)
{
	try
	{
		xmlHttp2=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttp2.onreadystatechange=function()
	{
		if(xmlHttp2.readyState==4)
		{
			if (xmlHttp2.responseText!="")
			{
				if (document.getElementById(divID))
				{
					document.getElementById(divID).innerHTML = xmlHttp2.responseText;
				}
			}
		}
	}
	var newDate = new Date();
	
	xmlHttp2.open("GET",websiterootaddress+"functions/ajax_texts.asp?t="+newDate.getTime()+"&textID="+textID,true);
	xmlHttp2.send(null);
}

//=================================================================================================================

function basketSelectedAddressTemp(divID,addressID,type)
{
	try
	{
		xmlHttp6=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp6=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp6=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttp6.onreadystatechange=function()
	{
		if(xmlHttp6.readyState==4)
		{
			if (xmlHttp6.responseText!="")
			{
				if (document.getElementById(divID))
				{
					document.getElementById(divID).innerHTML = xmlHttp6.responseText;
				}
			}
		}
	}
	var newDate = new Date();
	
	xmlHttp6.open("GET",websiterootaddress+"functions/ajax_selectedAddress.asp?t="+newDate.getTime()+"&addressID="+addressID+"&type="+type,true);
	xmlHttp6.send(null);
}

//=================================================================================================================

function basketSelectedAddress(divID,addressID,type)
{
	try
	{
		xmlHttp5=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp5=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp5=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttp5.onreadystatechange=function()
	{
		if(xmlHttp5.readyState==4)
		{
			if (xmlHttp5.responseText!="")
			{
				if (document.getElementById(divID))
				{
					document.getElementById(divID).innerHTML = xmlHttp5.responseText;
				}
			}
		}
	}
	var newDate = new Date();
	
	xmlHttp5.open("GET",websiterootaddress+"functions/ajax_selectedAddress.asp?t="+newDate.getTime()+"&addressID="+addressID+"&type="+type,true);
	xmlHttp5.send(null);
}

//=================================================================================================================

function prodPicChange(imgSrc)
{
	document.getElementById("prodMainImage").src = "images/prods/medium/" + imgSrc + ".jpg";
	document.getElementById("prodMainImageLink").href = "images/prods/large/" + imgSrc + ".jpg";
}

//=================================================================================================================

function checkFields(gelenform, divError)
{
	function findPos(obj) 
	{
		var curleft = curtop = 0;
		if (obj.offsetParent) 
		{
			do 
			{
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
			while (obj = obj.offsetParent);
		}
		return curleft+","+curtop;
	}

	var strPos = "";
	var intWidth = 0;

	var sonuc=true;
	var msg = "Lütfen [saha] sahasını boş bırakmayınız.";
	var msg2 = "[saha1] ve [saha2] sahalarının değerleri aynı değildir.<br>Lütfen kontrol edip tekrar deneyiniz.";
	var msg3 = "Lütfen geçerli bir e-posta adresi giriniz.";

	for (var i=0; i<gelenform.elements.length; i++)
	{
		gelenform.elements[i].style.backgroundColor = "#FFFFFF";
		if (gelenform.elements[i].title!="")
		{
			if (gelenform.elements[i].type=="checkbox")
			{
				if (gelenform.elements[i].checked==false)
				{
					sonuc = false;
					gelenform.elements[i].focus();
					gelenform.elements[i].style.backgroundColor = "#FFEED7";
					document.getElementById(divError).style.display = "";
				}
			}
			else
			{
// sahanin bos olup olmadiginin kontrolu
				if (gelenform.elements[i].value=="" && sonuc==true)
				{
					sonuc = false;
					gelenform.elements[i].focus();
					gelenform.elements[i].style.backgroundColor = "#FFEED7";
					document.getElementById(divError).style.display = "";
				}
				
// ikinci kez girilmesi gereken sahalarin kontrolu
				if (gelenform.elements[i].value!="" && sonuc==true)
				{
					if (document.getElementById(gelenform.elements[i].name+"_"))
					{
						document.getElementById(gelenform.elements[i].name+"_").style.backgroundColor = "#FFFFFF";
						if (gelenform.elements[i].value!=document.getElementById(gelenform.elements[i].name+"_").value)
						{
							sonuc = false;
							document.getElementById(gelenform.elements[i].name+"_").focus();
							document.getElementById(gelenform.elements[i].name+"_").style.backgroundColor = "#000000";
							document.getElementById(gelenform.elements[i].name).style.backgroundColor = "#FFEED7";
							document.getElementById(divError).style.display = "";
						}
					}
				}
	
// eposta gecerlilik kontrolu
				if (gelenform.elements[i].name.indexOf("Email")>0 && sonuc==true)
				{
					if (checkEmail(gelenform.elements[i].value)==false)
					{
						sonuc = false;
						gelenform.elements[i].focus();
						gelenform.elements[i].style.backgroundColor = "#FFEED7";
						document.getElementById(divError).style.display = "";
					}
				}
			}
		}
	}
	return sonuc;
}

//=================================================================================================================

function checkEmail(value) 
{
    var str = value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) 
	{
        return false;
    } 
	else 
	{
        return true;
    }
}		

//=================================================================================================================

function basket2addressChange()
{
	//Teslimat adresini fatura adresi olarak kullan
	document.getElementById("txtName_fatura").value = document.getElementById("txtName").value;
	document.getElementById("txtSurname_fatura").value = document.getElementById("txtSurname").value;
	document.getElementById("txtAddress_fatura").value = document.getElementById("txtAddress").value;
	document.getElementById("txtPK_fatura").value = document.getElementById("txtPK").value;
	cityList2(document.getElementById('country_teslimat').value,'cityID_fatura','1','tr_cityID_fatura','tr_townID_fatura','cityID_fatura','townID_fatura');
	townList2(document.getElementById('cityID_teslimat').value,'townID_fatura','1','tr_townID_fatura','townID_fatura');
	document.getElementById("country_fatura").value = document.getElementById("country_teslimat").value;
	document.getElementById("txtPhone_fatura").value = document.getElementById("txtPhone").value;
	document.getElementById("txtGSM_fatura").value = document.getElementById("txtGSM").value;
}

//=================================================================================================================

function basket3view(divID)
{
	try
	{
		xmlHttp7=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp7=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp7=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
         
	xmlHttp7.onreadystatechange=function()
	{
		if(xmlHttp7.readyState==4)
		{
			if (xmlHttp7.responseText!="")
			{
				if (document.getElementById(divID))
				{
					document.getElementById(divID).innerHTML = xmlHttp7.responseText;
				}
			}
		}
	}
	var newDate = new Date();
	
	xmlHttp7.open("GET",websiterootaddress+"functions/ajax_basket3.asp?t="+newDate.getTime(),true);
	xmlHttp7.send(null);
}

//=================================================================================================================

xmlHttp_search=new XMLHttpRequest();

function lookup(inputString,catID) 
{
	xmlHttp_search.cancel;
	if(inputString.length > 2) 
	{
		try
		{
			
		}
		catch (e)
		{
			try
			{
				xmlHttp_search=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp_search=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
			 
		xmlHttp_search.onreadystatechange=function()
		{
			if(xmlHttp_search.readyState==4)
			{
				if (xmlHttp_search.responseText!="")
				{
					if (document.getElementById("suggestions"))
					{
						document.getElementById("suggestions").innerHTML = xmlHttp_search.responseText;
						document.getElementById("suggestions").style.display="";
					}
				}
			}
		}
		var newDate = new Date();
		
		xmlHttp_search.open("GET",websiterootaddress+"functions/ajax_fastSearch.asp?t="+newDate.getTime()+"&queryString="+encodeURIComponent(inputString)+"&catID="+catID,true);
		xmlHttp_search.send(null);
	}
}

//=================================================================================================================

function cityList(countryID,divID,selectID,tr_cityID,tr_townID,checkFieldCity,checkFieldTown)
{
	document.getElementById(tr_townID).style.display="none";
	document.getElementById(checkFieldTown).title="";
	document.getElementById(checkFieldCity).options.length=0;
	document.getElementById(checkFieldCity).options[document.getElementById(checkFieldCity).options.length] = new Option("", "", false, false);
	document.getElementById(checkFieldTown).options.length=0;
	document.getElementById(checkFieldTown).options[document.getElementById(checkFieldTown).options.length] = new Option("", "", false, false);
	if (countryID != "")
	{
		try
		{
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
	
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				if (xmlHttp.responseText!="")
				{
					if (xmlHttp.responseText == "0")
					{
						document.getElementById(tr_cityID).style.display="none";
						document.getElementById(tr_townID).style.display="none";
						document.getElementById(checkFieldCity).title="";
						document.getElementById(checkFieldTown).title="";
					}
					else
					{
						document.getElementById(checkFieldCity).title="-";
						//document.getElementById(checkFieldTown).title="-";
						document.getElementById(tr_cityID).style.display="";
					//	document.getElementById(tr_townID).style.display="";
						var sonuc;
						var elem;
						elem = document.getElementById(divID);
						elem.options.length=0;
						sonuc = xmlHttp.responseText;
						sonuc = sonuc.split("$$$");
						elem.options[elem.options.length] = new Option("", "", false, false);
						for (var i=0; i<sonuc.length-1; i++)
						{
							elem.options[elem.options.length] = new Option(sonuc[i].split("|||")[1], sonuc[i].split("|||")[0], false, false);
						}
					}
				}
			}
		}
		var newDate = new Date();
		xmlHttp.open("GET",websiterootaddress+"functions/ajax_cityList.asp?t="+newDate.getTime()+"&countryID="+countryID+"&selectID="+selectID,true);
		xmlHttp.send(null);
	}
}

//=================================================================================================================

function townList(cityID,divID,selectID,tr_townID,checkFieldTown)
{
	document.getElementById(checkFieldTown).options.length=0;
	document.getElementById(checkFieldTown).options[document.getElementById(checkFieldTown).options.length] = new Option("", "", false, false);
	if (cityID != "")
	{
		try
		{
			xmlHttp5=new XMLHttpRequest();
		}
		catch (e)
		{
			try
			{
				xmlHttp5=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp5=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
	
		xmlHttp5.onreadystatechange=function()
		{
			if(xmlHttp5.readyState==4)
			{
				if (xmlHttp5.responseText!="")
				{
					if (xmlHttp5.responseText == "0")
					{
						document.getElementById(tr_townID).style.display="none";
						document.getElementById(checkFieldTown).title="";
					}
					else
					{
						document.getElementById(checkFieldTown).title="-";
						document.getElementById(tr_townID).style.display="";
						var sonuc;
						var elem;
						elem = document.getElementById(divID);
						elem.options.length=0;
						sonuc = xmlHttp5.responseText;
						sonuc = sonuc.split("$$$");
						elem.options[elem.options.length] = new Option("", "", false, false);
						for (var i=0; i<sonuc.length-1; i++)
						{
							elem.options[elem.options.length] = new Option(sonuc[i].split("|||")[1], sonuc[i].split("|||")[0], false, false);
						}
					}
				}
			}
		}
		var newDate = new Date();
		xmlHttp5.open("GET",websiterootaddress+"functions/ajax_townList.asp?t="+newDate.getTime()+"&cityID="+cityID+"&selectID="+selectID,true);
		xmlHttp5.send(null);
	}
	else
	{
		document.getElementById(tr_townID).style.display="none";
		document.getElementById(checkFieldTown).title="";
	}
}

//=================================================================================================================

function cityList2(countryID,divID,selectID,tr_cityID,tr_townID,checkFieldCity,checkFieldTown)
{
	document.getElementById(tr_townID).style.display="none";
	document.getElementById(checkFieldTown).title="";
	document.getElementById(checkFieldCity).options.length=0;
	document.getElementById(checkFieldCity).options[document.getElementById(checkFieldCity).options.length] = new Option("", "", false, false);
	document.getElementById(checkFieldTown).options.length=0;
	document.getElementById(checkFieldTown).options[document.getElementById(checkFieldTown).options.length] = new Option("", "", false, false);
	if (countryID != "")
	{
		try
		{
			xmlHttp4=new XMLHttpRequest();
		}
		catch (e)
		{
			try
			{
				xmlHttp4=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp4=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
	
		xmlHttp4.onreadystatechange=function()
		{
			if(xmlHttp4.readyState==4)
			{
				if (xmlHttp4.responseText!="")
				{
					if (xmlHttp4.responseText == "0")
					{
						document.getElementById(tr_cityID).style.display="none";
						document.getElementById(tr_townID).style.display="none";
						document.getElementById(checkFieldCity).title="";
						document.getElementById(checkFieldTown).title="";
					}
					else
					{
						document.getElementById(checkFieldCity).title="-";
						//document.getElementById(checkFieldTown).title="-";
						document.getElementById(tr_cityID).style.display="";
					//	document.getElementById(tr_townID).style.display="";
						var sonuc;
						var elem;
						elem = document.getElementById(divID);
						elem.options.length=0;
						sonuc = xmlHttp4.responseText;
						sonuc = sonuc.split("$$$");
						elem.options[elem.options.length] = new Option("", "", false, false);
						for (var i=0; i<sonuc.length-1; i++)
						{
							elem.options[elem.options.length] = new Option(sonuc[i].split("|||")[1], sonuc[i].split("|||")[0], false, false);
						}
						document.getElementById("cityID_fatura").value = document.getElementById("cityID_teslimat").value;
					}
				}
			}
		}
		var newDate = new Date();
		xmlHttp4.open("GET",websiterootaddress+"functions/ajax_cityList.asp?t="+newDate.getTime()+"&countryID="+countryID+"&selectID="+selectID,true);
		xmlHttp4.send(null);
	}
}

//=================================================================================================================

function townList2(cityID,divID,selectID,tr_townID,checkFieldTown)
{
	document.getElementById(checkFieldTown).options.length=0;
	document.getElementById(checkFieldTown).options[document.getElementById(checkFieldTown).options.length] = new Option("", "", false, false);
	if (cityID != "")
	{
		try
		{
			xmlHttp7=new XMLHttpRequest();
		}
		catch (e)
		{
			try
			{
				xmlHttp7=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp7=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
	
		xmlHttp7.onreadystatechange=function()
		{
			if(xmlHttp7.readyState==4)
			{
				if (xmlHttp7.responseText!="")
				{
					if (xmlHttp7.responseText == "0")
					{
						document.getElementById(tr_townID).style.display="none";
						document.getElementById(checkFieldTown).title="";
					}
					else
					{
						document.getElementById(checkFieldTown).title="-";
						document.getElementById(tr_townID).style.display="";
						var sonuc;
						var elem;
						elem = document.getElementById(divID);
						elem.options.length=0;
						sonuc = xmlHttp7.responseText;
						sonuc = sonuc.split("$$$");
						elem.options[elem.options.length] = new Option("", "", false, false);
						for (var i=0; i<sonuc.length-1; i++)
						{
							elem.options[elem.options.length] = new Option(sonuc[i].split("|||")[1], sonuc[i].split("|||")[0], false, false);
						}
						document.getElementById("townID_fatura").value = document.getElementById("townID_teslimat").value;
					}
				}
			}
		}
		var newDate = new Date();
		xmlHttp7.open("GET",websiterootaddress+"functions/ajax_townList.asp?t="+newDate.getTime()+"&cityID="+cityID+"&selectID="+selectID,true);
		xmlHttp7.send(null);
	}
	else
	{
		document.getElementById(tr_townID).style.display="none";
		document.getElementById(checkFieldTown).title="";
	}
}

function openLists()
{
	if (document.getElementById("divListsContainer").style.display=="none")
	{
		document.getElementById("divListsContainer").style.display="";
	}
	else
	{
		document.getElementById("divListsContainer").style.display="none";
	}
}