

function event_view(event_id){
	//alert"hello";
		var url;
	url = "events_pop.asp?event_id="+event_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600,left=100,top=100,modal=no");
}

function award_view(award_id){
	//alert"hello";
		var url;
	url = "awards_pop.asp?award_id="+award_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600,left=100,top=100,modal=no");
}

function wftv_user_view(user_id){
	//alert"hello";
		var url;
	url = "view_members_profile.asp?user_id="+user_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=270,left=100,top=100,modal=no");
}

function calendar_view(){
	//alert"hello";
		var url;
	url = "calendar.html"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=850,height=650,left=100,top=100,modal=no");
}

function user_image_load(id){
		var url;
	url = "user_image_pop.asp?user_id="+id;
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=250,left=200,top=200,modal=yes");
}

function user_image_delete(id){
	var answer;
	answer = confirm('You are about to delete this image - Are you certain ?');
	if (answer !="0")
	{
		var url;
	url = "user_image_delete_pop.asp?user_id="+id;
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=250,left=200,top=200,modal=yes");

	}
}

function industry_news_view(news_id){
	//alert"hello";
		var url;
	url = "industry_news_pop.asp?news_id="+news_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600,left=100,top=100,modal=no");
}


function blogs_view(blog_id){
	//alert"hello";
		var url;
	url = "blogs_pop.asp?blog_id="+blog_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600,left=100,top=100,modal=no");
}

function jobs_board_view(job_id){
	//alert"hello";
		var url;
	url = "jobs_board_pop.asp?job_id="+job_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600,left=100,top=100,modal=no");
}

function classifieds_view(job_id){
	//alert"hello";
		var url;
	url = "classifieds_pop.asp?job_id="+job_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=350,left=100,top=100,modal=no");
}

function offers_view(job_id){
	//alert"hello";
		var url;
	url = "offers_pop.asp?job_id="+job_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600,left=100,top=100,modal=no");
}

function reports_view(report_id){
	//alert"hello";
		var url;
	url = "reports_pop.asp?report_id="+report_id+"&action=search"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600,left=100,top=100,modal=no");
}

