window.onload = function() {
	var path	= jQuery("#rootPath").val();
	var record	= jQuery("#record").val();
	var proIdCon= jQuery("#proIdCon").val();
	var filePath= jQuery("#filePath").val();
	var p_code1= jQuery("#p_code1").val();
	//alert(p_code1);
	var url = document.location.href;
	var ind = url.lastIndexOf("/")+1;
	var len = url.length;
	var remStr = url.substring(ind,len);
	var ind1 = remStr.lastIndexOf("?");
	var len1 = remStr.length;
	var remStr1 = remStr.substring(0,ind1);
	if(document.getElementById('p_code1') != null && p_code1 == '') {
		document.getElementById('rightBarCont').style.display = 'none';
		document.getElementById('postCodeBlk').style.width = '837px';
		document.getElementById('postCodeBlk1').style.width = '837px';
		document.getElementById('pstLabel').style.width = '350px';
		jQuery('#postUpdate').css('padding-left','343px');
	} else {
		if (filePath != 'ideasuggest') {
			if (document.getElementById('blockVal') != null) {
				//alert("hghghg");
				var myfileName=window.location.href.substring(window.location.href.lastIndexOf("/")+1,window.location.href.length); 
				var myFileNameVal = myfileName.lastIndexOf("?");
				if(parseInt(myFileNameVal) > 0) {
					var myfileName1=myfileName.substring(0,myfileName.lastIndexOf("?")); 
				} else {
					var myfileName1=myfileName;
				}
				if(document.getElementById('error') != null ) {
					var err = document.getElementById('error').value;
					var error = '&error='+err;
				} else {
					var error = '';
				}
				jQuery.ajax({
					type: "POST",
					url: path+"/library/rightBarVocal/rightBarContent.php",
					data: "rec="+record+"&proIdCon="+proIdCon+error+"&fileName="+myfileName1,
					success: function(msg){
						//alert(msg);
						jQuery("#rightBarCont").html(msg);
						document.getElementById('rightBarCont').innerHTML = msg;
					}
				});
			} else {
				jQuery.ajax({
					type: "POST",
					url: path+"/library/rightBar/rightBarContent.php",
					data: "rec="+record+"&proIdCon="+proIdCon,
					success: function(msg){
						jQuery("#rightBarCont").html(msg);
					}
				});
			}
		}
		var filterIds = new Array("admin","geoBlock","scoBlock","busBlock","counBlock","favBlock");
		var i;
		var k =0;
		for (i=0; i<filterIds.length; i++) {
			if (document.getElementById(filterIds[i]) != null) {
				if (document.getElementById(filterIds[i]).style.display == 'block') {
					k++;
				}
			}
		}
		if (document.getElementById('mygrpRec') != null) {
			if(k == 0) {
				document.getElementById('mygrpRec').style.display = 'block';
			} else {
				document.getElementById('mygrpRec').style.display = 'none';
			}
		}
		if (document.getElementById('url') != null) {
			var proId = document.getElementById('vocalProId').value;
			var link = '/widget/showwidget.php?id='+proId;
			var u = document.getElementById('url').value = document.location.href;
			//var u=$_('url').value=document.location.href;
			//alert(u);
			var p=u.lastIndexOf("/");
			
			var domain=u.substr(0,p);
			var comLnk = path+link;
			var embed="<script type='text/javascript' src='"+comLnk+"'></script>";
			document.getElementById('embed').value=embed;
		}
	}
	return false;
}

function copyCmd(id) {
	document.getElementById(id).focus();
	document.getElementById(id).select();
	//CopiedTxt = document.selection.createRange();
    //CopiedTxt.execCommand("Copy");
}
var states = [];
function checkReadyState() {
    var state = document.readyState;
    states.push(state);
	var current_state = states.push(state);
	//alert(current_state);
	if (current_state == 4) {
		//document.getElementById('imgDiv').style.display = 'none';
		//document.getElementById('txtareaDiv').style.display = 'block';
		jQuery('#imgDiv').hide('fast');
		jQuery('#txtareaDiv').show('fast');
	} else {
		checkReadyState();
	}
}
/**
 * check spacial character validation
 * @return Boolean;
 */
