/* CSS Document
 * @Revision $Revision: 1603 $
 * @Author $Author: rajan $
 * @Date $Date: 2009-08-03 12:35:58 +0530 (Mon, 03 Aug 2009) $
*/
function check_email(str)
{
	if(str=="")
	{
		return false;
	}
	else
	{
	if(str!="")
	{

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ;
		if (!filter.test(str))
		{
			return false;
		}
	}
	}
return true;
}

function login_validate2(theform)
{
//alert(theform.comment.value);
if(trim(theform.comment.value)=="")
{
alert("please Enter Comment");
theform.comment.value='';
theform.comment.focus();
return false;
}
var str=theform.comment.value;
if(str.length<4)
{
alert("Please Enter at least one line Comment");
theform.comment.focus();
return false;
}

var return2=check_email(theform.emailid1.value);
if(return2==false)
{
alert("Please input a valid email address!");
theform.emailid1.value="";
theform.emailid1.focus();
return false;
}

if(trim(theform.password1.value)=="")
{
alert("Please Enter your Password");
theform.password1.value='';
theform.password1.focus();
return false;
}
if(trim(theform.comment.value)=="")
{
alert("please Enter Comment");
theform.comment.value='';
theform.comment.focus();
return false;
}
}
function login_validate1()
{

if(trim(document.cmtform.comment.value)=="")
{
alert("please Enter Comment");
document.cmtform.comment.value='';
document.cmtform.comment.focus();
return false;
}
var str=document.cmtform.comment.value;
if(str.length<4)
{
alert("Please Enter at least one line Comment");
document.cmtform.comment.focus();
return false;
}

var return2=check_email(document.cmtform.emailid1.value);

if(return2==false)
{
alert("Please input a valid email address!");
document.cmtform.emailid1.value="";
document.cmtform.emailid1.focus();
return false;
}

if(trim(document.cmtform.password1.value)=="")
{
alert("Please Enter your Password");
document.cmtform.password1.value='';
document.cmtform.password1.focus();
return false;
}
if(trim(document.cmtform.comment.value)=="")
{
alert("please Enter Comment");
document.cmtform.comment.value='';
document.cmtform.comment.focus();
return false;
}
}

function changetext()
	{
   		var val1=document.getElementById('select_search').value;
		if(val1==1)
			 {
				  	document.getElementById('search_community').value="Search blogs";
		     }
		else if(val1==9)
			{
				  	document.getElementById('search_community').value="Search bloggers";
			}
		else if(val1==2)
			 {
				  	document.getElementById('search_community').value="Type keyword (name, city, company, title)";
			 }
		else if(val1==3)
			 {
				  	document.getElementById('search_community').value="Search news";
			 }
		else if(val1==4)
			 {
				  	document.getElementById('search_community').value="Search jobs";
			 }
		else if(val1==5)
			 {
				  	document.getElementById('search_community').value="Search videos";
			 }
		else if(val1==6)
			 {
				  	document.getElementById('search_community').value="Search mentors";
			 }
	    else if(val1==7)
			 {
				  	document.getElementById('search_community').value="Search communities";
			 }
	    else if(val1==8)
			 {
				  	document.getElementById('search_community').value="Search questions";
			 }
   }

	function trim(stringToTrim) {
 //alert(stringToTrim);
	return stringToTrim.replace(/^\s+|\s+$/g,'');
	}
	function valid(i)
	{
      var url=i;
      if(trim(document.searchfrm.search.value)=='')
      {
      changetext();
      }
	  if(trim(document.searchfrm.search.value)=='' || document.searchfrm.search.value=='Type keyword (name, city, company, title)' || document.searchfrm.search.value=='Search news'
	  || document.searchfrm.search.value=='Search blogs' || document.searchfrm.search.value=='Search jobs'
	  || document.searchfrm.search.value=='Search videos' || document.searchfrm.search.value=='Search mentors'
	  || document.searchfrm.search.value=='Search communities' || document.searchfrm.search.value=='Search questions' || document.searchfrm.search.value=='Search bloggers')
	  {
	  	alert("Enter search string");
	  	document.searchfrm.search.value='';
	  	document.searchfrm.search.focus();
	  	return false;
	  }
	  else
	  {
	  	var val1=document.getElementById('select_search').value;
	     if(val1==1)
			 {
			 		document.searchfrm.bsearchtype.value=val1;
				  	document.searchfrm.action='/category/searchresult';
		     }
		else if(val1==9)
			 {
			 		document.searchfrm.bsearchtype.value=val1;
				  	document.searchfrm.action='/category/searchresult';
		     }
		else if(val1==2)
			 {
				  	document.searchfrm.action=url+'/network/membersearch.php';
			 }
		else if(val1==3)
			 {
				  	document.searchfrm.action=url+'/news/searchnews.php';
			 }
		else if(val1==4)
			 {
				  	  document.searchfrm.keywords.value=document.searchfrm.search.value;
					  document.searchfrm.action=url+'/career/jobsearch.php';
			 }
		else if(val1==5)
			 {
				  	document.searchfrm.action=url+'/university/coursesearch.php';
			 }
		else if(val1==6)
			 {
				  	document.searchfrm.action=url+'/mentorship_new1/mentorhome.php';
			 }
		else if(val1==7)
			 {
				  	document.searchfrm.action='http://communities.silicon-india.us/searchresult';
			 }
		else if(val1==8)
			 {
				  	document.searchfrm.action=url+'/answers/questions_search.php';
			 }
		  document.searchfrm.submit();
	  }
	}

