function searchinput(str){
	var txtfind = "Thanks";
   if (str.search(txtfind) != -1)
       var midstring = true;
   else
       var midstring = false;
	return midstring;
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}
function MM_openBrWindow(theURL,winName,features) 
{ 
	//v2.0
	window.open(theURL,winName,features);
}


function forward(divid)
{
	if(lastdiv=="")
	{
		document.getElementById(divid).innerHTML=frmdataforward;
		document.getElementById(divid).style.display='block';
		lastdiv=divid;
	}
	else
	{
		document.getElementById(lastdiv).innerHTML='';
		document.getElementById(lastdiv).style.display='none';
		document.getElementById(divid).innerHTML=frmdataforward;
		document.getElementById(divid).style.display='block';
		lastdiv=divid;
	}
}



function abuse(divid,commentid)
{
	if(lastdiv=="")
	{

		document.getElementById(divid).innerHTML=frmdataabuse;
		document.getElementById(divid).style.display='block';
		document.frmcommentabuse.commentid.value=commentid;
		lastdiv=divid;
	}
	else
	{
		document.getElementById(lastdiv).innerHTML='';
		document.getElementById(lastdiv).style.display='none';
		document.getElementById(divid).innerHTML=frmdataabuse;
		document.getElementById(divid).style.display='block';
		document.frmcommentabuse.commentid.value=commentid;
		lastdiv=divid;
	}
}


// Following function show and hide submit comment form.

function con(divid,parent)
{
	if(lastdiv=="")
	{

		document.getElementById(divid).innerHTML=frmdata;
		document.getElementById(divid).style.display='block';
		document.frmcomment.parent.value=parent;
		lastdiv=divid;
	}
	else
	{
		document.getElementById(lastdiv).innerHTML='';
		document.getElementById(lastdiv).style.display='none';
		document.getElementById(divid).innerHTML=frmdata;
		document.getElementById(divid).style.display='block';
		document.frmcomment.parent.value=parent;
		lastdiv=divid;
	}
}

var flag;
var imgpath='http://172.16.24.10/~dhiraj/frontend/www/static/fe/images';
function selectStarts(num)
{
flag=1;	

	if(num==1)
	{
		document.image1.src=imgpath+'/star_over.gif';
		document.image2.src=imgpath+'/star.gif';
		document.image3.src=imgpath+'/star.gif';
		document.image4.src=imgpath+'/star.gif';
		document.image5.src=imgpath+'/star.gif';
		document.image6.src=imgpath+'/star.gif';
		document.image7.src=imgpath+'/star.gif';
		document.image8.src=imgpath+'/star.gif';
	}
	if(num==2)
	{
		document.image1.src=imgpath+'/star_over.gif';
		document.image2.src=imgpath+'/star_over.gif';
		document.image3.src=imgpath+'/star.gif';
		document.image4.src=imgpath+'/star.gif';
		document.image5.src=imgpath+'/star.gif';
		document.image6.src=imgpath+'/star.gif';
		document.image7.src=imgpath+'/star.gif';
		document.image8.src=imgpath+'/star.gif';

	}
	if(num==3)
	{
		document.image1.src=imgpath+'/star_over.gif';
		document.image2.src=imgpath+'/star_over.gif';
		document.image3.src=imgpath+'/star_over.gif';
		document.image4.src=imgpath+'/star.gif';
		document.image5.src=imgpath+'/star.gif';
		document.image6.src=imgpath+'/star.gif';;
		document.image7.src=imgpath+'/star.gif';
		document.image8.src=imgpath+'/star.gif';
	}
	if(num==4)
	{
		document.image1.src=imgpath+'/star_over.gif';
		document.image2.src=imgpath+'/star_over.gif';
		document.image3.src=imgpath+'/star_over.gif';
		document.image4.src=imgpath+'/star_over.gif';
		document.image5.src=imgpath+'/star.gif';
		document.image6.src=imgpath+'/star.gif';
		document.image7.src=imgpath+'/star.gif';
		document.image8.src=imgpath+'/star.gif';
	}
	if(num==5)
	{
		document.image1.src=imgpath+'/star_over.gif';
		document.image2.src=imgpath+'/star_over.gif';
		document.image3.src=imgpath+'/star_over.gif';
		document.image4.src=imgpath+'/star_over.gif';
		document.image5.src=imgpath+'/star_over.gif';
		document.image6.src=imgpath+'/star.gif';
		document.image7.src=imgpath+'/star.gif';
		document.image8.src=imgpath+'/star.gif';
	}
	if(num==6)
	{
		document.image1.src=imgpath+'/star_over.gif';
		document.image2.src=imgpath+'/star_over.gif';
		document.image3.src=imgpath+'/star_over.gif';
		document.image4.src=imgpath+'/star_over.gif';
		document.image5.src=imgpath+'/star_over.gif';
		document.image6.src=imgpath+'/star_over.gif';
		document.image7.src=imgpath+'/star.gif';
		document.image8.src=imgpath+'/star.gif';
	}
	if(num==7)
	{
		document.image1.src=imgpath+'/star_over.gif';
		document.image2.src=imgpath+'/star_over.gif';
		document.image3.src=imgpath+'/star_over.gif';
		document.image4.src=imgpath+'/star_over.gif';
		document.image5.src=imgpath+'/star_over.gif';
		document.image6.src=imgpath+'/star_over.gif';
		document.image7.src=imgpath+'/star_over.gif';
		document.image8.src=imgpath+'/star.gif';
	}
	if(num==8)
	{
		document.image1.src=imgpath+'/star_over.gif';
		document.image2.src=imgpath+'/star_over.gif';
		document.image3.src=imgpath+'/star_over.gif';
		document.image4.src=imgpath+'/star_over.gif';
		document.image5.src=imgpath+'/star_over.gif';
		document.image6.src=imgpath+'/star_over.gif';
		document.image7.src=imgpath+'/star_over.gif';
		document.image8.src=imgpath+'/star_over.gif';
	}
}