function isAlphabet(elem) {  
	  var alphaExp = /^[a-zA-Z0-9_ ]+$/;  
	  if (elem.match(alphaExp)) {  
		   return true;  
	  } else {  
		 return false;  
	  }  
 }
function validateTextSearch() {
	var keyword	 = document.frmC1.keyword.value;
	var postcode = document.frmC1.p_code.value; 
	var pstr	= postit(postcode);
	if (keyword !='') {
		var checkAlpha = isAlphabet(keyword);
		if (checkAlpha == false) {
			alert("Invalid keyword.");
			document.frmC1.keyword.focus(); 
			return false;
		}
	}
	if (pstr != 'OK') {
		alert("Enter valid UK postcode.");
		document.frmC1.p_code.focus(); 
		return false;
	}
	return true;
}
function emailCheck(emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths email address contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The email address doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
//return true;
}

/**
 * check space  
 * @param String str_key
 * @return Boolean;
 */
function trim(str_key) {
	str_key = rtrim(str_key);
	str_key = ltrim(str_key);
	return str_key;
}

/**
 * function to right trim a string
 * @param String str_key
 * @return Boolean;
 */
function rtrim(str_key) {
	while (str_key.charAt(str_key.length-1)==" ") {
		str_key=str_key.substr(0,str_key.length-1);
	}	
	return str_key;
}

/**
 * function to left trim a string
 * @param String str_key
 * @return Boolean;
 */
function ltrim(str_key) {
	while (str_key.charAt ==" ") {
		str_key=str_key.substr(1);
	}	
	return str_key;
}


function submitFrm(parame) {
	//alert(parame);
	document.rtFrm.action=parame;
	document.rtFrm.submit();
}

// JavaScript Document
function validate_votee()
{
	// set var radio_choice to false
	var radio_choice = false;
	
	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < document.fav.poll_answer.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (document.fav.poll_answer[counter].checked)
		radio_choice = true; 
	}
	
	if (!radio_choice)
	{
	// If there were no selections made display an alert box 
	alert("Please select your vote.")
	return (false);
	}
	return true;
}