function hidediv(id1,id2){
if(id1 != ''){
document.getElementById(id1).style.display = 'none';}
if(id2 != ''){
document.getElementById(id2).style.display = 'block';}
}
function hidediv11(id1,id2){
if(id1 != ''){
document.getElementById(id1).style.display = 'none';}
if(id2 != ''){
document.getElementById(id2).style.display = 'block';}
}

function printThis()
{
    var usertype=navigator.userAgent.toLowerCase();
    if (window.print) {
        setTimeout('window.print();',200);
    }
    else if (usertype.indexOf("mac") != -1) {
        alert("Press 'Cmd+p' on your keyboard to print article.");
    }
    else {
        alert("Press 'Ctrl+p' on your keyboard to print article.")
    }
}
function showhide(st){
if(st==1){
document.getElementById("Layer1").style.display='block';
document.getElementById("Layer4").style.display='block';
}
else{
document.getElementById("Layer1").style.display='none';
document.getElementById("Layer4").style.display='none';
}
}
function ValidateSendEmail(theForm,i)
{
    var theForm=theForm;
    var url=i;
    //alert(theForm);
    //alert(url);
    //alert("hi");
	if(theForm.toaddress.value=="" || theForm.toaddress.value==0)
	{
	 alert("Please enter receiver's email");
	 theForm.toaddress.focus();
	 return false;
	}
	var emailvalue=theForm.toaddress.value;
	var mytool_array=emailvalue.split(",");
	for(i=0;i<mytool_array.length;i++)
	{
       //alert(mytool_array[i]);

		if (echeck(trim(mytool_array[i]))==false)
		{
		theForm.toaddress.value="";
		theForm.toaddress.focus();
		return false;
		}
	}
	if(theForm.fromname.value=="" || theForm.fromname.value==0)
	{
	 alert("Please enter your name");
	 theForm.fromname.focus();
	 return false;
	}
	if(theForm.fromaddress.value=="" || theForm.fromaddress.value==0)
	{
	 alert("Please enter your email");
	 theForm.fromaddress.focus();
	 return false;
	}
	var emailfrom=theForm.fromaddress;
	if (echeck(emailfrom.value)==false){
		emailfrom.value=""
		emailfrom.focus();
		return false;
	}
	if(theForm.body.value=="" || theForm.body.value==0)
	{
	 alert("Please enter your message");
	 theForm.body.focus();
	 return false;
	}
	if(theForm.message.value=="" || theForm.message.value==0)
	{
	alert("Please enter the verification code");
	theForm.message.focus();
	return false;
	}
	//alert("submit");
    document.sendemail.action=url+'/forwardemail.php';
    document.sendemail.submit();

}
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 login_validate(frm,i){

    var frm=frm;
    var url=i;
	var mail=echeck1(frm.email.value);
	if(mail== false){
		frm.email.value='';
		frm.email.focus();
		return false;
		}
	var pass= trim(frm.password.value);
	if(pass == '')
	{
		alert('Enter a password');
		frm.password.value='';
		frm.password.focus();
	return false;
		}
	frm.action=url+'/blogs/blogsothers/signin1.php';
    frm.submit();
}
function echeck1(email){
var email=email;
//alert(email);
	if(email==""){alert('Please enter email -id');return false;}
	else{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) {
      alert('Invalid email address');
      email='';
      //email.focus();
      return false;
   }
}
}



