function isEMail(s)
	{
		if(((s.indexOf("@"))==-1) || ((s.indexOf("."))==-1))
		{
			return true ;  
		}else{
			var x=s;
			var ctr=0;
			var dot=0;
			for(j=0;j<x.length;j++)
			{
				if(x.charAt(j)=="@"){
					ctr++;
				}
				if(x.charAt(j)=="."){
					dot++;
				}
			}
			if(ctr!=1){
				return true;
			}else{
				return false;
			}
		}
	}
function valid_phone_format(phone_num){

var re= /\D/;
// test for this format: (xxx)xxx-xxxx
var re2 = /^\({1}\d{3}\)\d{3}-\d{4}/; 
// test for this format: xxx-xxx-xxxx
//var re2 = /^\d{3}-\d{3}-\d{4}/;

//for (i=0; i<nums.length;i++){
var num=phone_num;
//alert(num);alert(num.length);
var newNum;
 if (num != "" && re2.test(num)!=true){
   if (num != ""){
     while (re.test(num)){
     num = num.replace(re,"");
     }
   }
	//alert(num.length);   
  if (num.length != 10){
    return false
      }
   else {
     // for format (xxx)xxx-xxxx
     newNum = '(' + num.substring(0,3) + ')' + num.substring(3,6) + '-' + num.substring(6,10);
	 //alert("rajesh");
	 //alert (newNum);
     // for format xxx-xxx-xxxx
     // newNum = num.substring(0,3) + '-' + num.substring(3,6) + '-' + num.substring(6,10);
     return newNum;
     }
   }
   else{
   return num;
   }
 // }
}
  
	function isValidEmail(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^a-zA-Z0-9_@.-]");
		//myRe=/[`~\#\$\{\}\;\:\"@,.|></]/;
		myArr=myRe.test(s);
		if(myArr){ 
			return myArr
		}else{
			if(s.length<=3){
				return true;
			}
			ch=isEMail(s)
			if(ch){
				return true;
			}else{
				return false;
			}
		}
	}
	function isAlphaNumeric(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^a-zA-Z0-9_]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isCharacter(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^a-zA-Z]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isNumeric(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^0-9]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isZip(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^0-9a-zA-Z]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isPhone(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^0-9/-/(/)]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isPhone_new(string) {
	if (string.search(/^([0-9]){3}-[0-9]{3}-[0-9]{4}$/) != -1)
		return true;
	else
		return false;
}
function isPhone1(string) {
	if (string.search(/^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$/) != -1)
		return true;
	else
		return false;
}
	function checkAddress(s)
	{
		var x=s;
		for(j=0;j<x.length;j++)
		{ 
			var char_code= x.charCodeAt(j);
			if(char_code==32 || (char_code>=65 && char_code<=90) || (char_code>=97 && char_code<=122) || (char_code>=48 && char_code<=57) || char_code==44 || char_code==45 ||char_code==46 || char_code==47 || char_code==35 || char_code==33 ||char_code==63 ||char_code==61 || char_code==10 || char_code==13 || char_code==39 || char_code==34)
			{
			}else{
				return true;
				break;
			}		
		}
	}
	function isCharwithSpc(s)
	{
		var x=s;
		for(j=0;j<x.length;j++)
		{ 
			var char_code= x.charCodeAt(j);
			if(char_code==32 || (char_code>=65 && char_code<=90) || (char_code>=97 && char_code<=122) || (char_code>=48 && char_code<=58) || char_code==46 || char_code==63 || char_code==33 || char_code==39  || char_code==44)
			{
			}else{
				return true;
				break;
			}		
		}
	}
	function isCity(s)
	{
		var x=s;
		for(j=0;j<x.length;j++)
		{ 
			var char_code= x.charCodeAt(j);
			if(char_code==32 || (char_code>=65 && char_code<=90) || (char_code>=97 && char_code<=122))
			{
			}else{
				return true;
				break;
			}		
		}
	}



