// JavaScript Document
//fucntion to validate text box
function isValidText(txtname,msg,txtlength)
{
	if(txtname.value == '')
	{
		alert('Please enter '+msg);
		txtname.focus();
		return false;
	}
	else if(txtlength != '' && txtname.value.length < txtlength)
	{
		alert(msg+' should be '+txtlength+' characters length');
		txtname.focus();
		return false;
	}
	else
		return true;
}

//fucntion to compare two fields
function isCompare(txtname1,txtname2,msg)
{
	if(txtname1.value != txtname2.value)
	{
		alert(msg);
		txtname2.focus();
		return false;
	}
	else
		return true;
	
}
//function to validate select box
function isValidSelect(selectName,msg)
{
	if(selectName.value == '')
	{
		alert("Please choose "+msg+" from the list");
		selectName.focus();
		return false;
	}
	else
		return true;
}

//function to show hide div
function fnToggleDiv(showid,hideid)
{
	if(hideid != '')
		document.getElementById(hideid).style.display = 'none';
	if(showid != '')
		document.getElementById(showid).style.display = 'block';	
}

//fucntion to validate email
function isValidemail(emailStr) 
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var firstChars=validChars
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom="(" + firstChars + validChars + "*" + ")"
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) 
		 return false;
	else
		return true;
}

function fnValidateTellFriendForm(frm)
{
	if(!isValidText(frm.elements['yourname'],'Your Name'))
		return false;
	if(!isValidemail(frm.elements['youremail'].value))
	{
		alert("Please Enter valid your email");
		frm.elements['youremail'].focus();
		return false;
	}
	if(!isValidText(frm.elements['friendname'],'Friend Name'))
		return false;
	if(!isValidemail(frm.elements['friendemail'].value))
	{
		alert("Please Enter valid friend email");
		frm.elements['friendemail'].focus();
		return false;
	}
	if(!isValidText(frm.elements['message'],'Message'))
		return false;
		
	fnSendEmail(frm);
}

//function to show transperant image
function showHighSlide()
{
	var shadeDivObj = document.getElementById('shadeDiv');
	var pageHeight = document.body.offsetHeight;
	shadeDivObj.style.height = pageHeight+'px';
	
	var pageWidth = document.body.offsetWidth;
	shadeDivObj.style.width = pageWidth+'px';
	shadeDivObj.style.top = '0px';
	shadeDivObj.style.left = '0px';
	
	shadeDivObj.style.display = 'block';
	
	//display content div
	var contentDivObj = document.getElementById('infoDiv');
	document.getElementById('infoDiv_content').innerHTML = '<div align="center"><img src="admin/images/loading.gif" border="0"></div>';
	contentDivObj.style.display = 'block';
	
	var leftPos = parseInt((screen.width/2)-200);
	var topPos = parseInt((screen.height/2)-100);
	contentDivObj.style.top = topPos+"px";
	contentDivObj.style.left = leftPos+"px";
}

//function to close highslide div
function fnCloseHighSlide()
{
	document.getElementById('shadeDiv').style.display = 'none';
	document.getElementById('infoDiv').style.display = 'none';
}
