﻿var helpWnd=0;
function HeplO(){
if(!helpWnd){
helpWnd = window.open('help.asp','','scrollbars=yes,top=0,left=2,height=200,width='+(screen.availWidth-10));
window.moveTo(0,200)
window.resizeTo(screen.availWidth,screen.availHeight-200);
}
else helpWnd.focus();
}

function Farsi(){
	//Farsi Unicode Replacer ©May 2002 By AFS (afs_d@yahoo.com)
	AFS_SetFormat();
	if(event.keyCode>=32 && event.srcElement.format!="em")
		event.keyCode = " !؛#$%&گ)(×+و-./٠١٢٣٤٥٦٧٨٩:كؤ=،؟@ِأ›’ُ‘لآة”“‚ءإ÷‍“ٌٍ‏ْ‹ً«‎»جژچ^ـپشذزيثبلاهتنمئدخحضقسفعرصطغظ}|{ّ".charCodeAt(event.keyCode-32);
}

var ErrorMessages = new Array();
	ErrorMessages[0] = "&#1606;&#1575;&#1605; &#1582;&#1608;&#1583; &#1585;&#1575; &#1608;&#1575;&#1585;&#1583; &#1603;&#1606;&#1610;&#1583;";
	ErrorMessages[1] = "&#1578;&#1604;&#1601;&#1606; &#1578;&#1605;&#1575;&#1587; &#1582;&#1608;&#1583; &#1585;&#1575; &#1608;&#1575;&#1585;&#1583; &#1603;&#1606;&#1610;&#1583;";
	ErrorMessages[200] = "&#1610;&#1603; &#1605;&#1581;&#1604;&#1607; &#1585;&#1575; &#1575;&#1606;&#1578;&#1582;&#1575;&#1576; &#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[4] = "&#1570;&#1583;&#1585;&#1587; &#1589;&#1581;&#1610;&#1581; &#1606;&#1605;&#1610;&#8204;&#1576;&#1575;&#1588;&#1583;"
	ErrorMessages[8] = "&#1608;&#1590;&#1593;&#1610;&#1578; &#1587;&#1575;&#1582;&#1578;&#1605;&#1575;&#1606; &#1585;&#1575; &#1605;&#1588;&#1582;&#1589; &#1603;&#1606;&#1610;&#1583;";
	ErrorMessages[12] = "&#1605;&#1608;&#1602;&#1593;&#1610;&#1578; &#1580;&#1594;&#1585;&#1575;&#1601;&#1610;&#1575;&#1610;&#1610; &#1587;&#1575;&#1582;&#1578;&#1605;&#1575;&#1606; &#1605;&#1608;&#1585;&#1583; &#1606;&#1610;&#1575;&#1586; &#1575;&#1587;&#1578;";
	ErrorMessages[20] = "&#1606;&#1608;&#1593; &#1587;&#1575;&#1582;&#1578;&#1605;&#1575;&#1606; &#1585;&#1575; &#1578;&#1593;&#1610;&#1610;&#1606; &#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[38] = "&#1608;&#1590;&#1593;&#1610;&#1578; &#1603;&#1606;&#1608;&#1606;&#1610; &#1587;&#1575;&#1582;&#1578;&#1605;&#1575;&#1606; &#1585;&#1575; &#1605;&#1588;&#1582;&#1589; &#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[45] = "&#1605;&#1587;&#1575;&#1581;&#1578; &#1586;&#1605;&#1610;&#1606; &#1585;&#1575; &#1608;&#1575;&#1585;&#1583;&#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[46] = "&#1591;&#1608;&#1604; &#1576;&#1585; &#1586;&#1605;&#1610;&#1606; &#1585;&#1575; &#1608;&#1575;&#1585;&#1583;&#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[47] = "&#1578;&#1593;&#1583;&#1575;&#1583; &#1591;&#1576;&#1602;&#1575;&#1578; &#1587;&#1575;&#1582;&#1578;&#1605;&#1575;&#1606; &#1585;&#1575; &#1605;&#1588;&#1582;&#1589; &#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[48] = "&#1578;&#1593;&#1583;&#1575;&#1583; &#1608;&#1575;&#1581;&#1583;&#1607;&#1575;&#1610; &#1587;&#1575;&#1582;&#1578;&#1605;&#1575;&#1606; &#1585;&#1575; &#1605;&#1588;&#1582;&#1589; &#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[51] = "&#1606;&#1575;&#1605; &#1582;&#1740;&#1575;&#1576;&#1575;&#1606; &#1585;&#1575; &#1605;&#1588;&#1582;&#1589;&nbsp; &#1705;&#1606;&#1740;&#1583;"
	ErrorMessages[53] = "&#1606;&#1608;&#1593; &#1606;&#1605;&#1575;&#1610; &#1587;&#1575;&#1582;&#1578;&#1605;&#1575;&#1606; &#1585;&#1575; &#1605;&#1593;&#1610;&#1610;&#1606; &#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[52] = "&#1606;&#1608;&#1593; &#1575;&#1587;&#1578;&#1582;&#1585; &#1585;&#1575; &#1578;&#1593;&#1610;&#1610;&#1606; &#1603;&#1606;&#1610;&#1583;"
	ErrorMessages[54] = "&#1606;&#1608;&#1593; &#1587;&#1606;&#1583; &#1605;&#1608;&#1585;&#1583; &#1606;&#1610;&#1575;&#1586; &#1575;&#1587;&#1578;"
	ErrorMessages[55] = "&#1588;&#1582;&#1589; &#1578;&#1606;&#1592;&#1610;&#1605; &#1603;&#1606;&#1606;&#1583;&#1607; &#1585;&#1575; &#1605;&#1588;&#1582;&#1589; &#1603;&#1606;&#1610;&#1583;"
	

