var xmlHttp

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}
function valForm(form) {
	var btn = valButton(document.favForm.group1);
	if (btn == null) alert('No radio button selected');
	else alert('Button value ' + btn + ' selected');
}


function showUser(str)
{ 
	var val1 = document.newsletterForm.s.value;
	var emailID=document.newsletterForm.s;
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	} else {
		document.getElementById("txtHint").innerHTML="Please wait updating...";
		//alert(val2);
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }
		var url="newsletter.php"
		url=url+"?vq="+val1
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}
function updateComment(str)
{ 
	var cmt_val = document.commentform.comment.value;
	//alert(val2);
	if(cmt_val == "") {
		alert("Please enter your comment.");
		document.commentform.comment.focus();
	} else {
		document.getElementById("txtHintX").innerHTML="Please wait updating...";
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }
		var url="comment_update.php"
		url=url+"?vq="+cmt_val
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=stateChangedX 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}
function favoriteUpdate(str)
{ 
	//var cmt_val = document.v_rateIt.comment.value;
	var btn = valButton(document.favForm.group1);
	if (btn == null) {
		alert('No radio button selected');
	} else {
	
		//alert('Button value ' + btn + ' selected');
		//alert(val2);
		document.getElementById("favDiv").innerHTML="Please wait updating...";
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }
		var url="favorite.php"
		url=url+"?vq="+btn
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=stateChangedY
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}
function stateChangedX() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 document.getElementById("txtHintX").innerHTML=xmlHttp.responseText
	 document.getElementById("cmtForm").style.display ="none";
	 } 
}
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
	 document.getElementById("newslet").style.display ="none";
	 } 
}
function stateChangedY() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 document.getElementById("favDiv").innerHTML=xmlHttp.responseText
	 document.getElementById("favoriteForm").style.display ="none";
	 } 
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	 {
		 //Firefox, Opera 8.0+, Safari
	 	xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}
function showStar(theVal) {
	if(theVal != 0)
		document.getElementById("starImg").src = "rate/"+theVal+"star.gif";
	else 
		document.getElementById("starImg").src = "rate/00star.gif";
}
function ToggleDiv() {
	var objDiv = document.getElementById("commentForm");
	if(objDiv.style.display == "") {
		objDiv.style.display = "none";
	} else {
		objDiv.style.display = "";
	}
}
function starStatus(sid) {
	var starDiv = document.getElementById("starDiv");
	if(sid == "1") { 
		starDiv.innerHTML = "<ul class='star-rating'><li><a href='#' title='1 star out of 5' class='one-star' style='background: url(images/alt_star.png) left center;' >2</a></li><li><a href='#' title='2 stars out of 5' >2</a></li><li><a href='#' title='3 stars out of 5' >2</a></li><li><a href='#' title='4 stars out of 5' >2</a></li><li><a href='#' title='5 stars out of 5' >2</a></li></ul>"; 
	}
	if(sid == "2") { 
		starDiv.innerHTML = "<ul class='star-rating'><li><a href='#' title='1 star out of 5' class='one-star' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='2 stars out of 5' class='two-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='3 stars out of 5' >2</a></li><li><a href='#' title='4 stars out of 5' >2</a></li><li><a href='#' title='5 stars out of 5' >2</a></li></ul>";
	}
	if(sid == "3") { 
		starDiv.innerHTML = "<ul class='star-rating'><li><a href='#' title='1 star out of 5' class='one-star' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='2 stars out of 5' class='two-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='3 stars out of 5' class='three-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='4 stars out of 5' >2</a></li><li><a href='#' title='5 stars out of 5' >2</a></li></ul>";
	}
	if(sid == "4") { 
		starDiv.innerHTML = "<ul class='star-rating'><li><a href='#' title='1 star out of 5' class='one-star' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='2 stars out of 5' class='two-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='3 stars out of 5' class='three-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='4 stars out of 5' class='four-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='5 stars out of 5' >2</a></li></ul>";
	}
	if(sid == "5") { 
		starDiv.innerHTML = "<ul class='star-rating'><li><a href='#' title='1 star out of 5' class='one-star' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='2 stars out of 5' class='two-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='3 stars out of 5' class='three-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='4 stars out of 5' class='four-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li><li><a href='#' title='5 stars out of 5' class='five-stars' style='background: url(images/alt_star.png) left bottom;' >2</a></li></ul>"; 
	}
	
}