// JavaScript Document
function ValidateSuperSearchKeyword(control)
{
	if (document.getElementById(control).value.length < 0)
	{
		alert('Please enter a word larger than 3 characters.');
		return false;
	} 
	return true;
}

function AllValidCharacters(control)
{
	var myInvalidChars=new Array("select ", "script", "drop ", ";", "--", "insert ", "delete ", "xp_", "#", "%", "(", ")", "/", ":", ";", "<", ">", "=", "[", "]", "?", "`", "'", "|");
	for (i=0;i<myInvalidChars.length;i++)
	{
		if (document.getElementById(control).value.toLowerCase().indexOf(myInvalidChars[i]) > -1)
		{
		alert('You entered invalid characters.');
		return false;
		}
	}
	return true;
}

function popUpCenteredWindow(ref,w,h) {
	var iMyWidth;
	var iMyHeight;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/3) - (w/2 + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (window.screen.height/3) - (h/2 + 50); //half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(ref,"Window2","status,height="+h+",width="+w+",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
	win2.focus();
}




function alphanumeric(e) {
	
var k;
document.all ? k = e.keyCode : k = e.which;
/*if ((k > 64 && k < 91) || (k > 96 && k < 123) || (k > 47 && k < 58) || k == 8 || k == 32)*/
if ((k > 31 && k < 127))
{
return true;
}
else
{
alert("Please enter valid english letters.");
return false;
}
}

function numeric(e) {
	
var k;
document.all ? k = e.keyCode : k = e.which;
/*if ((k > 64 && k < 91) || (k > 96 && k < 123) || (k > 47 && k < 58) || k == 8 || k == 32)*/
if ((k > 47 && k < 58))
{
return true;
}
else
{
alert("Please enter a valid number.");
return false;
}
}

function CheckNumber(a)
{
	var x= a
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	
	if (!anum.test(x))
	{
		alert("Please enter a valid number.");
		return false;
	}
	else
	return true;
}

function ValidatePublicLogin(){
	var str="";
	var validemail=""
	if (document.form1.email.value=="")
		str+="Email address is required\n"
	else{
		validemail= IsValidEmail(document.form1.email)
		if (validemail==false)
			str+="Invalid email address\n"
		}
	if (document.form1.password.value=="")
		str+="Password is required\n"
	if (str==""){
		document.form1.submit();
		return true;}
	else{
		alert(str);
		return false;
		}
	}
	
//validate Email
function IsValidEmail(txt){
    var stremail="";
	if(txt.value !=""){ 
		var goodEmail = txt.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (goodEmail){
		    return true;
		} else {
			return false;
		}
	}
}


var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}


function toggleImageSign(control1,control2,control3)
{
	var str = document.getElementById(control1).src;
	if (str.indexOf('plus.gif') > 0)
	{
		document.getElementById(control1).src = 'images/categorybarminus.gif';
		document.getElementById(control2).src = 'images/categorybarplus.gif';
		document.getElementById(control3).src = 'images/categorybarplus.gif';
	}
	else
	if (str.indexOf('minus.gif') > 0)
	{
		document.getElementById(control1).src = 'images/categorybarplus.gif';
	}
}

function toggleWord(control1,control2)
{
	var str = document.getElementById(control1).innerHTML;
	if (str.indexOf('Collapse') == 0)
	{
		document.getElementById(control1).innerHTML = 'Expand';
		document.getElementById(control2).src = 'images/categorybarplus.gif';
	}
	else
	if (str.indexOf('Expand') == 0)
	{
		document.getElementById(control1).innerHTML = 'Collapse';
		document.getElementById(control2).src = 'images/categorybarminus.gif';
	}
}

function ValidateTestimonialForm(){
	var str="";
	if (document.form1.name.value=="")
		str+="Name is required\n"
	if (document.form1.country.value=="")
		str+="Country is required\n"
	if (document.form1.message.value=="")
		str+="Message is required\n"
	if (str==""){
		document.form1.submit();
		return true;}
	else{
		alert(str);
		return false;
		}
	}