function AFS_ValidataForm(FormO){

	var OutStr = new String("");
	var HasE = false;
	Form = FormO.all.tags("INPUT");
	for(i=0;i<Form.length;i++){
		if(Form(i).type == "text" && Form(i).value.length == 0  && Form(i).requier == "1"){
			Form(i).id = "err"+i;
			
			HasE = true;
			OutStr += "<a onclick=err"+i+".focus() class=ew style='cursor:hand'><img border=0 alt=ERROR src=Images/error.gif> " + ErrorMessages[i] + "</a><br>";
			}
		else if(Form(i).type == "checkbox" && Form(i).requier == "1"){
				var KO = 0;
				for(j=i;;j++){
					if(Form(j).checked == true)KO=1;
					if(Form(j).name != Form(i).name)break;
					}
				if(!KO){
					Form(i).id = "err"+i;
					//alert(j);
					HasE = true;
					OutStr += "<a onclick=err"+i+".focus() class=ew style='cursor:hand'><img border=0 alt=ERROR src=Images/error.gif> " + ErrorMessages[j] + "</a><br>";
					}
				i=j-1;
			}
		}
	Form = FormO.all.tags("SELECT");
	for(i=0;i<Form.length;i++){
		if(Form(i).value == "?"){
			if	(Form(i).requier == "1"){
				Form(i).id = "err"+(i+50);
				HasE = true;
				OutStr += "<a onclick=err"+(i+50)+".focus() class=ew style='cursor:hand'><img border=0 alt=ERROR src=Images/error.gif> " + ErrorMessages[i+50] + "</a><br>";
				}
			else{;
				//Form(i).id = "err"+(i+50);
				//if(ErrorMessages[i+50]!=null) OutStr += "<a onclick=err"+(i+50)+".focus() class=ew style='cursor:hand'><img border=0 alt=WARNING src=Images/warning.gif> " + ErrorMessages[i+50] + "</a><br>";
				}
			}
		}
	
				
	Board.innerHTML = (OutStr.length>1)? OutStr:"Please Wait ...";
	
	if (HasE == true) return false;
	else if (HasE == false && OutStr.length>1){
		if(confirm("Some Warnings Are In Your Data Do You Want To Continue Without Repairing Them?"))
			return true;
		else return false;
		}
	else return true;
}

function AFS_SetPrice(){

		if (event.srcElement.notype == "price" && event.srcElement.value.length!=0){
			var NoM = new String();
			var k,m,n;
			event.srcElement.value = event.srcElement.value.replace(/,/g,"");
			k = (event.srcElement.value.length%3==0)? 3:event.srcElement.value.length%3;
			m = (k==3)? parseInt(event.srcElement.value.length/3)-1:parseInt(event.srcElement.value.length/3);
			NoM = event.srcElement.value.slice(0,k);
			for(i=0;i<m;i++)NoM += "," + event.srcElement.value.slice((i*3)+k,(i*3)+k+3);
			event.srcElement.value = NoM;
			}

}

function AFS_AddNew(S,Mes){
	FInput(S);	
}

function AFS_SetFormat(){
	
	if(event.srcElement.tagName == "INPUT")
		if(event.srcElement.type == "text")
			if(event.keyCode != 13 && event.keyCode != 8 ){
				if( event.srcElement.format == "no")
					if( event.keyCode <47 || event.keyCode >58)event.keyCode = 0;
				else if (event.srcElement.format == "em")
					if ( "`~\\/\"'!#$%^&*()+=}{][|,?;:><".indexOf(String.fromCharCode(event.keyCode)) != -1)event.keyCode = 0;
				}
}