// registration form javascript ###########
function validate()
{
first_name		 = document.form1.first_name.value;
last_name 		 = document.form1.last_name.value;
screen_name		 = document.form1.screen_name.value;
gender 		 	 = document.form1.gender.value;
//dob 			 = document.form1.dob.value;
telephone		 = document.form1.telephone.value;
mobile			 = document.form1.mobile.value;
email 			 = document.form1.email.value;
address_line1	 = document.form1.address_line1.value;
address_line2	 = document.form1.address_line2.value;
postcode		 = document.form1.postcode.value;
password		 = document.form1.password.value;
cpassword		 = document.form1.cpassword.value;
security_code	 = document.form1.security_code.value;
security_code_temp = document.form1.security_code_temp.value;
mode 			 = document.form1.mode.value;

//country			 = document.form1.cmbCountry.value;
//nation			 = document.form1.cmbNation.value;
//county			 = document.form1.cmbCounty.value;
//community	     = document.form1.community.value;

b_day = document.form1.bday.value;
b_month = document.form1.bmonth.value;
b_year  = document.form1.byear.value;


first_name		= first_name.replace(/(\s+)$/,""); 
first_name		= first_name.replace(/^(\s+)/,"");
last_name		= last_name.replace(/(\s+)$/,""); 
last_name		= last_name.replace(/^(\s+)/,"");
screen_name		= screen_name.replace(/(\s+)$/,""); 
screen_name		= screen_name.replace(/^(\s+)/,"");
telephone		= telephone.replace(/(\s+)$/,""); 
telephone		= telephone.replace(/^(\s+)/,"");
mobile			= mobile.replace(/(\s+)$/,""); 
mobile			= mobile.replace(/^(\s+)/,"");
email			= email.replace(/(\s+)$/,""); 
email			= email.replace(/^(\s+)/,"");
address_line1	= address_line1.replace(/(\s+)$/,""); 
address_line1	= address_line1.replace(/^(\s+)/,"");
address_line2	= address_line2.replace(/(\s+)$/,""); 
address_line2	= address_line2.replace(/^(\s+)/,"");
postcode		= postcode.replace(/(\s+)$/,""); 
postcode		= postcode.replace(/^(\s+)/,"");
password		= password.replace(/(\s+)$/,""); 
password		= password.replace(/^(\s+)/,"");
cpassword		= cpassword.replace(/(\s+)$/,""); 
cpassword		= cpassword.replace(/^(\s+)/,"");
security_code	= security_code.replace(/(\s+)$/,""); 
security_code	= security_code.replace(/^(\s+)/,"");
security_code_temp	= security_code_temp.replace(/(\s+)$/,""); 
security_code_temp	= security_code_temp.replace(/^(\s+)/,"");

var str = "Please check the following :";
if(mode != 'update')
{
if(first_name == '' || last_name == '' || screen_name == '' || gender == '' || telephone == '' || email == '' || address_line1 == '' || address_line2 == '' ||  postcode == '' ||  password == '' ||  cpassword == '' ||  security_code == '' || b_day == "" || b_month == "" || b_year == "" || country == "" || nation == "" || county == "" || community == "")
{
str = str + "\n Fields mark with '*' are Compulsory.";		
}
}	
else
{
if(first_name == '' || last_name == '' || screen_name == '' ||  gender == '' || telephone == '' || email == '' || address_line1 == '' || address_line2 == '' || postcode == '' ||  security_code == '' || b_day == "" || b_month == "" || b_year == "" || country == "" || nation == "" || county == "" || community == "")
{
str = str + "\n Fields mark with '*' are Compulsory.";		
}
}	
if(first_name != "" && (hasNumber(first_name,"First Name") == false))
{
str = str + "\n Only characters (a-z) are allowed in first name";
}
if(last_name != "" && (hasNumber(last_name,"Last Name") == false))
{
str = str + "\n Only characters (a-z) are allowed in surname";
}

if(b_month == 2 && (b_day > 29))
{
str = str + "\n Please enter corrent date for Feb month";
}

/*var myDate=new Date()
var myY = dob.substring(0,4);
var myM = dob.substring(5,7);
var myD = dob.substring(8,10);
myDate.setFullYear(myY,myM-1,myD)
var today = new Date()
if (myDate>today)
{
str = str + "\n Date of Birth is greater than today";
}
*/
if(telephone != "" && (hasNumDash(telephone,"telephone") == false))
{
str = str + "\n Only characters (0-9)(-) are allowed in phone.";
}
if(mobile != "" && (hasNumDash(mobile,"mobile") == false))
{
str = str + "\n Only characters (0-9)(-) are allowed in mobile.";
}
if(email != "" && (isEmail(email) == false))
{
str = str + "\n Enter valid email address.";
}
if(password != '' && cpassword != '' && password != cpassword)
{
str = str + "\n Password and confirm password are not matching.";
}
pstr = postit(postcode);
if( pstr != 'OK')
{
str = str + "\n Enter valid UK postcode.";// + pstr;//"\n Special charachers are not allowed in postcode";
}
if(security_code != '' && security_code_temp != '' && security_code != security_code_temp)
{
str = str + "\n Security code is wrong.";
}

if(str.length > 28)
{
alert(str);
return false;
}
return true;
}

var http = gethttpobject(); // we create the http object 
function gethttpobject() { 
var xmlhttp; 

//alert(window.XMLHttpRequest);
if(window.XMLHttpRequest){ 
xmlhttp = new XMLHttpRequest(); 
} 
else if (window.activexobject){ 
xmlhttp=new activexobject("microsoft.xmlhttp"); 
if (!xmlhttp){ 
xmlhttp=new activexobject("msxml2.xmlhttp"); 
} 

} 
return xmlhttp; 
} 

function handlehttpresponse() {    
//alert(http+'pash');
if (http.readyState == 4) { 

if(http.status==200) { 
var results=http.responseText; 
//alert(results);
var a = results.split(';');
var nam = document.form1.selBox.value;

//		  var select = document.forms.form1.elements.nam;
var select = document.getElementById(''+nam+'');

for(i=0;i<a.length-1;i++)
{
var aa = a[i].split('|');
var str_value = aa[0];
var str_name  = aa[1];

select.options[i] = new Option(str_name, str_value,true);
}

} 
} 
} 


