// Provided by Rad eCommerce - Maziar Barzi

//  ********************************************************************
//  ********************************************************************
//  Mail Login Form
function UseridComplete()
{
	if ( logon.miniuserid.value == "" || logon.miniuserid.value == " " )
	{
		logon.miniuserid.focus()
		return false
	}
	if ( logon.minipass.value == "" || logon.minipass.value == " " )
	{
		logon.minipass.focus()
		return false
	}

	clsu = logon.miniuserid.value
	clsp = logon.minipass.value

	logon.oPassID.value = clsp
	logon.oUserID.value = clsu + "@amirfakhrian.com"

	logon.miniuserid.value = ""
	logon.minipass.value = ""

//	 alert ( logon.oUserID.value + "\n" + logon.oPassID.value )
}	






//  ********************************************************************
//  ********************************************************************
//  Contact Reset Form
function ContactResetForm(ResetType)
{
	if (ResetType == 1 )
	{
		for (i=1;i<=4;i++)
		{
			document.getElementById("Error_"+i).className = "Makhfi"
		}
		frmContact.reset()
		frmContact.FullName.focus()
	}
	else
	{
		for (i=1;i<=4;i++)
		{
			document.getElementById("Error_"+i).className = "Makhfi"
			frmContact.ErrorMsg.value = ""
		}
	}
}





//  ********************************************************************
//  ********************************************************************
//  Contact Validation
function ContactValidation()
{
	ContactResetForm(2)

	if (frmContact.FullName.value == "" || frmContact.FullName.value == " ")
	{
		Error_1.className = "Ashkar"
		frmContact.FullName.focus()
		frmContact.FullName.select()
		return false
	}

	if (frmContact.Email.value == "")
	{
		frmContact.ErrorMsg.value = "Please enter your email address"
		Error_2.className = "Ashkar"
		frmContact.Email.focus()
		frmContact.Email.select()
		return false
	}
	else
	{
		if ( re.test(frmContact.Email.value) == false)
		{
			frmContact.ErrorMsg.value = "Invalid email address"
			Error_2.className = "Ashkar"
			frmContact.Email.focus()
			frmContact.Email.select()
			return false			
		}
	}

	if (frmContact.Subject.value == "" || frmContact.Subject.value == " ")
	{
		Error_3.className = "Ashkar"
		frmContact.Subject.focus()
		frmContact.Subject.select()
		return false
	}


	if (frmContact.Description.value.length < 10)
	{
		Error_4.className = "Ashkar"
		frmContact.Description.focus()
		frmContact.Description.select()
		return false			
	}

	frmContact.btnSubmit.disabled = true
	return true
}





//  ********************************************************************
//  ********************************************************************
//  Block key , Only Number
function BlockKeyNum()
{
	// Numeric Code
	if (event.keyCode < 45 || event.keyCode > 57) 
		event.returnValue = false
	// Enter Code
	if (event.keyCode == 13 )
		event.returnValue = true		
}




//  ********************************************************************
//  ********************************************************************
//  Comma , 3 digit
function Comma(myVal) {
 var T='',S=String(myVal),L=S.length-1, C, j;
  for (j=0; j<=L; j++)
	{
    T+=C=S.charAt(j);
    if ((j < L) && ((L-j)%3 == 0)) T+='.';
	 }
return T;
}


//  ********************************************************************
//  ********************************************************************
//  Preload Images
function FP_preloadImgs()
{
	var d=document,a=arguments; 
	if(!d.FP_imgs) d.FP_imgs=new Array();
	for(var i=0; i<a.length; i++)
	{ 
		d.FP_imgs[i]=new Image;
		d.FP_imgs[i].src=a[i];
	}
}



//  ********************************************************************
//  ********************************************************************
//  Object in Middle Page
function MiddlePage(objIDName,objWidth,sizeHeight)
{			
		WinSizWD = document.body.clientWidth
		WinSizHI = document.body.clientHeight	 	

		posLeft = ( WinSizWD - objWidth ) / 2
		posTop	= ( WinSizHI - sizeHeight ) / 2

		objIDName.style.left = posLeft
		objIDName.style.top = posTop
}










//  ********************************************************************
//  ********************************************************************
//  Html Tag for use memo fields in database
function EncryptHtml(theText) {
output = new String;
TextSize = theText.length;
output = ""

for (i = 0; i < TextSize; i++)
{

	CodeMatn = theText.charCodeAt(i) 

	if ( CodeMatn == 13 ) 
		TagHtml = "<p>"
	else
		TagHtml = String.fromCharCode(CodeMatn)

	if ( CodeMatn == 32 )
		rdl = "&nbsp;"

	output = output + TagHtml

}
return output;
}





//  ********************************************************************
//  ********************************************************************
//  Email Validation
function PortWin(pageURL)
{

	conf ='width=450,height=480,scrollbars=yes'
	conf += ',resizable=no'
	poop = window.open (pageURL,"poop",conf)	

}






//  ********************************************************************
//  ********************************************************************
//  Window Map
function MapWin(pageURL)
{

	conf ='width=648,height=452,scrollbars=yes'
	conf += ',resizable=no'
	poop = window.open (pageURL,"poop",conf)	

}











//  ********************************************************************
//  ********************************************************************
//  Email Validation
re=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/












//  ********************************************************************
//  ********************************************************************
//  Search Validaiton
function SearchValidate()
{
if (Search.q.value.length < 8)
{
	Search.q.select()
	return false
}
Search.btnSearch.disabled = true
return true
/*	if (frmContact.Descript.value.length < 10)
	{
		Error_4.cla	ssName = "Ashkar"
		frmContact.Descript.focus()
		frmContact.Descript.select()
		return false			
	}

	frmContact.btnContact.disabled = true
*/

}







//  ********************************************************************
//  ********************************************************************
//  Admin Login Validaiton
function LoginValidate()
{
	if (frmLogin.Login.value == "" || frmLogin.Login.value == " ")
	{
		frmLogin.Login.focus()
		return false
	}
	if (frmLogin.Password.value == "" || frmLogin.Password.value == " ")
	{
		frmLogin.Password.focus()
		return false
	}
	if (frmLogin.AntiRobot.value.length < 5)
	{
		frmLogin.AntiRobot.focus()
		return false
	}
	frmLogin.btnSignin.disabled = true
	return true
}