var sho=0;

function sho_hide(){

if(sho	== 0){
showregularly(30,0);sho=1;}
else {
hideregularly1(285,500);sho=0;}
}

function showregularly(hgt,wdth){
	var hg=document.getElementById("cmntsouter").style.height;
	//alert(hgt);
	var x=hg.split('p');
	sho=1;
	hg=Number(x[0]);
	var brVer = navigator.userAgent;
	var brVerId = brVer.indexOf('MSIE');
   	brNum = brVer.substr(brVerId,8);
	if(navigator.appName == "Microsoft Internet Explorer" && brNum=='MSIE 6.0')
	{
		if( hg < 250){
			if(hgt < 300){
				document.getElementById("cmntsouter").style.height=hgt+"px";

				document.getElementById("examples1").style.height=hgt+"px";
				//document.getElementById("").style.width=wdth+"px";
				document.getElementById("incomments").style.clip = "rect(0px, "+wdth+"px,"+hgt+"px"+", 0px)";
				hgt = hgt+10;
				wdth =547;
				//alert(hgt);
				setTimeout("showregularly("+hgt+","+ wdth+")",20);
			}

		}
	}
	else
	{
		if( hg < 300){
			if(hgt < 300){
				document.getElementById("cmntsouter").style.height=hgt+"px";

				document.getElementById("examples1").style.height=hgt+"px";
				//document.getElementById("").style.width=wdth+"px";
				document.getElementById("incomments").style.clip = "rect(0px, "+wdth+"px,"+hgt+"px"+", 0px)";
				hgt = hgt+10;
				wdth =wdth+21;
				//alert(hgt);
				setTimeout("showregularly("+hgt+","+ wdth+")",20);
			}

		}
	}
}



function hideregularly1(hgt,wdth){
sho=0;
if(hgt>10){
document.getElementById("cmntsouter").style.height=hgt+"px";
document.getElementById("examples1").style.height=hgt+"px";
//document.getElementById("").style.width=wdth+"px";
document.getElementById("incomments").style.clip = "rect(0px, "+wdth+"px,"+hgt+"px"+", 0px)";
//document.getElementById("examples1").style.width=wdth+"px";
wdth -=15;
hgt=hgt-10;
setTimeout("hideregularly1("+hgt+","+wdth +")",20);
}
else {document.getElementById("incomments").style.clip = "rect(0px 600px 0px 0px)"; }
}

function sho_hide1(num,cntcount){
examples="examples"+num;
document.getElementById(examples).style.display='block';
for(i=2;i<=cntcount+1;i++)
{
	if(i!=num)
	{
	examples="examples"+i;
	document.getElementById(examples).style.display='none';
	}
}
}

function sho_hide2(num){

examples="examples"+num;
document.getElementById(examples).style.display='none';
}
/**
 *
 * @access public
 * @return void
 **/
function login_chek(){
//alert(errorcode);
document.getElementById('newmahi').style.display='block';
document.getElementById('newmahi2').style.display='block';
//setTimeout('waitlogin()',5000);
}
/*function waitlogin(){
 document.getElementById('newmahi').style.display='none';
 document.getElementById('newmahi2').style.display='none';
 document.getElementById('errormsg').style.display='none';

 }*/
 /**
  *
  * @access public
  * @return void
  **/
 function validate_post(){
title=document.postblog.blog_title;
description=document.postblog.description;
	if(trim(title.value)=='')
	{
	alert("please enter title of your blog");
	title.value='';
	title.focus();
	return false;
	}
	if(trim(description.value)=='')
	{
	alert("please enter blog description");
	description.value='';
	description.focus();
	return false;
	}
	var return2=check_email(document.postblog.email.value);

	if(trim(document.postblog.email.value)=='')
	{
	alert("Please enter your email");
	document.postblog.email.value='';
	document.postblog.email.focus();
	return false;
	}
	else if(return2==false)
	{
	alert("Please input a valid email address!");
	document.postblog.email.value="";
	document.postblog.email.focus();
	return false;
	}

	if(trim(document.postblog.password.value)=="")
	{
	alert("Please Enter your Password");
	document.postblog.password.value='';
	document.postblog.password.focus();
	return false;
	}
	document.getElementById('joinsiliconindia').style.display='none';

}

function textCounter(c,a,b){
	if(c.value.length>b){
	c.value=c.value.substring(0,b)
	}
	else{
	a.value=b-c.value.length
	}
}