function handlehttpresponse_nation() 
{    

id_selected_nation = document.form1.nation_selected.value;


if (http.readyState == 4) { 
if(http.status==200) { 
var results=http.responseText; 

var a = results.split(';');
var nam = document.form1.selBox.value;

//		  var select = document.forms.form1.elements.nam;
var select = document.getElementById(''+nam+'');

for(i=0;i<a.length-1;i++)
{
var aa = a[i].split('|');
var str_value = aa[0];
var str_name  = aa[1];

select.options[i] = new Option(str_name, str_value,true);
if(str_value == id_selected_nation)
{
select.options[i].selected = true;
}
}

} 
} 
} 


function handlehttpresponse_county() {    

id_selected_county = document.form1.county_selected.value;


if (http.readyState == 4) { 
if(http.status==200) { 
var results=http.responseText; 

var a = results.split(';');
var nam = document.form1.selBox.value;

//		  var select = document.forms.form1.elements.nam;
var select = document.getElementById(''+nam+'');

for(i=0;i<a.length-1;i++)
{
var aa = a[i].split('|');
var str_value = aa[0];
var str_name  = aa[1];

select.options[i] = new Option(str_name, str_value,true);
if(str_value == id_selected_county)
{
select.options[i].selected = true;
}
}

} 
} 
} 

function handlehttpresponse_community() {    

id_selected = document.form1.community_selected.value;


if (http.readyState == 4) { 
if(http.status==200) { 
var results=http.responseText; 

var a = results.split(';');
var nam = document.form1.selBox.value;

//		  var select = document.forms.form1.elements.nam;
var select = document.getElementById(''+nam+'');

for(i=0;i<a.length-1;i++)
{
var aa = a[i].split('|');
var str_value = aa[0];
var str_name  = aa[1];

select.options[i] = new Option(str_name, str_value,true);
if(str_value == id_selected)
{
select.options[i].selected = true;
}
}

} 
} 
} 

function fill_nation(selboxnam,id)
{
//alert(id);
// wait(10);
country	= document.form1.cmbCountry.value;	
document.form1.selBox.value = selboxnam;
http.open("get",'get_nation.php?country='+country, false); 
http.onreadystatechange = handlehttpresponse_nation; 

http.send(null); 
}

function fill_county(selboxnam,id)
{

nation = document.form1.cmbNation.value;
document.form1.selBox.value = selboxnam;

http.open("get",'get_nation.php?county='+nation, false); 
http.onreadystatechange = handlehttpresponse_county; 
http.send(null); 

}

function fill_village(selboxnam,id)
{

comm_name = document.form1.cmbCounty.value;
document.form1.selBox.value = selboxnam;
http.open("get",'get_nation.php?community='+comm_name, false); 
http.onreadystatechange = handlehttpresponse_community; 
http.send(null); 
}

function get_info(selboxnam)
{

country	= document.form1.cmbCountry.value;	

document.form1.selBox.value = selboxnam;
http.open("get",'get_nation.php?country='+country, true); 
http.onreadystatechange = handlehttpresponse; 

http.send(null); 
}

function get_county(selboxnam)
{


nation = document.form1.cmbNation.value;
document.form1.selBox.value = selboxnam;

http.open("get",'get_nation.php?county='+nation, true); 
http.onreadystatechange = handlehttpresponse; 
http.send(null); 
}

function get_community(selboxnam)
{
comm_name = document.form1.cmbCounty.value;
document.form1.selBox.value = selboxnam;
http.open("get",'get_nation.php?community='+comm_name, true); 
http.onreadystatechange = handlehttpresponse; 
http.send(null); 
}




//Login page javascript =====================
function validateLogin()
{
 	mail = document.form1.email.value;
	 pass = document.form1.password.value;

	 mail	= mail.replace(/(\s+)$/,""); 
     mail	= mail.replace(/^(\s+)/,"");

     pass	= pass.replace(/(\s+)$/,""); 
     pass	= pass.replace(/^(\s+)/,"");
	
	
	if(mail == "" && pass == "")
	{
		alert("Please enter both email and password");
		return false;
	}
	if(isEmail(mail)==false)
	{
		alert("Please enter valid email");
		return false;
	}
	/*if(mail == "")
	{
		alert("Please enter screen name");
		return false;
	}*/
	if(pass == "")
	{
		alert("Please enter password");
		return false;
	}
	return true;
}

