function isValidEmail( fieldValue ) {
	if ( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(fieldValue) )
		return true;
	
	return false;
}

function isValidURL(url) {

	if ( url == null )
		return false;

// space extr
	var reg='^ *';
//protocol	
	reg = reg+'(?:([Hh][Tt][Tt][Pp](?:[Ss]?))(?:\:\\/\\/))?';
//usrpwd	
	reg = reg+'(?:(\\w+\\:\\w+)(?:\\@))?';
//domain
	reg = reg+'([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|localhost|([Ww][Ww][Ww].|[a-zA-Z0-9].)[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,6})';
//port
	reg = reg+'(\\:\\d+)?';
//path
	reg = reg+'((?:\\/.*)*\\/?)?';
//filename
	reg = reg+'(.*?\\.(\\w{2,4}))?';
//qrystr
	reg = reg+'(\\?(?:[^\\#\\?]+)*)?';
//bkmrk
	reg = reg+'(\\#.*)?';
// space extr
	reg = reg+' *$';

	return url.match(reg);
}

// returns true if checkStr contains only characters specified in checkOK
// probably can be replaced with a more efficient regular expression

function isValidString( checkStr, checkOK ) {

	if ( !checkOK )
		var checkOK = '';

	var allValid = true;

	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
	}
	
	return allValid;
}

var alphabeticChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var numericChars = "0123456789";

function isNumeric ( fieldValue ) {
	if ( /[0-9]/.test ( fieldValue ) )
		return true;
	return false;
}

function isNumeric( val, addChars ) {
	return isValidString( val, numericChars + addChars );
}

function isAlphabetic( val ) {
	if ( /[A-Za-z]/.test ( val ) )
		return true;
	return false;
}

function isAlphabetic( val, addChars ) {
	return isValidString( val, alphabeticChars + addChars );
}

function isAlphaNumeric( val ) {
	if ( /\w/.test ( val ) )
		return true;
	return false;
}

function isAlphaNumeric( val, addChars ) {
	return isValidString( val, alphabeticChars + numericChars + addChars );
}

function DispDispHide ( disp1, disp2, hide )
{
    if (hide) hide.style.display = 'none';
    if (disp1) disp1.style.display = 'inline';
    if (disp2) disp2.style.display = 'inline';
}

function DispHideHide ( disp, hide1, hide2 )
{
    if (hide1) hide1.style.display = 'none';
    if (hide2) hide2.style.display = 'none';
    if (disp) disp.style.display = 'inline';
}

function showHide( paramA, paramB)
{
	if (paramA.value == 'US')
		paramB.style.display ='inline';
	else
		paramB.style.display = 'none';
}

function openWin(id)
{
		openpopup=window.open('viewresult.php?pollid=' + id ,'','width=550,height=378,left=101,top=1,resizable=no,scrollbars=yes,status=no');
		openpopup.opener.name='abc';
}


function launchTellFriend ()
{
	var left = (screen.width/2) - 500/2;
	var top = (screen.height/2) - 500/2;
    var win = "width=450,height=200,left=" + left + ",top=" + top + ",copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
    window.open("tellfriend.php",'tellfriend',win);
}

function launchTellFriendProfile ( sID )
{
	var left = (screen.width/2) - 300/2;
	var top = (screen.height/2) - 300/2;
    var win = "width=300,height=300,left=" + left + ",top=" + top + ",copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
    window.open("tellfriend.php?ID="+sID,'tellfriendprofile',win);
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=yes,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function popUpWindow(URLStr, align, width, height)
{
	if(popUpWin){
	
		if(!popUpWin.closed) popUpWin.close();
	}

	if( align == 'center' ){
	
		var left = (screen.width/2) - width/2;
		var top = (screen.height/2) - height/2;
	}else{
	
		var left = 0;
		var top = 0;	
	}
	
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