function classifieds_post_new(user_id){
	//alert"hello";
		var url;
	url = "classifieds_pop.asp?user_id="+user_id+"&action=new"
	window.open(url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=360,left=100,top=100,modal=no");
}

function submitform(type){
	var intype;
	intype=type
	switch(intype)
		{
		case 'profile_update'://checking for return true on a negative value
		pword_check()
		
		case 'classifieds_pop'://checking for return true on a negative value
		classifieds_pop_submit()
		//case 'admin_staff'://checking for return true on a negative value
			//admin_staff_submit()
		default:
  			//alert("Nout Selected");
		}

}

function classifieds_pop_submit(){
	 	if (document.class_pop.title.value == ""){ 
				alert("You must enter a title!");
				return false;
				
			}
		if (document.class_pop.description.value == ""){ 
				alert("You must enter some text for the description!");
				return false;
			}
			
		else
  			{
			document.class_pop.submit();
			}
}
 

function pword_check()
{
var invalid = " "; // Invalid character is a space
var minLength = 6; // Minimum length
var pw1 = document.getElementById('password').value;
var pw2 = document.getElementById('password_2').value;

// check for minimum length
//if (document.getElementById('password').length < minLength) {
//alert('Your password must be at least ' + minLength + ' characters long. Try again.');
//return false;
//}

if (pw1.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}

// check for a value in both fields.
if (pw1 == '' || pw2 == '') {
alert('Please enter your password twice.');
return false;
}

// check for spaces
if (document.getElementById('password').value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else {
if (pw1 != pw2) {
alert ("You did not enter the same new password twice. Please re-enter your password.");
return false;
}
else {
//alert('Nice job.');
//return true;
profile_update();
      }
   }
}

function profile_update(){
		if (document.form_profile.username.value == ""){ 
				alert("You must enter a username!");
				return false;
			}
	
		if (document.form_profile.email.value == ""){ 
				alert("You must enter an email!");
				return false;
			}

		else
  			{
			document.form_profile.submit();
			}
}



function ValidateRegForm(){
	var emailID=document.RegisterForm.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (reg_echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 
 function reg_echeck(str) {
	
		//var str = document.RegisterForm.email.value
		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 Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			 alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			 alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			 alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
			 alert("Invalid E-mail Address")
		    return false
		 }
		 return true
		 //else
		 //{
 		 	//document.RegisterForm.submit();
		 //}
			
	}
	
function web_member_submit(){
	 	if (document.getElementById('first_name').value == ""){ 
				alert("You must enter a First Name!");
				return false;
				
			}
		if (document.getElementById('surname').value == ""){ 
				alert("You must enter a Surname!");
				return false;
			}
			
		if (document.getElementById('add_1').value == ""){ 
				alert("You must enter an Address!");
				return false;
			}
		if (document.getElementById('postcode').value == ""){ 
				alert("You must enter a Postcode!");
				return false;
			}
		if (document.getElementById('telephone').value == ""){ 
				alert("You must enter a telephone number!");
				return false;
			}
		if (document.getElementById('email_s').value == ""){ 
				alert("You must enter an email address!");
				return false;
			}
		if (document.getElementById('mem_type').value == "not_selected"){ 
				alert("You must select a membership type!");
				return false;
			}
		if (document.getElementById('policy').checked == false){ 
				alert("You must agree to the Terms of Use!");
				return false;
			}
		else
  			{
			document.form_profile.submit();
			}
 }
 
 
 function awards_form_member_submit(){
	 	//if (document.getElementById('first_name').value == ""){ 
				//alert("You must enter a First Name!");
				//return false;
				
			//}
		//if (document.getElementById('surname').value == ""){ 
				//alert("You must enter a Surname!");
				//return false;
			//}
			
		//if (document.getElementById('add_1').value == ""){ 
				//alert("You must enter an Address!");
				//return false;
			//}
		//if (document.getElementById('postcode').value == ""){ 
				//alert("You must enter a Postcode!");
				//return false;
			//}

		if (document.getElementById('afm_name').value == ""){ 
				alert("You must enter a Name!");
				return false;
			}
		else
  			{
			document.awards_m_form.submit();
			}
 } 
 
  function awards_form_corporate_submit(){
	 	//if (document.getElementById('first_name').value == ""){ 
				//alert("You must enter a First Name!");
				//return false;
				
			//}
		//if (document.getElementById('surname').value == ""){ 
				//alert("You must enter a Surname!");
				//return false;
			//}
			
		//if (document.getElementById('add_1').value == ""){ 
				//alert("You must enter an Address!");
				//return false;
			//}
		//if (document.getElementById('postcode').value == ""){ 
				//alert("You must enter a Postcode!");
				//return false;
			//}
		if (document.getElementById('afc_company_name').value == ""){ 
				alert("You must enter a company Name!");
				return false;
			}
		else
  			{
			document.awards_C_form.submit();
			}
 }
 
 
 
function web_renewal_submit(){
	 	if (document.getElementById('first_name').value == ""){ 
				alert("You must enter a First Name!");
				return false;
				
			}
		if (document.getElementById('surname').value == ""){ 
				alert("You must enter a Surname!");
				return false;
			}
		if (document.getElementById('occupation').value == ""){ 
				alert("You must enter an Occupation!");
				return false;
			}
		if (document.getElementById('email_s').value == ""){ 
				alert("You must enter an email address!");
				return false;
			}
		if (document.getElementById('mem_type').value == "not_selected"){ 
				alert("You must select a membership type!");
				return false;
			}

		else
  			{
			document.renewal_profile.submit();
			}
 } 
 

//var myvarnomination="no";
//function checkBoxValidate(form_name, field_name, cb) {
	//alert ("THIS IS: "+form_name+" FOR FIELD: " +field_name+ "AT INDEX: " +cb);
	//var doccy = eval('document.'+form_name+'.'+field_name+'');
	
		   //for (j=0; j < doccy.length; j++) {
		//if (doccy[j].checked==true){
		//doccy[j].checked=false;
		//myvarnomination="no";
			//if (j == cb) {
			//doccy[j].checked=true;
			//myvarnomination="yes";
         //}
      //}
   //}
//}

var myvarnomination="no";
function checkBoxValidate(form_name, field_name, cb) 
{
	//alert ("THIS IS: "+form_name+" FOR FIELD: " +field_name+ "AT INDEX: " +cb);
	var doccy = eval('document.'+form_name+'.'+field_name+'');
	
		   for (j=0; j < doccy.length; j++) 
		   {
			   //alert (j);
				if (j == cb)
				{
					//alert (cb);
					if (doccy[j].checked==true)
					{
					doccy[j].checked=true;
					myvarnomination="yes";
					}
					else
					{
					doccy[j].checked=false;
					myvarnomination="no";	
					}
					//alert ("INTERIM"+ myvarnomination);
      			}
				else
				{
				doccy[j].checked=false;
				//myvarnomination="no";
				}
   			}
	//alert (myvarnomination);
}


function countit(fieldname)
{
	//formcontent=what.form.charcount.value
	//what.form.displaycount.value=formcontent.length
	var formcontent=document.getElementById(fieldname).value.length;
	var my_length = 800;
	var content_dif=formcontent-my_length
	if (formcontent>my_length)
		{
		alert(formcontent + "   characters. You have "+content_dif+" too many. ");
		}
	else 
		{	
		alert(formcontent + "   characters. ");
		}
}

function CountWords (this_field, show_word_count, show_char_count) {
if (show_word_count == null) {
show_word_count = true;
}
if (show_char_count == null) {
show_char_count = false;
}
var char_count = document.getElementById(this_field).value.length;
var fullStr = document.getElementById(this_field).value + " ";

//var char_count = this_field.value.length;
//var fullStr = this_field.value + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;
if (fullStr.length <2) {
word_count = 0;
}
if (word_count == 1) {
wordOrWords = " word";
}
else {
wordOrWords = " words";
}
if (char_count == 1) {
charOrChars = " character";
} else {
charOrChars = " characters";
}
if (show_word_count & show_char_count) {
alert ("Word Count:\n" + "    " + word_count + wordOrWords + "\n" + "    " + char_count + charOrChars);
}
else {
if (show_word_count) {
alert ("Word Count:  " + word_count + wordOrWords);
}
else {
if (show_char_count) {
alert ("Character Count:  " + char_count + charOrChars);
      }
   }
}
return word_count;
}

 
