function registerValidation()
{    
var name=document.getElementById("name").value;
var email=document.getElementById("email").value;
var passwd=document.getElementById("passwd").value;
var cpasswd=document.getElementById("cpasswd").value;
var capchacode=document.getElementById("capchacode").value;
submitOK="true";

if (name.length<1)
 {
 alert("Please enter your name.");
 submitOK="false";
 }

else if (email.length<1 || email.indexOf("@") == -1)
 {
 alert("Please enter your valid E-Mail Id.");
 submitOK="false";
 }

else if (passwd.length<1)
 {
 alert("Please enter your password!");
 submitOK="false";
 }

else if (cpasswd.length<1)
 {
 alert("Please confirm your password!");
 submitOK="false";
 }

 else if (capchacode.length<1)
 {
 alert("Please verify the Captcha code?");
 submitOK="false";
 }

else if (cpasswd!=passwd)
 {
 alert("Passwords doesn't match.Please try again!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}


function passwordValidation()
{
var opwd=document.getElementById("opwd").value;
var npwd=document.getElementById("npwd").value;
var rnpwd=document.getElementById("rnpwd").value;
submitOK="true";

if (opwd.length<=0)
 {
 alert("Please enter your old password!");
 submitOK="false";
 }

else if (npwd.length<=0)
 {
 alert("Please enter your new password!");
 submitOK="false";
 }

else if (rnpwd.length<=0)
 {
 alert("Please confirm your new password! ");
 submitOK="false";
 }

else if (npwd != rnpwd)
 {
 alert("Re-Entered password doesn't match. Please try again!");
 submitOK="false";
 }

 if (submitOK=="false")
 {
 return false;
 }
}

function photoValidation()
{
var photo=document.getElementById("photo").value;
submitOK="true";

if (photo.length<=0)
 {
 alert("Please upload your image!");
 submitOK="false";
 }

 if (submitOK=="false")
 {
 return false;
 }
}

function searchValidation()
{
var key=document.getElementById("keyword").value;
var searchby=document.getElementById("searchby").value;
submitOK="true";

if (key.indexOf("%") == 0 && searchby !='Online' && searchby!='NewUsers')
 {
 alert("Please enter some valid keywords to search!");
 submitOK="false";
 }

else if (key.length<=0 && searchby !='Online' && searchby!='NewUsers')
 {
 alert("Please enter some keywords to search!");
 submitOK="false";
 }

if (searchby=='Online' && key != 'Yes' && key != 'No' && key != 'YES' && key != 'NO' && key != 'yes' && key != 'no')
 {
 alert("Please enter the keyword as 'Yes' or 'No'");
 submitOK="false";
 }

 if (submitOK=="false")
 {
 return false;
 }
}

function messageValidation()
{    
var msg=document.getElementById("message").value;
var url=document.getElementById("url").value;
var category=document.getElementById("category").value;
submitOK="true";

if (msg.length>152)
 {
 alert("Please post your message in less than 150 charecters!");
 submitOK="false";
 }

else if (msg.length <= 1)
 {
 alert("Sorry!You can not post empty message!");
 submitOK="false";
 }

else if (url.indexOf(".") == -1)
 {
 alert("Please enter a valid url");
 submitOK="false";
 }

else if (category.length<1)
 {
 alert("Please select a category!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}

function private_messageValidation()
{
var msg=document.getElementById("message").value;
submitOK="true";

if (msg.length>150)
 {
 alert("Please post your message in less than 150 charecters!");
 submitOK="false";
 }
else if (msg.length <= 1)
 {
 alert("Sorry! You can not send empty message to the user!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}

 function notesValidation()
{
var note=document.getElementById("note").value;
submitOK="true";

if (note.length>150)
 {
 alert("Please make notes in less than 150 charecters!");
 submitOK="false";
 }
else if (note.length <= 0)
 {
 alert("Sorry! You can not make empty notes!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }

}

 function commentsValidation()
{
var comment=document.getElementById("comment").value;
submitOK="true";

if (comment.length>150)
 {
 alert("Please make your comment in less than 150 charecters!");
 submitOK="false";
 }
else if (comment.length <= 0)
 {
 alert("Sorry! You can not add an empty comment!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }

}

function share_messageValidation()
{
var to_user=document.getElementById("to_user").value;
submitOK="true";

 if (to_user.length <= 0)
 {
 alert("Please choose atleast 'a person' to share!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}

function loginValidation()
{
var email=document.getElementById("lemail").value;
var passwd=document.getElementById("lpasswd").value;
submitOK="true";

//if (email.length<1 || email.indexOf("@") == -1)
if (email.length<1)
 {
 alert("Please enter your valid Email id!");
 submitOK="false";
 }

else if (passwd.length<1)
 {
 alert("Please enter your password!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}

function loginGameValidation()
{
var email=document.getElementById("lemail").value;
var passwd=document.getElementById("lpasswd").value;
var point=document.getElementById("point").value;
submitOK="true";

if (email.length<1 || email.indexOf("@") == -1)
 {
 alert("Please enter your valid Email id!");
 submitOK="false";
 }

else if (passwd.length<1)
 {
 alert("Please enter your password!");
 submitOK="false";
 }

else if (point.length<1)
 {
 alert("Please enter valid score!");
 submitOK="false";
 }
else if (isNaN(point))
 {
 alert("Please enter your score in numbers!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}

function saalram_loginValidation()
{
var email=document.getElementById("remail").value;
var passwd=document.getElementById("rpasswd").value;
submitOK="true";

//if (email.length<1 || email.indexOf("@") == -1)
if (email.length<1)
 {
 alert("Please enter your valid Email id!");
 submitOK="false";
 }

else if (passwd.length<1)
 {
 alert("Please enter your password!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}


function forgetPasswordValidation()
{
var email=document.getElementById("femail").value;
submitOK="true";

if (email.length<1 || email.indexOf("@") == -1)
 {
 alert("Please enter your valid Email id!");
 submitOK="false";
 }

else if (passwd.length<1)
 {
 alert("Please enter your password!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}

function autoAnnounceValidation()
{
var rssurl=document.getElementById("rssurl").value;
var category=document.getElementById("category").value;
var tags=document.getElementById("tags").value;
submitOK="true";

if (rssurl.length<1)
 {
 alert("Please enter a valid RSS feed link!");
 submitOK="false";
 }

 else if (category.length<1)
 {
 alert("Please select a category!");
 submitOK="false";
 }
else if (tags.length<1)
 {
 alert("Please specify tags!");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}


function socialNetworkValidation()
{
var SocialNetworkUserid=document.getElementById("SocialNetworkUserid").value;
var SocialNetworkPassword=document.getElementById("SocialNetworkPassword").value;
submitOK="true";

if (SocialNetworkUserid.length<1)
 {
 alert("Please enter a valid User Id!");
 submitOK="false";
 }

 else if (SocialNetworkPassword.length<1)
 {
 alert("Please select a valid Password!");
 submitOK="false";
 }
if (submitOK=="false")
 {
 return false;
 }
}

  function checkCharLength(qparam)
  {
  xmlHttp=CreateXmlHttpObject()
  if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
  qparam = replaceAll(qparam,"%",".");
  var url="CheckCharLength.jsp"
  url=url+"?param="+qparam;
  xmlHttp.onreadystatechange=stateChanged1
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
  }
function stateChanged1()
  {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
  document.getElementById("availchar").innerHTML=xmlHttp.responseText
  }
  }

  function hitCount(qparam)
  {
  xmlHttp=CreateXmlHttpObject()
  if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
  var url="Hitcount"
  url=url+"?msg_id="+qparam;
  //alert(url);
  xmlHttp.onreadystatechange=stateChanged3
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
  }
function stateChanged3()
  {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
  //document.getElementById("availchar").innerHTML=xmlHttp.responseText
  }
  }


  function checkavailble_Url(qparam)
  {
  xmlHttp=CreateXmlHttpObject()
  if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
  
  var url="checkavailble_Url.jsp"
  url=url+"?param="+qparam;
  //alert(url);
  xmlHttp.onreadystatechange=stateChanged2
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
  }
function stateChanged2()
  {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
  document.getElementById("prof_link").innerHTML=xmlHttp.responseText
  }
  }

  function findPeople(qparam)
  {
  xmlHttp=CreateXmlHttpObject()
  if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
  if(qparam == null)
        alert("Please type something to search");
  
  var url="find_people_1.jsp"
  url=url+"?param="+qparam;
  //alert(url);
  xmlHttp.onreadystatechange=stateChanged4
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
  }
function stateChanged4()
  {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
  document.getElementById("searchresult").innerHTML=xmlHttp.responseText
  }
  }



function socialNetworkChange(qparam)
  {
  xmlHttp=CreateXmlHttpObject()
  if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
  var url="add_social_network.jsp"
  url=url+"?param="+qparam;
  xmlHttp.onreadystatechange=stateChanged5
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
  }
function stateChanged5()
  {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
  document.getElementById("changeDiv").innerHTML=xmlHttp.responseText
  }
}

function gameSelect(qparam)
  {
  if(qparam.length > 0)
  {
  xmlHttp=CreateXmlHttpObject()
  if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
  var url="games_1.jsp"
  url=url+"?param="+qparam;
  xmlHttp.onreadystatechange=stateChanged6
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
  }
  else
      {alert("Please select a Game!");}
  }
function stateChanged6()
  {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
  document.getElementById("showGames").innerHTML=xmlHttp.responseText
  }
}

function gamePlay(qparam)
  {  
  if(qparam.length>0)
  {
  xmlHttp=CreateXmlHttpObject()
  if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
  var url="games_2.jsp"
  url=url+"?param="+qparam;
  xmlHttp.onreadystatechange=stateChanged7
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
  }
  else
      {alert("Please select a Game Category!");}
  }
function stateChanged7()
  {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
  document.getElementById("showPlay").innerHTML=xmlHttp.responseText
  }
}

function indexNavigation(page)
  {
  if(page.length>0)
  {
      window.open(page);
  }
  else
      {alert("Please select a page!");}
  }

function changeNewsChannel(qparam)
  {
  if(qparam.length>0)
  {
      var dd = document.news.newschannel.selectedIndex;
      var title = document.news.newschannel[dd].text;
      //alert(title);
      var url = document.news.newschannel[dd].value;
      //alert(url);
      document.getElementById("newstitle").value=title;
      document.getElementById("newslink").value=url;
  }
  else{
      alert("Please select a channel!");
  }
}


function CreateXmlHttpObject()
  {
  var objXMLHttp=null
  if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest()
  }
  else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
  return objXMLHttp
  }


function addFavouriteForm(param)
{
 document.getElementById("fparam").value=param;
 document.addfavouriteform.submit();
}
function remFavouriteForm(param)
{
 document.getElementById("rfparam").value=param;
 document.remfavouriteform.submit();
}

function commentsForm(param)
{
 document.getElementById("cparam").value=param;
 document.commentsform.submit();
}

function flcommentsForm(param)
{ 
 document.getElementById("flcparam").value=param;
 document.flcommentsform.submit();
}

function ratingupForm(param)
{
 document.getElementById("ruparam").value=param;
 document.ratingupform.submit();
}
function ratingdownForm(param)
{
 document.getElementById("rdparam").value=param;
 document.ratingdownform.submit();
}

function writetouserForm(param1,param2)
{
 document.getElementById("2uidparam").value=param1;
 document.getElementById("2unameparam").value=param2;
 document.writetouserform.submit();
}

function pwritetouserForm(param1,param2,param3)
{
 document.getElementById("p2uidparam").value=param1;
 document.getElementById("p2unameparam").value=param2;
 document.getElementById("p2publicizemsgparam").value=param3;
 document.pwritetouserform.submit();
}
function writetousershareForm(param1,param2,param3)
{
 document.getElementById("2shareuidparam").value=param1;
 document.getElementById("2shareunameparam").value=param2;
 document.getElementById("2sharemsgidparam").value=param3;
 document.writetousershareform.submit();
}

function replytouserForm(param1,param2,param3,param4)
{
 document.getElementById("3uidparam").value=param1;
 document.getElementById("3unameparam").value=param2;
 document.getElementById("3midparam").value=param3;
 document.getElementById("3readflagparam").value=param4;
 document.replytouserform.submit();
}

function sharewithuserForm(param)
{
 document.getElementById("sparam").value=param;
 document.sharewithuserform.submit();
}
function msgwatchForm(param)
{
 document.getElementById("mparam").value=param;
 document.msgwatchform.submit();
}
function userwatchForm(param)
{ 
 document.getElementById("uparam").value=param;
 document.userwatchform.submit();
}
function userwatchFormRight(param)
{ 
 document.getElementById("uparami").value=param;
 document.userwatchformright.submit();
}
function markasreadshareForm(param)
{
 document.getElementById("msparam").value=param;
 document.markasreadshareform.submit();
}
function deletemsgForm(param)
{ 
 document.getElementById("dmparam").value=param;
 document.deletemsgform.submit();
}
function deletemsgoutForm(param)
{
 document.getElementById("dmoparam").value=param;
 document.deletemsgoutform.submit();
}
function categoryForm(param1,param2)
{
 document.getElementById("catidparam").value=param1;
 document.getElementById("catnameparam").value=param2;
 //alert(param1+" "+param2);
 document.categoryform.submit();
}
function categoryForm1(param1,param2,param3)
{
 document.getElementById("catidparam1").value=param1;
 document.getElementById("catnameparam1").value=param2;
 document.getElementById("load1").value=param3;
 //alert(param1+" "+param2);
 document.categoryform1.submit();
}
function removemsgForm(param)
{
   // alert("1 "+param);
 document.getElementById("rmparam").value=param;
 //alert(param1+" "+param2);
 document.removemsgform.submit();
}

function sendKissForm(param1,param2)
{    
 document.getElementById("kissuidparam").value=param1;
 document.getElementById("kissidunameparam").value=param2;
 document.sendkissform.submit();
}

function sendHugsForm(param1,param2)
{
 document.getElementById("hugsuidparam").value=param1;
 document.getElementById("hugsidunameparam").value=param2;
 document.sendhugsform.submit();
}

function removeAllmsgForm()
{
    
 var aa= document.getElementById('frm1');
 var chckflag=false;
 for (var i =1; i < aa.elements.length; i++)
	{
	 chckflag=aa.elements[i].checked;
     if (chckflag)     
           break;
	}
 
 if(chckflag)
  document.removeallmsgform.submit();
else if (!chckflag)
    alert ("Please select any message(s) to delete!")
}

function editmsgForm(param)
{
 document.getElementById("edparam").value=param;
 //alert(param1+" "+param2);
 document.editmsgform.submit();
}
function markasreadForm(param)
{
 document.getElementById("maparam").value=param;
 document.markasreadform.submit();
}
function removemsgoutForm(param)
{
 document.getElementById("rmoutparam").value=param;
 //alert(param1+" "+param2);
 document.removemsgoutform.submit();
}
function removeAllmsgoutForm()
{
var aa= document.getElementById('outfrm1');
 var chckflag=false;
 for (var i =1; i < aa.elements.length; i++)
	{
	 chckflag=aa.elements[i].checked;
     if (chckflag)
           break;
	}
 if(chckflag)
  document.removeallmsgoutform.submit();
else if (!chckflag)
    alert ("Please select any message(s) to delete!")
  
}

function usermsgForm(param1,param2)
{
 document.getElementById("auparam").value=param1;
 document.getElementById("aunparam").value=param2;
 //alert(param1+" "+param2);
 document.usermsgform.submit();
}

function usermsgFormLoad(param1,param2,param3)
{
 document.getElementById("auparam").value=param1;
 document.getElementById("aunparam").value=param2;
 document.getElementById("aloadparam").value=param3;
 //alert(param1+" "+param2);
 document.usermsgformload.submit();
}

function chatRoomForm(param1)
{
 alert("checkng");
 document.getElementById("UNAME").value=param1;
  //alert(param1+" "+param2);
 document.chatroomform.submit();
}

function sharewithuserForm1(param1,param2,param3)
{
 document.getElementById("touserparam").value=param1;
 document.getElementById("msgidparam").value=param2;
 document.getElementById("usernameparam").value=param3;
 //alert(param1+" "+param2);
 document.sharewithuserform1.submit();
}
function replaceAll(Source,stringToFind,stringToReplace){
  var temp = Source;
  var index = temp.indexOf(stringToFind);
  while(index != -1){
  temp = temp.replace(stringToFind,stringToReplace);
  index = temp.indexOf(stringToFind);
   }
  return temp;
}

//Saalram BookMark Script

 function bookmark(url,title){  
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else if (navigator.appName == "Opera") {
    alert("Press CTRL+D to bookmark");
  }
  else {
    alert("Press CTRL+D to bookmark");
  }
}


function disableTextArea(a)
{
var MAXLENGTH=150
var length=a.value.length;
if (length>MAXLENGTH)
{ a.value=a.value.substring(0,MAXLENGTH);
  alert("Maximum of "+MAXLENGTH+" chars!");
  return false;}
else return true;
}


function imageFileValidation( filename)
{
var filext= filename.substring(filename.lastIndexOf(".")+1);
// Checking Extension
if(filext == "jpg" || filext == "jpeg" || filext == "gif" || filext == "bmp" || filext == "JPG" || filext == "JPEG" || filext == "GIF" || filext == "BMP")
{ 
}
else
{
    alert("Invalid File Format Selected. Please upload Jpg,Jpeg,Gif or Bmp files!");
}
}

function imageSubmitValidation()
{
var image1=document.getElementById("image1").value;
var image2=document.getElementById("image2").value;
var image3=document.getElementById("image3").value;
var image4=document.getElementById("image4").value;
var image5=document.getElementById("image5").value;
submitOK="true";

if (image1.length>1 || image2.length>1 || image3.length>1 || image4.length>1 || image5.length>1)
 { 
 submitOK="true";
 }

 else
     {
 alert("Please Upload atleast one image!");
 submitOK="false";
     }

if (submitOK=="false")
 {
 return false;
 }
}

function modifyAlbumForm(param)
{ 
 document.getElementById("operatekey").value=param;
// var res=modifyAlbumValidation();
// if(res=="true"){
 document.modifyalbumform.submit();
 //}
}

function modifyAlbumValidation()
{
submitOK="true";
var total=""
for(var i=0; i < document.modifyalbumform.album_name.length; i++){
if(document.modifyalbumform.album_name[i].checked)
total +=document.modifyalbumform.album_name[i].value + "\n"
}
if(total==""){
submitOK="false";
alert("Please select an Album!");
}
else{
submitOK="true";
}
return submitOK;
 }
 
function loveScoreValidation()
{
var lovescore=document.getElementById("lovescore").value;
submitOK="true";

if (lovescore=='Your Love Score...' || lovescore.length<1)
 {
 alert("Please enter your love score!\n  Example: 94%");
 submitOK="false";
 }

if (submitOK=="false")
 {
 return false;
 }
}