function sub_form()
{
	document.form1.submit();

}

//############ fill alll nation s

//######################################








//comminityVoiceSetup   ---page
function remove(id, profile_id)
{
	document.frmSC.action = 'communityVoiceSetupProcess.php?profile_id='+profile_id;
	document.frmSC.setupId.value	= id;
	document.frmSC.mode.value	= 'remove';
	document.frmSC.submit();
}	
function add(id,type, profile_id)
{
	

	var warn_msg = document.frmSC.warn_message.value;

	if(warn_msg == 'You must be logged in to send a message.')
	{
		alert('You must login before you can add yourself.');
		return false;
	}
	if(type ==1 )
	{
		
		if(document.frmSC.pwd1.value == '')
		{
			alert('Please enter password');
			return false;
		}
	}	
	
	if(type ==2 )
	{
		if(document.frmSC.pwd2.value == '')
		{
			alert('Please enter password');
			return false;
		}
	}		
	if(type ==3 )
	{
		if(document.frmSC.pwd3.value == '')
		{
			alert('Please enter password');
			return false;
		}
	}	
	document.frmSC.action = 'communityVoiceSetupProcess.php?profile_id='+profile_id;
	document.frmSC.setupId.value	= id;
	document.frmSC.type.value	= type;
	document.frmSC.mode.value	= 'add';
	document.frmSC.submit();
}
//communityVoiceTopicDetail ==== page 
function validate_vote(theForm)
{	
// require at least one radio button be selected
var radioSelected = false;
if(theForm.poll_answer.length >= 2)
{
for (i = 0;  i < theForm.poll_answer.length;  i++)
	{
	if (theForm.poll_answer[i].checked)
	
	radioSelected = true;
	
	}
}
else
{	if (theForm.poll_answer.checked)
	{
		radioSelected = true;
	}
}

if (!radioSelected)
	{
	alert("please select your answer.");
	return false;
	
	}

}	

function validate_for()
{
if(document.form_for.argument.value == '')
{
alert("please enter argument");
return false;
}	
return true;
}
function validate_against()
{
if(document.form_against.argument.value == '')
{
alert("please enter argument");
return false;
}	
return true;
}

//########## comminity notices 
 
 

	
//####################################################			


//############# communityViewDetailArgumentAgianst   ---page
function validate_for()
{
	if(document.form_for.argument.value == '')
	{
	 alert("Please enter argument");
	 return false;
	}	
	return true;
}
function validate_against()
{
	if(document.form_against.argument.value == '')
	{
	 alert("Please enter argument");
	 return false;
	}	
	return true;
}
function validate_comment()
{
	comment = document.form_comment.comment.value;
	if(comment == "")
	{
		alert("Please enter your comment");
		document.form_comment.comment.focus();
		return false;
	}
	return true;
}
//#########################commSugestTopics ---------------- page 
  function check_submit()
  {
	
	var str="";

	/*if(document.sugFrm.community_id.value==0)
	  {
		str=str+"\n Community ";
	  }*/
	 if(document.sugFrm.title.value=="")
	  {
		str=str+"\n Topic Title ";
	  }
	  if(document.sugFrm.poll_topic.value=="")
	  {
		str=str+"\n Topic Detail";
	  }
	   if(document.sugFrm.Areas.value=="")
	  {
		str=str+"\n Topic Group";
	  }
	 /* if(document.sugFrm.Age.value==0)
	  {
		str=str+"\n Please select the Age Group";
	  }*/
	if(str!="")
	  {
		str="\n Please set the following fields - "+str;
		alert(str);
		return false;
	  }
	  else
	  document.sugFrm.submit;
  }
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else 
	countfield.value = maxlimit - field.value.length;
}

function textCounterViews(field, countfield, maxlimit) {
	var fieldVal = jQuery("#"+field).val();
	var countfields = jQuery("#"+countfield).val();
	var fieldVals;
	//alert(fieldVal);
	if (fieldVal.length > maxlimit)  // if too long...trim it!
		jQuery("#"+field).val(fieldVal.substring(0, maxlimit));
	// otherwise, update 'characters left' counter
	else
		//alert(maxlimit - fieldVal.length);
		jQuery("#"+countfield).val(maxlimit - fieldVal.length);
	//}
}
	//#############  its in the template page ---- 
