// JavaScript Document
function emailCheck(emailStr, errormessage)
{
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=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) 
	{
		alert(errormessage);
		return false;
	}
	
	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) 
	{
		if (user.charCodeAt(i)>127) 
		{
			alert(errormessage);
			return false;
		}
	}
	for (i=0; i<domain.length; i++) 
	{
		if (domain.charCodeAt(i)>127) 
		{
			alert(errormessage);
			return false;
   		}
	}

	if (user.match(userPat)==null) 
	{
		alert(errormessage);
		return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++) 
		{
			if (IPArray[i]>255) 
			{
				alert(errormessage);
				return false;
   			}
		}
		return true;
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) 
	{
		if (domArr[i].search(atomPat)==-1) 
		{
			alert(errormessage);
			return false;
	   	}
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
	{
		alert(errormessage);
		return false;
	}

	if (len<2) 
	{
		alert(errormessage);
		return false;
	}

	return true;
}
//--------------------------time zone
	function updateclock(z)
	{
		zone=z.options[z.selectedIndex].value;
		isitlocal=(z.options[0].selected)?true:false;
		if (zone == "") isitlocal=true;
	}

	function WorldClock()
	{
		fullmonth = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
		
		now=new Date();

		ofst=now.getTimezoneOffset()/60;
		secs=now.getSeconds();
		mins=now.getMinutes();
		hrs =now.getHours();
		if (parseInt(zone))
		{
			ofsetmins = (now.getTimezoneOffset()) + (zone * 60);
			totalminutes = ((hrs * 60) + mins);
			
			totalminute = (totalminutes + ofsetmins);
			if (totalminute < 0)
			{
				now.setDate(now.getDate()-1)
				month = now.getMonth();
				day = now.getDate();
				year = now.getFullYear();
			}
		}
		month = now.getMonth();
		day = now.getDate();
		year = now.getFullYear();

		
		newhr=(isitlocal)?now.getHours():(now.getHours() + parseFloat(ofst)) + parseFloat(zone);
		hr = parseInt(newhr);
		addmin = parseInt(parseFloat(newhr - hr) * 60);
		mins = (mins + addmin);
		if (mins < 0)
		{
			mins = (60 + mins);
		}
		if (mins > 59)
		{
			hr = (hr + 1);
			mins = (mins - 60);
			if (hr > 24)
			{
				now.setDate(now.getDate()+1)
				month = now.getMonth();
				day = now.getDate();
				year = now.getFullYear();
			}
		}
		
		if (hr < 0) hr+=24;
		if (hr > 23) hr-=24;
		ampm = (hr > 11)?"PM":"AM";
		statusampm = ampm.toLowerCase();

		hr2 = hr;
		if (hr2 == 0) hr2=12;
		(hr2 < 13)?hr2:hr2 %= 12;
		if (hr2<10) hr2="0"+hr2

		var finaltime=fullmonth[month]+'-'+day+'-'+year+' '+hr2+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs)+' '+statusampm;
		if (document.all) 
		{
			worldclock.innerHTML=finaltime
		}
		else if (document.getElementById) 
		{
			document.getElementById("worldclock").innerHTML=finaltime
		}
		setTimeout('WorldClock()',1000);
	}
	
	function CityClock(offset)
	{
		zone = offset;
		fullmonth = new Array("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
		
		now=new Date();

		ofst=now.getTimezoneOffset()/60;
		secs=now.getSeconds();
		mins=now.getMinutes();
		hrs =now.getHours();
		if (parseInt(zone))
		{
			ofsetmins = (now.getTimezoneOffset()) + (zone * 60);
			totalminutes = ((hrs * 60) + mins);
			
			totalminute = (totalminutes + ofsetmins);
			if (totalminute < 0)
			{
				now.setDate(now.getDate()-1)
				month = now.getMonth();
				day = now.getDate();
				year = now.getFullYear();
			}
		}
		month = now.getMonth();
		day = now.getDate();
		year = now.getFullYear();

		
		newhr= (now.getHours() + parseFloat(ofst)) + parseFloat(zone);
		hr = parseInt(newhr);
		addmin = parseInt(parseFloat(newhr - hr) * 60);
		mins = (mins + addmin);
		if (mins < 0)
		{
			mins = (60 + mins);
		}
		if (mins > 59)
		{
			hr = (hr + 1);
			mins = (mins - 60);
			if (hr > 24)
			{
				now.setDate(now.getDate()+1)
				month = now.getMonth();
				day = now.getDate();
				year = now.getFullYear();
			}
		}
		
		if (hr < 0) hr+=24;
		if (hr > 23) hr-=24;
		ampm = (hr > 11)?"PM":"AM";
		statusampm = ampm.toLowerCase();

		hr2 = hr;
		if (hr2 == 0) hr2=12;
		(hr2 < 13)?hr2:hr2 %= 12;
		if (hr2<10) hr2="0"+hr2

		var finaltime=fullmonth[month]+'-'+day+'-'+year+' '+hr2+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs)+' '+statusampm;
		document.write(finaltime);
	}