function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}


function isPhoneOk(input)
{
   var phonePattern = /\d{3}\-\d{3}\-\d{4}/;
   var match1; 
   if ((match1 = phonePattern.exec(input))) 
   {
		return true ;
   }
   else 
   {
    //alert('Phone field should be in xxx-xxx-xxxx format'); 
	 return false ;
   }
} 

function validateZIP(field)
{
	var valid = "0123456789-";
	var hyphencount = 0;
	if (field.length!=5 && field.length!=6 && field.length!=7 && field.length!=10) {
		visitor =  "- Please enter valid zip code.\n";
		return visitor;
	}
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == "-") hyphencount++;
		if (valid.indexOf(temp) == "-1") {
			visitor =  "- Invalid characters in your zip code.  Please try again.";
			return visitor;
		}
		if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
			visitor =  "- The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.";
			return visitor;
	   }
	}
	return '';
}

function bookmark(bookmarkurl,bookmarktitle)
{
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable,menubar=no,resizable=yes'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

var timerID ;

function tzone(tz, os, ds, cl)
{
	this.ct = new Date(0) ;		// datetime
	this.tz = tz ;		// code
	this.os = os ;		// GMT offset
	this.ds = ds ;		// has daylight savings
	this.cl = cl ;		// font color
}

function UpdateClocks()
{
	// www.timeanddate.com/worldclock
	var ct = new Array(
		new tzone('NYC: ', -5, 1, '#FFAA00'),
		new tzone('LON: ',  0, 1, 'silver')
	) ;
	var dt = new Date() ;	// [GMT] time according to machine clock
	var startDST = new Date(dt.getFullYear(), 3, 1) ;
	while (startDST.getDay() != 0)
		startDST.setDate(startDST.getDate() + 1) ;

	var endDST = new Date(dt.getFullYear(), 9, 31) ;
	while (endDST.getDay() != 0)
		endDST.setDate(endDST.getDate() - 1) ;

	var ds_active ;		// DS currently active
	if (startDST < dt && dt < endDST)
		ds_active = 1 ;
	else
		ds_active = 0 ;

	// Adjust each clock offset if that clock has DS and in DS.
	for(n=0 ; n<ct.length ; n++)
		if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;

	// compensate time zones
	gmdt = new Date() ;
	for (n=0 ; n<ct.length ; n++)
		ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;
	document.all.Clock0.innerHTML = ct[0].tz + ClockString(ct[0].ct);
	document.all.Clock1.innerHTML = ct[1].tz + ClockString(ct[1].ct);

	timerID = window.setTimeout("UpdateClocks()", 1001) ;
}

function ClockString(dt)
{
	var stemp, ampm ;

	var dt_year = dt.getUTCFullYear() ;
	var dt_month = dt.getUTCMonth() + 1 ;
	var dt_day = dt.getUTCDate() ;
	var dt_hour = dt.getUTCHours() ;
	var dt_minute = dt.getUTCMinutes() ;
	var dt_second = dt.getUTCSeconds() ;

	dt_year = dt_year.toString() ;
	if (0 <= dt_hour && dt_hour < 12)
	{
		ampm = 'AM' ;
		if (dt_hour == 0) dt_hour = 12 ;
	} else {
		ampm = 'PM' ;
		dt_hour = dt_hour - 12 ;
		if (dt_hour == 0) dt_hour = 12 ;
	}

	if (dt_minute < 10)
		dt_minute = '0' + dt_minute ;

	if (dt_second < 10)
		dt_second = '0' + dt_second ;

	//stemp = dt_month + '/' + dt_day + '/' + dt_year.substr(2,2) ;
	stemp = dt_hour + ":" + dt_minute + ":" + dt_second + ' ' + ampm ;
	return stemp ;
}

function load_website()
{
	MM_preloadImages('images/view-hover.jpg');
	UpdateClocks();
}