function validate_vote_all(theForm)
{	
// require at least one radio button be selected
var radioSelected = false;
if(theForm.poll_answer.length >= 2)
{
for (i = 0;  i < theForm.poll_answer.length;  i++)
	{
	if (theForm.poll_answer[i].checked)
	
	radioSelected = true;
	
	}
}
else
{	if (theForm.poll_answer.checked)
	{
		radioSelected = true;
	}
}

if (!radioSelected)
	{
	alert("please select your answer.");
	return false;
	
	}

}	
//#########  commRateTopicDetail  ---- page 
function validate_vote()
{
	// set var radio_choice to false
	var radio_choice = false;
	
	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < document.rtFrm.rad.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (document.rtFrm.rad[counter].checked)
		radio_choice = true; 
	}
	
	if (!radio_choice)
	{
	// If there were no selections made display an alert box 
	alert("Please select your rate.")
	return (false);
	}
	return true;
}

function check_comment()
{
	
	var comment = document.comfrm.comment_txt.value;
	//alert(comment);
	if(comment == "")
	{
		alert("Please enter your comment");
		document.comfrm.comment_txt.focus();
		return false;
	}
	return true;
}

function check_argument_for()
{
	argument = document.form1.argument.value;
	if(argument == "")
	{
		alert("Please enter your argument FOR");
		document.form1.argument.focus();
		return false;
	}

	document.form1.submit();
	return true;
}

function check_argument_against()
{
	
	argument1 = document.form2.argument.value;
	if(argument1 == "")
	{
		alert("Please enter your argument AGAINST");
		document.form2.argument.focus();
		return false;
	}
	
	return true;
}
//#############communityViewDetailArgumentFor  -------------page 

function validate_for()
{
	if(document.form_for.argument.value == '')
	{
	 alert("Please enter argument");
	 return false;
	}	
	return true;
}
function validate_against()
{
	if(document.form_against.argument.value == '')
	{
	 alert("Please enter argument");
	 return false;
	}	
	return true;
}
//##################communityVoiceTopicDetail page######
function callhoVoice( obj , ServerPath) {
	
	
	//var ServerPath="http://192.168.0.30/localeyes_01";
	//var ServerPath="http://localeyestest.co.uk";
	profile_id = obj;

	varV = "profile_id_"+obj;
	valR = document.getElementById(varV).value;

	
	if (valR == 'Voice' ) {
		document.location.href= ServerPath+"/vocaleyes/communitySearch.php?profile_id="+profile_id; 
	}
	if (valR == 'Addtnl' ) {
		
		document.location.href= ServerPath+"/groups/groups_additional_info.php?profile_id="+profile_id; 
	}

	if (valR == 'Evts' ) {
		document.location.href= ServerPath+"/groups/events/events_all_view_details.php?profile_id="+profile_id; 
	}
	if (valR == 'news' ) {
		document.location.href= ServerPath+"/groups/news/news_view_all.php?profile_id="+profile_id; 
	}
	if (valR == 'homepage' ) {
		document.location.href= ServerPath+"/groups/groups_profile.php?profile_id="+profile_id; 
	}

	if (valR == 'Mems' ) {
		document.location.href= ServerPath+"/groups/groupsProfileMembers.php?profile_id="+profile_id; 
	}
}

function callhoPeople( obj, ServerPath ) {
	
	
	//var ServerPath="http://localeyestest.co.uk";
	//var ServerPath="http://192.168.0.5/localeyes_01";
	profile_id = obj;

	varV = "profile_id_"+obj;
	
	valR = document.getElementById(varV).value;
	if(valR == "Groups")
		document.location.href= ServerPath+"/groups/my_profiles.php?action=mygroup&member_id="+profile_id; 
	else
		document.location.href= ServerPath+"/groups/my_profiles.php?action=mygroup&member_id="+profile_id; 
	

}

