// JavaScript Document
function GetXmlHttpObject(){ 
var objXMLHttp=null
if (window.XMLHttpRequest){objXMLHttp=new XMLHttpRequest()}else if (window.ActiveXObject){objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")}return objXMLHttp
}

function CreateInputForm(InputName,InputType,InputArguments,DivWidth){
	InputWidth = parseInt(parseInt(DivWidth)-8)
	StrArg = '<table border="0" cellpadding="0" cellspacing="0"><tr><td width="2px" height="17px"><img src="images/input_left.jpg" style="padding-top:2px;" ></td><td width=""><input name="'+InputName+'" type="'+InputType+'" class=InputText id="'+InputName+'" style="width:'+DivWidth+'px;" '+InputArguments+' /></td><td width="2px" height="17px"><img src="images/input_right.jpg"></td></tr></table>'
	document.writeln(StrArg);							
}

function AddBox(Element,Id){
	
	var now = new Date()
	xmlHttp=GetXmlHttpObject()
	xmlHttp.onreadystatechange=function(){
		
		if (xmlHttp.readyState==4){
			if(xmlHttp.responseText=="true"){
			if(Element){
				Element.src="images/add_ed.gif";
				Element.onclick="";
				Element.style.cursor="default";
			}
			document.location.href=document.location.href
			}else{
				alert("Bir hata olustu ve ürün eklenemedi.");
				}
		}
	} 
		
	xmlHttp.open("GET","Application.sys?n=1&s="+Id+"&d="+now,true)
	xmlHttp.send(null)
	
}
	
function IsMail(MVal) {

	var regex = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
	return regex.test(MVal);

}

function MailExists(iMail,el){
			var now = new Date()
			xmlHttp=GetXmlHttpObject()
			xmlHttp.onreadystatechange=function(){
				
				if (xmlHttp.readyState==4){
					if(xmlHttp.responseText=="true"){el.value=0}else if(xmlHttp.responseText=="false"){el.value=1}
					}
				}
				
			xmlHttp.open("GET","Application.sys?n=2&s="+iMail+"&d="+now,true)
			xmlHttp.send(null)
}


function CustomerLogin(m,p,x){
	if(m=="" || p==""){
		alert("Lütfen E-Posta adresinizi veya sifrenizi giriniz.");
		return false;
		}
		
	var now = new Date()
	xmlHttp=GetXmlHttpObject()
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4){
			if(xmlHttp.responseText=="true"){
				document.location.href=x;
			}else{
				alert("Hatali E-Posta veya sifre.")
				return false;
				}
		}
	} 
		
	xmlHttp.open("GET","Application.sys?n=4&m="+m+"&p="+p+"&d="+now,true)
	xmlHttp.send(null)
	
}

function SeeNotifyBox(NotifyType,NotifyHeader,NotifyText){
			document.getElementById("Notify").style.display='none';
			
			HtmlTag  = '<div>'
            HtmlTag += '  <div id="NotifyTop"></div>'
            HtmlTag += '  <div id="NotifyText"><div class="NotifyHeader">'+NotifyHeader+'</div><div class="NotifyText">'+NotifyText+'</div><div><img src="images/nof_close.gif" style="cursor:pointer;" onclick="CloseNotifyBox();"></div></div>'
            HtmlTag += '  <div id="NotifyBottom"></div>'
            HtmlTag += '</div>'

			if(NotifyText!=""){
			document.getElementById("Notify").innerHTML=HtmlTag;
			document.getElementById("Notify").style.display='';
			}
	}
function CloseNotifyBox(){document.getElementById("Notify").style.display='none';}