function AFS_Floor(val,confirm){
	
	
	if(isNaN(parseInt(val))==true){
		var valt = new String(val);
		var valtt = new String("");
		var pat = "٠١٢٣٤٥٦٧٨٩";
		for(i=0;i<valt.length;i++)
			valtt += parseInt(pat.indexOf(valt.charAt(i)));
		val = parseInt(valtt);
		}
	else val = parseInt(val);
	var Go = false;
	FloorssinnerHTML = '<table border="0" cellspacing="0" style="border-collapse: collapse" width="470"><tr><td width="10%" align="center"><p><font face="Tahoma" size="1">&#1591;&#1576;&#1602;&#1575;&#1578;</font></td><td width="9%" align="center" bgcolor="#83C8E9"><font face="Tahoma" size="1">&#1586;&#1610;&#1585;&#1576;&#1606;&#1575;</font></td><td width="9%" align="center"><font face="Tahoma" size="1">&#1575;&#1578;&#1575;&#1602; &#1582;&#1608;&#1575;&#1576;</font></td><td width="9%" align="center" bgcolor="#83C8E9"><font face="Tahoma" size="1">&#1603;&#1575;&#1576;&#1610;&#1606;&#1578;</font></td><td width="9%" align="center" bgcolor="#83C8E9"><font face="Tahoma" size="1">&#1587;&#1585;&#1608;&#1610;&#1587; &#1576;&#1607;&#1583;&#1575;&#1588;&#1578;&#1610;</font></td><td width="9%" align="center"><font face="Tahoma" size="1">&#1603;&#1601;</font></td><td width="9%" align="center" bgcolor="#83C8E9"><font face="Tahoma" size="1">Open</font></td><td width="9%" align="center"><font face="Tahoma" size="1">&#1662;&#1575;&#1585;&#1603;&#1610;&#1606;&#1711;</font></td><td width="9%" align="center" bgcolor="#83C8E9"><font face="Tahoma" size="1">&#1575;&#1606;&#1576;&#1585;&#1610;</font></td><td width="9%" align="center"><font face="Tahoma" size="1">&#1588;&#1608;&#1605;&#1610;&#1606;&#1607;</font></td>';

	if(confirm){
		Go = window.confirm("Last Floor Data Will Be Lost Do. Are You Sure To Continue?");
		if(Go) FloorssinnerHTML += '<tr><td align="center" width="10%"><p align="left"><select  style="font-family:Tahoma" onchange="if(this.value==\'\')AFS_Floor(Floorsss.value,0);" size="1" name="FloorNumber" class="In" style="font-family: Verdana; font-size: 10px"><option value=all selected>&#1607;&#1605;&#1607;</option><option value=\'\'>&#1591;&#1576;&#1602;&#1575;&#1578;</option></select></td><td align="center" width="9%" bgcolor="#83C8E9"><input notype="price" format="no" type="text" dir=ltr name="FloorArea" size="2" class="In"></td><td align="center" width="9%"><input dir=ltr format="no" maxlength=2 type="text" name="Bedroom" size="1" class="In"></td><td align="center" width="9%" bgcolor="#83C8E9"><select  style="font-family:Tahoma" name="Cabinet" size="1" style="font-family: Verdana; font-size: 10px" class="In"><option value="?" selected>?</option><option>&#1570;&#1576;&#1583;&#1575;&#1585;&#1582;&#1575;&#1606;&#1607;</option><option>&#1605;&#1588;&#1578;&#1585;&#1603;</option><option>&#1601;&#1575;&#1610;&#1576;&#1585;&#1711;&#1604;&#1575;&#1587;</option><option>&#1601;&#1608;&#1585;&#1605;&#1578;</option><option>&#1605;&#1576;&#1604;&#1607;</option><option>&#1711;&#1575;&#1586;&#1608;&#1585;</option><option>&#1583;&#1604;&#1582;&#1608;&#1575;&#1607;</option><option>&#1605;&#1575;&#1580; &#1606;&#1605;&#1575;</option><option>&#1601;&#1604;&#1586;&#1610;</option><option>&#1606;&#1583;&#1575;&#1585;&#1583;</option><option>&#1606;&#1601; &#1570;&#1604;&#1605;&#1575;&#1606;</option><option>&#1670;&#1608;&#1576;&#1610;</option><option>&#1670;&#1608;&#1576;&#1610; &#1601;&#1604;&#1586;&#1610;</option></select></td><td><select  style="font-family:Tahoma" name="Toilet" size="1" style="font-family: Verdana; font-size: 10px" class="In"><option value="?" selected>?</option><option>&#1575;&#1610;&#1585;&#1575;&#1606;&#1610;</option><option>&#1575;&#1610;&#1585;&#1575;&#1606;&#1610; &#1601;&#1585;&#1606;&#1711;&#1610;</option><option>&#1583;&#1604;&#1582;&#1608;&#1575;&#1607;</option><option>&#1605;&#1588;&#1578;&#1585;&#1603;</option><option>&#1601;&#1585;&#1606;&#1711;&#1610;</option></select></td><td><select  style="font-family:Tahoma" name="Flooring" size="1" style="font-family: Verdana; font-size: 10px" class="In"><option value="?" selected>?</option><option>&#1587;&#1610;&#1605;&#1575;&#1606;</option><option>&#1587;&#1585;&#1575;&#1605;&#1610;&#1603;</option><option>&#1711;&#1585;&#1575;&#1606;&#1610;&#1578;</option><option>&#1603;&#1601; &#1662;&#1608;&#1588;</option><option>&#1587;&#1606;&#1711;</option><option>&#1587;&#1606;&#1711; &#1608; &#1576;&#1585;&#1606;&#1586;</option><option>&#1605;&#1608;&#1603;&#1578;</option><option>&#1605;&#1608;&#1603;&#1578; &#1587;&#1585;&#1575;&#1605;&#1610;&#1603;</option><option>&#1605;&#1608;&#1603;&#1578; &#1587;&#1606;&#1711;</option><option>&#1605;&#1608;&#1603;&#1578; &#1605;&#1608;&#1586;&#1575;&#1574;&#1610;&#1603;</option><option>&#1605;&#1608;&#1603;&#1578; &#1662;&#1575;&#1585;&#1603;&#1578;</option><option>&#1605;&#1608;&#1586;&#1575;&#1574;&#1610;&#1603;</option><option>&#1662;&#1575;&#1585;&#1603;&#1578;</option><option>&#1662;&#1575;&#1585;&#1603;&#1578; &#1587;&#1585;&#1575;&#1605;&#1610;&#1603;</option><option>&#1603;&#1575;&#1588;&#1610;</option></select></td><td align="center" width="9%" bgcolor="#83C8E9"><input type="checkbox" name="Ser1" value="_open"></td><td align="center" width="9%"><input type="checkbox" name="Ser1" value="_parking"></td><td align="center" width="9%" bgcolor="#83C8E9"><input type="checkbox" name="Ser1" value="_repository"></td><td align="center" width="9%"><input type="checkbox" name="Ser1" value="_fireplace"></td></tr>' ;
		}
	else{ 
		for(i=0;i<val;i++)
			FloorssinnerHTML += '<tr><td align="center" width="10%"><p align="left"><select  style="font-family:Tahoma" style="font-family:Tahoma" onchange="if(this.value==\'\')AFS_AddNew(this,\'Enter Floor Number\');else if(this.value==\'all\')AFS_Floor(1,1);" size="1" name="FloorNumber" class="In" style="font-family: Verdana; font-size: 10px"><option value=? selected>?</option><option value=all>&#1607;&#1605;&#1607;</option><option value="&#1607;&#1605;&#1603;&#1601;">&#1607;&#1605;&#1603;&#1601;</option><option>&#1583;&#1610;&#1711;&#1585;</option></select></td><td align="center" width="9%" bgcolor="#83C8E9"><input notype="price" format="no" type="text" dir=ltr name="FloorArea" size="2" class="In"></td><td align="center" width="9%"><input  format="no" maxlength=2 type="text" dir=ltr name="Bedroom" size="1" class="In"></td><td align="center" width="9%" bgcolor="#83C8E9"><select style="font-family:Tahoma" name="Cabinet" size="1" style="font-family: Verdana; font-size: 10px" class="In"><option value="?" selected>?</option><option>&#1570;&#1576;&#1583;&#1575;&#1585;&#1582;&#1575;&#1606;&#1607;</option><option>&#1605;&#1588;&#1578;&#1585;&#1603;</option><option>&#1601;&#1575;&#1610;&#1576;&#1585;&#1711;&#1604;&#1575;&#1587;</option><option>&#1601;&#1608;&#1585;&#1605;&#1578;</option><option>&#1605;&#1576;&#1604;&#1607;</option><option>&#1711;&#1575;&#1586;&#1608;&#1585;</option><option>&#1583;&#1604;&#1582;&#1608;&#1575;&#1607;</option><option>&#1605;&#1575;&#1580; &#1606;&#1605;&#1575;</option><option>&#1601;&#1604;&#1586;&#1610;</option><option>&#1606;&#1583;&#1575;&#1585;&#1583;</option><option>&#1606;&#1601; &#1570;&#1604;&#1605;&#1575;&#1606;</option><option>&#1670;&#1608;&#1576;&#1610;</option><option>&#1670;&#1608;&#1576;&#1610; &#1601;&#1604;&#1586;&#1610;</option></select></td><td align="center" width="9%" bgcolor="#83C8E9"><select style="font-family:Tahoma" name="Toilet" size="1" style="font-family: Verdana; font-size: 10px" class="In"><option value="?" selected>?</option><option>&#1575;&#1610;&#1585;&#1575;&#1606;&#1610;</option><option>&#1575;&#1610;&#1585;&#1575;&#1606;&#1610; &#1601;&#1585;&#1606;&#1711;&#1610;</option><option>&#1583;&#1604;&#1582;&#1608;&#1575;&#1607;</option><option>&#1605;&#1588;&#1578;&#1585;&#1603;</option><option>&#1601;&#1585;&#1606;&#1711;&#1610;</option></select></td><td align="center" width="9%" bgcolor="#83C8E9"><select style="font-family:Tahoma" name="Flooring" size="1" style="font-family: Verdana; font-size: 10px" class="In"><option value="?" selected>?</option><option>&#1587;&#1610;&#1605;&#1575;&#1606;</option><option>&#1587;&#1585;&#1575;&#1605;&#1610;&#1603;</option><option>&#1711;&#1585;&#1575;&#1606;&#1610;&#1578;</option><option>&#1603;&#1601; &#1662;&#1608;&#1588;</option><option>&#1587;&#1606;&#1711;</option><option>&#1587;&#1606;&#1711; &#1608; &#1576;&#1585;&#1606;&#1586;</option><option>&#1605;&#1608;&#1603;&#1578;</option><option>&#1605;&#1608;&#1603;&#1578; &#1587;&#1585;&#1575;&#1605;&#1610;&#1603;</option><option>&#1605;&#1608;&#1603;&#1578; &#1587;&#1606;&#1711;</option><option>&#1605;&#1608;&#1603;&#1578; &#1605;&#1608;&#1586;&#1575;&#1574;&#1610;&#1603;</option><option>&#1605;&#1608;&#1603;&#1578; &#1662;&#1575;&#1585;&#1603;&#1578;</option><option>&#1605;&#1608;&#1586;&#1575;&#1574;&#1610;&#1603;</option><option>&#1662;&#1575;&#1585;&#1603;&#1578;</option><option>&#1662;&#1575;&#1585;&#1603;&#1578; &#1587;&#1585;&#1575;&#1605;&#1610;&#1603;</option><option>&#1603;&#1575;&#1588;&#1610;</option></select></td><td align="center" width="9%" bgcolor="#83C8E9"><input type="checkbox" name="Ser'+(i+1)+'" value="_open"></td><td align="center" width="9%"><input type="checkbox" name="Ser'+(i+1)+'" value="_parking"></td><td align="center" width="9%" bgcolor="#83C8E9"><input type="checkbox" name="Ser'+(i+1)+'" value="_repository"></td><td align="center" width="9%"><input type="checkbox" name="Ser'+(i+1)+'" value="_fireplace"></td></tr>' ;
		}

		FloorssinnerHTML += "</table>";
		Floorss.innerHTML = FloorssinnerHTML;
}

function AFS_ChForm(f){

	for(i=0;i<f.all.tags("INPUT").length;i++)
		if(f.all.tags("INPUT").item(i).value == "" && f.all.tags("INPUT").item(i).req != "no") return false;
	for(i=0;i<f.all.tags("TEXTAREA").length;i++)
		if(f.all.tags("TEXTAREA").item(i).value == "" && f.all.tags("TEXTAREA").item(i).req != "no") return false;
	return true;
	
}
	function ins(cd){
		if(!window.opener) return false;
		if(cd!=8){
			if(window.opener.aobj.format!="no" && window.opener.aobj.format!="em") window.opener.aobj.value += " !؛#$%&گ)(×+و-./٠١٢٣٤٥٦٧٨٩:كؤ=،؟@ِأ›’ُ‘لآة”“‚ءإ÷‍“ٌٍ‏ْ‹ً«‎»جژچ^ـپشذزيثبلاهتنمئدخحضقسفعرصطغظ}|{ّ".charAt(cd.charCodeAt(0)-32);
		}
		else window.opener.aobj.value = window.opener.aobj.value.slice(0,window.opener.aobj.value.length-1);
	}