function Confrim_Removal()
{
		
		var ServerPath="http://localeyestest.co.uk";
		var a=confirm("Are You sure, you want to delete from your member list?");
		
		if(a == true)
			{
				document.location.href = ServerPath+"/groups/groups_search.php?action=mygroup&rem=rem&group_profile_id=<?=$profile_id?>&grpreg_id=<?=$group_registration_id?>";
			}
			else
			{
				
				document.location.href = ServerPath+"/groups/groups_search.php?action=mygroup";
				
			}			
	
}

function chkrated()
{
document.rtFrm.action='commRateTopicsProcess.php';
document.rtFrm.submit();
}

//skills_profile_add_edit.php
function radioSelected(theForm)
{
	// require at least one radio button be selected
var radioSelected = false;
if(theForm.skillfor.length >= 2)
{
for (i = 0;  i < theForm.skillfor.length;  i++)
	{
	if (theForm.skillfor[i].checked)
	
	radioSelected = true;
	
	}
}
else
{	if (theForm.skillfor.checked)
	{
		radioSelected = true;
	}
}

if (!radioSelected)
	{
	alert("Please select skills type.");
	return false;
	
	}


}
//skills_profile_select_categories.php , adding new skil category

/*function validate()
{
  
	var elements ='';
	var elements1 ='';
	for (i = 0; i < document.form1.suggestions.options.length; i++) {
		if(hasSemi(document.form1.suggestions.options(i).value,'suggestions') == false)
		{
			alert("';' are not allowed");
		}
		else
		{	elements += document.form1.suggestions.options(i).value + ';'; 
		}
	}
	document.form1.suggestions.value = elements;
	return true; 
}
*/
function addoption()
{
var selectbox = document.getElementById('suggestions');
var text =  document.getElementById('skill').value;
var value = document.getElementById('skill').value;
var skill = document.getElementById('skill');

	if(value == '')
	{
	 alert("please enter suggestion");
	}
	else if(hasSemi(value,'suggestions') == false)
	{
		alert("';' are not allowed");
	}
	else
	{
		var optn = document.createElement("option");
		optn.text = text;
		optn.value = value;
		optn.selected = true;
		selectbox.options.add(optn);
		skill.value = '';
	}
}
function save_checkbox(id)
{

	document.form1.action = 'groups_select_sub_categories.php';
	document.form1.category_id.value = id;
	document.form1.submit();	
}


/*
 * function that except only number and hypen
 * @param String acceptValue
 * @return Boolean
 */
function acceptNumberAndHypen(acceptValue) {
	//alert(acceptValue);
	var patternString = /^[0-9]+\-+[xzXZ]+?\d+$/;
	 if (patternString.test(acceptValue) == true) {
		return true;    		
	 } else {
        return false;
	 }
}

/*
 * function that except only number 
 * @param String acceptValue
 * @return Boolean
 */
function acceptNumber(acceptValue) {
	var patternString = /^\d+$/;
	 if (patternString.test(acceptValue) == true) {
		return true;    		
	 } else {
        return false;
	 }
}

function groupDetail(id,serverPath) {
	if (id !='') {
		//document.myGroupForm.action=serverPath+"/groups/groups_profile.php?rec=mygroups&profile_id="+profile_id;
		window.location = serverPath+"/groups/groups_profile.php?profile_id="+id;
		//document.myGroupForm.submit();
	}
}

function businessDetail(id,serverPath) {
	if (id !='') {
		//document.myGroupForm.action=serverPath+"/groups/groups_profile.php?rec=business&profile_id="+profile_id;
		window.location = serverPath+"/groups/groups_profile.php?profile_id="+id;
		//document.myGroupForm.submit();
	}
}

function myAccountDetail(id) {
	document.FormRedirect.action=id;
	document.FormRedirect.submit();
}

function openPopup(id) {
	var cmpId = "scrnName_"+id;
	var scrName = jQuery("#"+cmpId).val();
	var hideDivNme = "showhideScrnName_"+id;
	document.getElementById(hideDivNme).style.display='block';
	jQuery("#"+hideDivNme).attr('innerHTML', scrName);
}

function hidePopup(id) {
	var hideDivNme = "showhideScrnName_"+id;
	document.getElementById(hideDivNme).style.display='none';
}