function Mout()
{
		document.image1.src=imgpath+'/star.gif';
		document.image2.src=imgpath+'/star.gif';
		document.image3.src=imgpath+'/star.gif';
		document.image4.src=imgpath+'/star.gif';
		document.image5.src=imgpath+'/star.gif';
		document.image6.src=imgpath+'/star.gif';
		document.image7.src=imgpath+'/star.gif';
		document.image8.src=imgpath+'/star.gif';
}

function setCookie123(val)
{
	if(getCookie("ratingdone-"+val))
	{
		return false;
	}
	else
	{
		document.cookie="ratingdone-"+val+"=yes";
		return true;
	}
}


function setVal(strURL,content_id)
{
	//alert('here');
	var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
	if(setCookie123(content_id) == false)
	{
		return;
	}
    if (window.XMLHttpRequest) 
	{
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
	{
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('GET', '/storyresources.php?flag=Rating&rating='+strURL+'&content_id='+content_id+'&website=screenstorypage', true);

	self.xmlHttpReq.onreadystatechange = function()
	{
        if (self.xmlHttpReq.readyState == 4)
		{    	
			updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(null);
}


function updatepage(str)
{
 document.getElementById("result").innerHTML = str;
}


function getCookie(name) 
{
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) {
	return null;
	}
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
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){
		   return false
		}
	
		
		if(str.indexOf(dot) == str.length -1){
			return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
}

function insertCommetMain(content_id)
{
    var xmlHttpReq1 = false;
    var self = this;
    var name=document.frmcommentmain.name.value
    var email=document.frmcommentmain.email.value
    var comment=document.frmcommentmain.comment.value
    var subject=document.frmcommentmain.subject.value
	var flag=true;
    var done=false;

    if(name=="")
    {
	document.getElementById("divnamemain").innerHTML = "<font face=verdana size=2 color=red>Name</font>";
	flag=false;
    }
    else
    {
    	document.getElementById("divnamemain").innerHTML = "Name";
    }


   if((email=="")||(echeck(email)==false))
    {
	document.getElementById("divemailmain").innerHTML = "<font face=verdana size=2 color=red>Email</font>";	
	flag=false;
    }
    else
    {
	document.getElementById("divemailmain").innerHTML = "Email";	
    }

    if(subject=="")
    {
	document.getElementById("divsubjectmain").innerHTML = "<font face=verdana size=2 color=red>Subject</font>";	
	flag=false;
    }
    else
    {
    	document.getElementById("divsubjectmain").innerHTML = "Subject";	
    }

    if(comment=="")
    {
	document.getElementById("divmessagemain").innerHTML = "<font face=verdana size=2 color=red>Message</font>";	
	flag=false;
    }
    else
    {
	document.getElementById("divmessagemain").innerHTML = "Message";	
    }

   if(!document.frmcommentmain.checkbox.checked)
   {
	 document.getElementById("comment_result_main").innerHTML = "<center><font face=verdana size=2 color=red>Please accept the terms of use.</font></center>";	
	 flag=false;
	 done=true;
   }

if(flag==true)
{
    if (window.XMLHttpRequest) 
    {
        self.xmlHttpReq1 = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
    {
        self.xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP");
    }

	self.xmlHttpReq1.open('GET', '/storyresources.php?flag=SubmitComment&name='+name+'&content_id='+content_id+'&email='+email+'&subject='+subject+'&comment='+escape(comment)+'&typ=commentSubmit&parent=0', true);

	self.xmlHttpReq1.onreadystatechange = function()
	{
        if (self.xmlHttpReq1.readyState == 4)
	{    	
        str = self.xmlHttpReq1.responseText;
		updateCommentResultMain(self.xmlHttpReq1.responseText);
		var url = unescape(window.location.pathname);	
		var txtfind = searchinput(str);
			if(txtfind == true){
			window.location.href = url;
			}
        }
		else
		{

  		  // document.frmcommentmain.Submit.disabled = true;
		   document.getElementById("comment_result_main").innerHTML = "<center><font face=verdana size=2 color=red>Submitting...</font></center>";	
		}
    }
    self.xmlHttpReq1.send(null);

}
else
{
	if(!done)
	{
	  document.getElementById("comment_result_main").innerHTML = "<center><font face=verdana size=2 color=red>Please fill the fields indicated in the red color.</font></center>";	
	}
}
return false;
}

function updateCommentResultMain(str)
{
 document.getElementById("comment_result_main").innerHTML = "<center><font face=verdana size=2 color=red>"+str+"</font></center>";
}

<!-- -------------------------------------------------------------------------------------------------- -->


function insertCommet(content_id)
{
    var xmlHttpReq1 = false;
    var self = this;
    var name=document.frmcomment.name.value
    var email=document.frmcomment.email.value
    var comment=document.frmcomment.comment.value
    var subject=document.frmcomment.subject.value
    var parent=document.frmcomment.parent.value
    var flag=true;
  var done=false;

	if(name=="")
    {
	document.getElementById("divname").innerHTML = "<font face=verdana size=2 color=red>Name</font>";
	flag=false;
    }
    else
    {
    	document.getElementById("divname").innerHTML = "Name";
    }

    if((email=="")||(echeck(email)==false))
    {
	document.getElementById("divemail").innerHTML = "<font face=verdana size=2 color=red>Email</font>";	
	flag=false;
    }
    else
    {
	document.getElementById("divemail").innerHTML = "Email";	
    }

    if(subject=="")
    {
	document.getElementById("divsubject").innerHTML = "<font face=verdana size=2 color=red>Subject</font>";	
	flag=false;
    }
    else
    {
    	document.getElementById("divsubject").innerHTML = "Subject";	
    }

    if(comment=="")
    {
	document.getElementById("divmessage").innerHTML = "<font face=verdana size=2 color=red>Message</font>";	
	flag=false;
    }
    else
    {
	document.getElementById("divmessage").innerHTML = "Message";	
    }

//   if(!document.frmcomment.checkbox.checked)
  // {
	// document.getElementById("comment_result").innerHTML = "<center><font face=verdana size=2 color=red>Please accept the terms of use.</font></center>";	
	 //flag=false;
	 //done=true;
   //}


if(flag==true)
{
    if (window.XMLHttpRequest) 
    {
        self.xmlHttpReq1 = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
    {
        self.xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP");
    }
	self.xmlHttpReq1.open('GET', '/storyresources.php?flag=SubmitComment&name='+name+'&content_id='+content_id+'&parent='+parent+'&email='+email+'&subject='+subject+'&comment='+escape(comment)+'&typ=commentSubmit', true);
	self.xmlHttpReq1.onreadystatechange = function()
	{
        if (self.xmlHttpReq1.readyState == 4)
	{  
		/*//document.frmcomment.Submit.disabled = true;			
		var url = unescape(window.location.pathname);	
		window.location.href = url;		  	
        updateCommentResult(self.xmlHttpReq1.responseText);*/
		
		 str = self.xmlHttpReq1.responseText;
		updateCommentResult(self.xmlHttpReq1.responseText);
		var url = unescape(window.location.pathname);	
		var txtfind = searchinput(str);
			if(txtfind == true){
			window.location.href = url;
			}
        }
	else
	{
	
	  //document.frmcomment.Submit.disabled = true;			
	   document.getElementById("comment_result").innerHTML = "<center><font face=verdana size=2 color=red>Submitting...</font></center>";	
	}
    }
    self.xmlHttpReq1.send(null);

}
else
{
	if(!done)
	{
	  document.getElementById("comment_result").innerHTML = "<center><font face=verdana size=2 color=red>Please fill the fields indicated in the red color.</font></center>";	
	}
}
return false;
}

function updateCommentResult(str)
{
 document.getElementById("comment_result").innerHTML = "<center><font face=verdana size=2 color=red>"+str+"</font></center>";
}



function updateAbuse()
{
    var xmlHttpReq1 = false;
    var self = this;
    var comment=document.frmcommentabuse.comment.value
    var commentid=document.frmcommentabuse.commentid.value
    var storyid=document.frmcommentabuse.storyid.value
    var flag=true;
    document.getElementById("divmessageabuse").innerHTML = "Message";	
    if (window.XMLHttpRequest) 
    {
        self.xmlHttpReq1 = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
    {
        self.xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq1.open('GET','/storyresources.php?flag=ProcessAbuse&comment='+escape(comment)+'&commentid='+commentid+'&storyid='+storyid, true);
	self.xmlHttpReq1.onreadystatechange = function()
	{
        if (self.xmlHttpReq1.readyState == 4)
	{    
 	    document.getElementById("comment_result_abuse").innerHTML = "<center><font face=verdana size=2 color=red>"+self.xmlHttpReq1.responseText+"</font></center>";
        }
	else
	{
	   document.getElementById("comment_result_abuse").innerHTML = "<center><font face=verdana size=2 color=red>Submitting...</font></center>";	
	}
    }
    self.xmlHttpReq1.send(null);
return false;
}



function forwardLink()
{
    var xmlHttpReq1 = false;
    var self = this;
    var myname=document.frmcommentforward.myname.value
    var myemail=document.frmcommentforward.myemail.value
    var friendsemail=document.frmcommentforward.friendsemail.value
    var linkforward=document.frmcommentforward.link.value
    var flag=true;
    
    if(myname=="")
    {
	document.getElementById("divmynameforward").innerHTML = "<font face=verdana size=2 color=red>Your Name</font>";
	flag=false;
    }
    else
    {
    	document.getElementById("divmynameforward").innerHTML = "Your Name";
    }

    if(myemail=="")
    {
	document.getElementById("divmyemailforward").innerHTML = "<font face=verdana size=2 color=red>My Email</font>";	
	flag=false;
    }
    else
    {
	document.getElementById("divmyemailforward").innerHTML = "My Email";	
    }

    if(friendsemail=="")
    {
	document.getElementById("divfriendsemailforward").innerHTML = "<font face=verdana size=2 color=red>Friend's Email</font>";	
	flag=false;
    }
    else
    {
    	document.getElementById("divfriendsemailforward").innerHTML = "Friend's Email";	
    }

if(flag)
{
    if (window.XMLHttpRequest) 
    {
        self.xmlHttpReq1 = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
    {
        self.xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq1.open('GET', '/storyresources.php?flag=LinkForward&myname='+myname+'&friendsemail='+friendsemail+'&myemail='+myemail+'&linkforward='+linkforward, true);
	self.xmlHttpReq1.onreadystatechange = function()
	{
        if (self.xmlHttpReq1.readyState == 4)
	{    	
            document.getElementById("comment_result_forward").innerHTML = "<center><font face=verdana size=2 color=red>"+self.xmlHttpReq1.responseText+"</font></center>";
        }
	else
	{
	   document.getElementById("comment_result_forward").innerHTML = "<center><font face=verdana size=2 color=red>Submitting...</font></center>";	
	}
    }
    self.xmlHttpReq1.send(null);

}
else
{
	document.getElementById("comment_result_forward").innerHTML = "<center><font face=verdana size=2 color=red>Please fill the fields indicated in the red color.</font></center>";	
}
return false;

}

