function checkEmail()
	{
	var strEmail, strError, countAtRate, countDot, i;	
	var checkAtRate, checkDot;
	var ValidChars,CountValidChars;
	ValidChars="abcdefghijklmnopqrstuvwxyz0123456789_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	strEmail = checkEmail.arguments[0];
	countAtRate=0;
	countDot=0;
	CountValidChars=0;
	if (strEmail.length >= 7)
		{		
		for(i=0;i<strEmail.length;i++)
			{
			if(strEmail.charAt(i)=="@")
				countAtRate++;
			if(strEmail.charAt(i)==".")
				countDot++;
			CountValidChars=0;
			for(j=0;j<ValidChars.length;j++)
				{
				if(strEmail.charAt(i)==ValidChars.charAt(j))
					{
					CountValidChars++;
					}
				}
			if(CountValidChars==0)
				{
				strError=0;
				break;
				}							
			}
		}
	checkAtRate=strEmail.indexOf("@",1);
	checkDot=strEmail.indexOf(".",1);
	for(i=1;i<countDot;i++)
		checkDot=strEmail.indexOf(".",checkDot+1);
	if(countAtRate==1 && countDot > 0 && strEmail.length >=7 && strError != 0)
		strError=1;
	else
		strError=0;
	if(checkDot>=strEmail.length-2)
		strError=0;
	if(strEmail.charAt(0)=="@" || strEmail.charAt(strEmail.length-1)=="@")
		strError=0;
	if(strEmail.charAt(0)=="." || strEmail.charAt(strEmail.length-1)==".")
		strError=0;
	if(checkDot < checkAtRate)
		strError=0;	

	return strError;
	}


function frmGuestbookValidate1(dm){

	var strError="";
	
	if(dm.entry_email.value=="")
		strError += "Email Address\n";
	else if(checkEmail(dm.entry_email.value)==0)
		strError += "Invalid Email address\n";
	
	
	if(dm.entry_author.value=="")
		strError += "Name\n";
	if(dm.entry_age.value=="")
		strError += "Age\n";
	if(dm.entry_comments.value=="")
		strError += "Comments\n";	
	if(strError=="")
		return true;
	else{
		alert("Invalid Fields\n------------------------------------\n"+strError);
		return false;
	}
}


function frmGuestbookValidate(dm,pg){

	var strError="";
	if(dm.entry_author.value=="")
		strError += "Name\n";
		
	if(dm.entry_email.value=="")
		strError += "Email Address\n";
	else if(checkEmail(dm.entry_email.value)==0)
		strError += "Invalid Email address\n";	
	
	
	if(dm.entry_age.value=="")
		strError += "Age\n";
	if(dm.entry_comments.value=="")
		strError += "Comments\n";
		
	if(strError != "")
	
			alert("Invalid Fields\n------------------------------------\n"+strError);		
				
		else {
			dm.method="Post";
			dm.action = pg;
			dm.submit();		
	}
}



function WinOpenAddress(){
 window.open(WinOpenAddress.arguments[0],"win1","toolbar=no,directories=no,menubar=no,location=no,help=no,scrollbars=yes,width=900,height=600,resizable=yes");
}

function WinOpenEvent(){
 window.open(WinOpenEvent.arguments[0],"win1","toolbar=no,directories=no,menubar=no,location=no,help=no,scrollbars=yes,width=600,height=290,resizable=yes");
}

function WinOpenEventForAffiliate(){
 window.open(WinOpenEventForAffiliate.arguments[0],"win1","toolbar=no,directories=no,menubar=no,location=no,help=no,scrollbars=yes,width=600,height=140,resizable=yes");
}

function WinOpenGuestBook(){
window.open(WinOpenGuestBook.arguments[0],"win1",'width=800 height=600 toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1')
}


function showBigImage(t){
	var stxt = "";
	
	stxt += "<html><head><title>Image viewer</title></head><body>";
	stxt += "<table border=0 cellpadding=0 cellspacing=0>";
	stxt += "<tr><td>";
	stxt += "<img src='"+ t +"'>";
	stxt += "</td></tr><tr><td align=center><br><a href=javascript:window.close();><font size=2 face=arial color=blue>Close Window</font></a></td></tr></table>";
	
	var win = window.open("","img","width=550,height=460,top=100,resizable=yes,scrollbars=yes")
	win.document.write(stxt);
	
}




function updateQuantityKeypress(dm,pg){
	if(event.keyCode=="13")
		UpdateQuantity(dm,pg)
}