function openPopupRec(id) {
	var hideDivNme = "showhideScrnNamesRec_"+id;
	document.getElementById(hideDivNme).style.display='block';
	var cmpId = "scrnNameRec_"+id;
	var scrName = jQuery("#"+cmpId).val();
	jQuery("#"+hideDivNme).attr('innerHTML', scrName);
}

function hidePopupRec(id) {
	var hideDivNme = "showhideScrnNamesRec_"+id;
	document.getElementById(hideDivNme).style.display='none';
}

function hideBlk(id) {
	document.getElementById(id).style.display='none';
}

function showBlk(id) {
	document.getElementById(id).style.display='block';
}
/* 
 * function for validate top bar jump to content
 * @return Boolean
 */

 function validateJumpContent() {
	 var contentId = $.trim($('#contentId').attr('value'));
		var isCorrect = 0;
		if (contentId == '') {
			alert('Please enter content code.');
			$('#contentId').focus();
			return false;
		}
		var arrContent	 = contentId.split('-');
		var contentType	 = arrContent[0];
		var contentID	 = arrContent[1];
		
		if(contentType=='bu' || contentType=='co' || contentType=='ev' || contentType=='gr' ||contentType=='pe' ||  contentType=='ne' || contentType=='id'|| contentType=='vo'|| contentType=='sk' || contentType=='th' || contentType=='vw' || contentType=='cm'){
			isCorrect = 1;
		}
		var patternString = /^\d+$/;
		 if (patternString.test(contentID) == true) {
			 isCorrect=1;
		 }else{
			isCorrect=0;
		 }
		if(isCorrect==0){
			alert('Please try with valid content code. It seems your content code entered by you is invalid.');
			$('#contentId').focus();
			return false;
		}
	
 }

emailCheck('abc@gamil.com.in.in.in');

function emailTextBoxVal(formName) {
	emailVal = formName.email.value;
	if (emailVal == "enter email or screen name") {
		formName.email.value = '';
	}
	return true;
}

function showhideBlk(id) {
	
	if (document.getElementById(id).style.display=='none') {
		document.getElementById(id).style.display='block';
		if (id == 'MyBusinessesDiv') {
			jQuery("#myBusinessArrow").removeClass("WelcomeBox leftArrow");
			jQuery("#myBusinessArrow").addClass("WelcomeBox rightNavdownArrow");
		}
		if (id == 'MyCouncilDiv') {
			jQuery("#PublicSctrArrow").removeClass("WelcomeBox leftArrow");
			jQuery("#PublicSctrArrow").addClass("WelcomeBox rightNavdownArrow");
		}
		if (id == 'MyGeoGroupsDiv') {
			jQuery("#GeoGrpsArrow").removeClass("WelcomeBox leftArrow");
			jQuery("#GeoGrpsArrow").addClass("WelcomeBox rightNavdownArrow");
		}
		if (id == 'MyGroupsDiv') {
			jQuery("#socialGrpsArrow").removeClass("WelcomeBox leftArrow");
			jQuery("#socialGrpsArrow").addClass("WelcomeBox rightNavdownArrow");
		}

	} else {
		document.getElementById(id).style.display='none';
		if (id == 'MyBusinessesDiv') {
			jQuery("#myBusinessArrow").removeClass("WelcomeBox rightNavdownArrow");
			jQuery("#myBusinessArrow").addClass("WelcomeBox leftArrow");
		}
		if (id == 'MyCouncilDiv') {
			jQuery("#PublicSctrArrow").removeClass("WelcomeBox rightNavdownArrow");
			jQuery("#PublicSctrArrow").addClass("WelcomeBox leftArrow");
		}
		if (id == 'MyGeoGroupsDiv') {
			jQuery("#GeoGrpsArrow").removeClass("WelcomeBox rightNavdownArrow");
			jQuery("#GeoGrpsArrow").addClass("WelcomeBox leftArrow");
		}
		if (id == 'MyGroupsDiv') {
			jQuery("#socialGrpsArrow").removeClass("WelcomeBox rightNavdownArrow");
			jQuery("#socialGrpsArrow").addClass("WelcomeBox leftArrow");
		}
	}
}

function changeImage(img,ids) {
	jQuery(ids).attr("src", img);
}
function revertImage(img,ids) {
	jQuery(ids).attr("src", img);
}
