function hideUnhideMenu(){
	if(document.getElementById('sliding_menu').style.display == "none"){
		document.getElementById('sliding_menu').style.display = "block";
		document.getElementById('hide_unhide_image').src = 'images/hide.jpg';
		document.getElementById('hide_unhide_menu_panel').style.background = 'azure';
		document.cookie = "menuStatus=block";
	}
	else{
		document.getElementById('sliding_menu').style.display = "none";
		document.getElementById('hide_unhide_image').src = 'images/unhide.jpg';
		document.getElementById('hide_unhide_menu_panel').style.background = 'azure';
		document.cookie = "menuStatus=none";
	}
}

function display_menu(container) {
	if(document.getElementById(container).style.visibility=="hidden")
		document.getElementById(container).style.visibility = "visible";
	else
		document.getElementById(container).style.visibility = "hidden";
}

function display_menu_hide_show(container) {
	if(document.getElementById(container).style.display=="none")
		document.getElementById(container).style.display = "block";
	else
		document.getElementById(container).style.display = "none";
}

function hide_menu(container) {
	document.getElementById(container).style.visibility = "hidden";
}


function getSecurityCode(divName) {
	xmlHttp=GetXmlHttpObject();
	var url="ajaxPages/getCaptchaImage.php";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=getImage;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getImage() {
	if (xmlHttp.readyState==4) { 
		document.getElementById("securityCode").innerHTML=xmlHttp.responseText;
	}
	else {
		document.getElementById("securityCode").innerHTML="Loading Image ...";
	}
}

function toggleToInputBox(optionId,divId) {
	if(optionId == 7) {
		document.getElementById(divId).style.display = 'block';
		return;
	}
	document.getElementById(divId).style.display = 'none';
}

function textBox_onFocus(element,text) {
	if(element.value == text) {
		element.value = "";
	}
}

function textBox_onBlur(element,text) {
	if(element.value == "") {
		element.value = text;
	}
}

function checkPaginationForm() {
	if(document.paginationForm.page.value>0 && document.paginationForm.page.value<=document.paginationForm.maxPage.value) {
		return true;
	}
	else {
		alert("Please insert a value between 1 to " + document.paginationForm.maxPage.value);
		return true;
	}
}

function toggleImageMaxMin(divName) {
	if(document.getElementById(divName).src.indexOf("plus")>=0)
		document.getElementById(divName).src = "images/minus.gif";
	else
		document.getElementById(divName).src = "images/plus.gif";
}

function genericConfirm(message) {
	return confirm(message);
}

function validateInviteForm() {
	//var Regex = new RegExp("^([a-zA-Z0-9])+(.[a-zA-Z0-9_])*@([a-zA-Z0-9-_])+.[A-Za-z]{2,4}(.[A-Za-z]{2,4})*$");
	var Regex = new RegExp("^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)$");
	if(document.inviteForm.email.value.length<=4 || document.inviteForm.email.value.length>100) {
		alert("Email address should be between 4 to 100 characters.");
		return false;
	}
	 else if(!Regex.test(document.inviteForm.email.value)) {
		alert("Invalid format of email address.");
		return false;
	}
	else if(document.inviteForm.firstname.value.length<1 || document.inviteForm.firstname.value.length>100) {
		alert("First name should be between 1 to 100 characters.");
		return false;
	}
	else {
		xmlHttp = GetXmlHttpObject();
		url = "ajaxPages/InviteFriends.php?sid=" + Math.random()+
		"&username=" + document.inviteForm.email.value +
		"&firstname=" + document.inviteForm.firstname.value + 
		"&lastname=" + document.inviteForm.lastname.value;
		xmlHttp.onreadystatechange = invitingFrnd;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function invitingFrnd() {
	if (xmlHttp.readyState == 4) {
		document.getElementById('inviteFrndStatus').innerHTML = xmlHttp.responseText;
	} else {
		document.getElementById('inviteFrndStatus').innerHTML = "<table align='center'><tr><td style='font-family: verdana;font-size: 11;font-weight: bold;color: blue'><img src='images/loading.gif'/></td></tr><tr><td align='center' style='font-weight: bold;font-size: 12;color: black;font-family: arial'>Sending, Please Wait ...</td></tr></table>";
	}
}

function forwardRequest(fieldName,value) {
	str = window.location+"";
	if(str.indexOf("&"+fieldName)!=-1) {
		str = str.substr(0,str.indexOf(fieldName)-1);
		window.location = str + "&"+fieldName+"=" + value;
	}
	else if(str.indexOf("?"+fieldName)!=-1) {
		str = str.substr(0,str.indexOf(fieldName));
		window.location = str + fieldName + "=" + value;
	}
	else if(str.indexOf('?')==-1)
		window.location = str + "?"+fieldName+"=" + value;
	else
		window.location = str + "&"+fieldName+"=" + value;
}