var dropM;
var popupInt = 0;
var popupInt2 = 0;
//Function to find X Y cordinates=======
function findPosX(obj){
	var curleft = 0;
	if(obj.offsetParent)
		while(1) 
		{
		  curleft += obj.offsetLeft;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj){
	var curtop = 0;
	if(obj.offsetParent)
		while(1)
		{
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}
function showDrop(curTD){
	clearInterval(popupInt);
	dropM = curTD;
	//curTD.parentNode.style.backgroundColor = "#ffffff";
	curTD.style.color = "#da251c";
	var popupDiv = document.getElementById("submenuDiv");
	popupDiv.style.display="block";
	tmpPos=findPosX(curTD)-1.5;
	popupDiv.style.left=tmpPos + "px";
	tmpPos=findPosY(curTD)+17;
	popupDiv.style.top=tmpPos + "px";
	var dropArr = document.getElementById("ulipLink");
	dropArr.style.backgroundImage = "url(images/dropArrowRed.gif)";
}
function hideDrop(){
	clearInterval(popupInt);
	curPopUp=document.getElementById("submenuDiv");
	curPopUp.style.display="none";
	dropM.parentNode.style.backgroundColor = "transparent";
	dropM.style.color = "#ffffff";
	var dropArr = document.getElementById("ulipLink");
	dropArr.style.backgroundImage = "url(images/dropArrow.gif)";
}
function hideDropStart(){
	clearInterval(popupInt);
	popupInt = setInterval(hideDrop, 700);
}
function clearInt(){
	clearInterval(popupInt);
	clearInterval(popupInt2);
}


//Comment Form Validation
function commentValid()
{
	if(document.commentForm.author.value == "")
	{
		document.getElementById('name_alert').style.display= 'block';
		document.getElementById('author').style.marginBottom='2px';
		document.commentForm.author.focus();
		return false;
	}
	else
	{
		document.getElementById('name_alert').style.display= 'none';
		document.getElementById('author').style.marginBottom='8px';
		}
	var regex = /^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/;
	var email = document.commentForm.email.value;
	 if(regex.test(email) == false)
	{
		document.getElementById('email_alert').style.display= 'block';
		document.getElementById('email').style.marginBottom='2px';
		document.commentForm.email.focus();
		return false;
	}
	else
	{
		document.getElementById('email_alert').style.display= 'none';
		document.getElementById('email').style.marginBottom='8px';
		}
	if(document.commentForm.text.value == "" )
	{
		document.getElementById('comment_alert').style.display= 'block';
		document.getElementById('text').style.marginBottom='2px';
        document.commentForm.text.focus();
        return false;
	}
	else
	{
		document.getElementById('comment_alert').style.display= 'none';
		document.getElementById('text').style.marginBottom='8px';
		}
	return true;
}
//Suggest Form Validation
function suggestValid()
{
	
	name=document.suggestform.name.value; 
	topic=document.suggestform.Topic.value; 
	if(document.suggestform.name.value == "")
	{
		document.getElementById('name_alert').style.display= 'block';
		document.getElementById('name').style.marginBottom='2px';
		document.suggestform.name.focus();
		return false;
	}
	else
	{
		document.getElementById('name_alert').style.display= 'none';
		document.getElementById('name').style.marginBottom='8px';
		}
	var regex = /^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/;
	var email = document.suggestform.email.value;
	 if(regex.test(email) == false)
	{
		document.getElementById('email_alert').style.display= 'block';
		document.getElementById('email').style.marginBottom='2px';
		document.suggestform.email.focus();
		return false;
	}
	else
	{
		document.getElementById('email_alert').style.display= 'none';
		document.getElementById('email').style.marginBottom='8px';
		}
	var numb = /[0-9]/;
	var mobile = document.suggestform.phone.value;
	 if(numb.test(mobile) == false || mobile == "")
	{
		document.getElementById('phone_alert').style.display= 'block';
		document.getElementById('phone').style.marginBottom='2px';
		document.suggestform.phone.focus();
		return false;
	}
	else
	{
		document.getElementById('phone_alert').style.display= 'none';
		document.getElementById('phone').style.marginBottom='2px';
		}


	return true;
}
//Question Form Validation
function qaValid()
{
	if(document.qaform.name.value == "")
	{
		document.getElementById('name_alert').style.display= 'block';
		document.getElementById('name').style.marginBottom='2px';
		document.qaform.name.focus();
		return false;
	}
	else
	{
		document.getElementById('name_alert').style.display= 'none';
		document.getElementById('name').style.marginBottom='8px';
		}
	var regex = /^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/;
	var email = document.qaform.email.value;
	 if(regex.test(email) == false)
	{
		document.getElementById('email_alert').style.display= 'block';
		document.getElementById('email').style.marginBottom='2px';
		document.qaform.email.focus();
		return false;
	}
	else
	{
		document.getElementById('email_alert').style.display= 'none';
		document.getElementById('email').style.marginBottom='8px';
		}
	var numb = /[0-9]/;
	var mobile = document.qaform.phone.value;
	 if(numb.test(mobile) == false || mobile == "")
	{
		document.getElementById('phone_alert').style.display= 'block';
		document.getElementById('phone').style.marginBottom='2px';
		document.qaform.phone.focus();
		return false;
	}
	else
	{
		document.getElementById('phone_alert').style.display= 'none';
		document.getElementById('phone').style.marginBottom='2px';
		}
	return true;
}
//Weekly Quiz Validation
function weeklyqValid()
{
	if((document.weeklyquiz.option.value != "A") || (document.weeklyquiz.option.value != "B") || (document.weeklyquiz.option.value != "C"))
	{
		document.getElementById('option_alert').style.display= 'block';
		document.getElementById('option').style.marginBottom='2px';
		return false;
	}
	else
	{
		document.getElementById('option_alert').style.display= 'none';
		document.getElementById('option').style.marginBottom='8px';
		}
	return true;
}
//Subscription Validation
function subemailValid()
{
	var regex = /^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/;
	var email = document.subform.email.value;
	 if(regex.test(email) == false || email == "Your Email")
	{
		document.getElementById('subemail_alert').style.display= 'block';
		document.getElementById('email').style.marginBottom='2px';
		document.subform.email.focus();
		return false;
	}
	else
	{
		document.getElementById('subemail_alert').style.display= 'none';
		document.getElementById('email').style.marginBottom='8px';
		}
	return true;
}

