<!---

function closewindow(){

window.opener.location.reload();
window.close();
	
}

function popUp($url,w,h) {
   mywindow = window.open ($url,"mywindow","location=0,status=0,scrollbars=1,toolbar=0,menubar=0,titlebar=0,width=" + w + ",height=" + h + "");
  mywindow.moveTo(300,200);
 }
 
 function http(field){
 field.value=field.value.replace('http://','');
 } function http(field){
 field.value=field.value.replace('http://','');
 }
 
 function nav(state,id){
	strsrc = element(id).src;
	
	if(state == "on"){
	element(id).src = strsrc.replace('off','on');	
	} else {
	element(id).src = strsrc.replace('on','off');	
	}
	 
	 
 }
 
 /*/
function popUp($url,w,h) {
	var rand = Math.random();
   mywindow = window.open($url,rand,"location=0,status=0,scrollbars=1,toolbar=0,menubar=0,titlebar=0,width=" + w + ",height=" + h + "");
  mywindow.moveTo(300,200);
 }/*/
 function element(id){
	 return document.getElementById(id);
 }
 
 
 function pdf(type,id){
	
element('niframe').src='dl2.php?type='+type+'&id='+id;


}


 function explode(inputstring, separators, includeEmpties) {
	inputstring = new String(inputstring);
	separators = new String(separators);
	
	if(separators == "undefined") {
	separators = " :;";
	}
	
	fixedExplode = new Array(1);
	currentElement = "";
	count = 0;
	
	for(x=0; x < inputstring.length; x++) {
	char = inputstring.charAt(x);
	if(separators.indexOf(char) != -1) {
	if ( ( (includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) { } 
	else {
	fixedExplode[count] = currentElement;
	count++;
	currentElement = ""; } }
	else { currentElement += char; }
	}
	
	if (( ! (includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) {
	fixedExplode[count] = currentElement; } 
	return fixedExplode;
}


function strstr (haystack, needle, bool) {
    // Finds first occurrence of a string within another  
    // 
    // version: 1004.2314
    // discuss at: http://phpjs.org/functions/strstr    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strstr('Kevin van Zonneveld', 'van');
    // *     returns 1: 'van Zonneveld'    // *     example 2: strstr('Kevin van Zonneveld', 'van', true);
    // *     returns 2: 'Kevin '
    // *     example 3: strstr('name@example.com', '@');
    // *     returns 3: '@example.com'
    // *     example 4: strstr('name@example.com', '@', true);    // *     returns 4: 'name'
    var pos = 0;
    
    haystack += '';
    pos = haystack.indexOf( needle );    if (pos == -1) {
        return false;
    } else{
        if (bool){
            return haystack.substr( 0, pos );        } else{
            return haystack.slice( pos );
        }
    }
}


 
 function checkCheckedboxes(theform,prefix){
	var error = ""; 
 var objs =  document.getElementsByTagName('input');
 var text = ""; var  countregarding = 0; var  countfor = 0;
	for(i=0;i<objs.length;i++){
		var names = explode("_",objs[i].name,3);
		  objs[i].type;
		 if(objs[i].type == "checkbox" && objs[i].checked){
			var title = objs[i].name
				var patt1=/Regarding/gi;
				var patt2=/For_/gi;
				//text += title.match(patt1)+"\n";
				
			  if(title.match(patt1) == "Regarding"){ 
		 	 countregarding = count + 1; 
				  }  
			  if(title.match(patt2) == "For_"){ 
		 	 countfor = countfor + 1; 
				  }  
				 
	 	}  
	 }   
	 if(countregarding < 1){
		 error += "Please select at least one Query Category. \n";
	 }
	 if(countfor < 1){
		 error  += "Please select at least one Department for your query. \n";
	 }
	 return error
 }
 
 


 function checkWorkshops(theform,prefix){
	var error = ""; 
 var objs =  document.getElementsByTagName('input');
 var text = ""; var  countregarding = 0;  
	for(i=0;i<objs.length;i++){
		var names = explode("_",objs[i].name,3);
		  objs[i].type;
		 if(objs[i].type == "checkbox" && objs[i].checked){
			var title = objs[i].name
				var patt1=/workshop/gi; 
				//text += title.match(patt1)+"\n";
				
			  if(title.match(patt1) == "workshop"){ 
		 	 countregarding = count + 1; 
				  }   
				 
	 	}  
	 }   
	 if(countregarding < 1){
		 error += "Please select at least one workshop date. \n";
	 }
 
	 return error
 }
 
 
 
function CheckBookings(theform){

var error = "";
/*//*/
error += isBlank(theform.name.value,"Please enter your Name.");
error += checkEmail(theform.email.value,"Please enter a valid Email Address.");
error += isEmptyNum(theform.tel.value,"Please enter a valid Phone Number.");
error += isBlank(theform.practice_name.value,"Please enter your Practice Name.");
error += isBlank(theform.practice_number.value,"Please enter your Practice No.");
error += isBlank(theform.delegates.value,"Please enter the names of your Deletegate(s).");
error += checkWorkshops(theform,'');
if(error != ""){ alert(error); return false; }  // else { return true; }
} 
 
 

function CheckContact(theform){

var error = "";
/*//*/
error += isBlank(theform.name.value,"Please enter your Name");
error += checkEmail(theform.email.value,"Please enter a valid Email Address");
error += isEmptyNum(theform.tel.value,"Please enter a valid Phone Number");
error += isBlank(theform.comments.value,"Please enter your comments or questions");
error += checkCheckedboxes(theform,'');
if(error != ""){ alert(error); return false; }  // else { return true; }
}


function CheckContact2(theform){

var error = "";
/*//*/
error += isBlank(theform.name.value,"Please enter your Full Name.");
error += isBlank(theform.company.value,"Please enter your Company Name.");
error += isEmptyNum(theform.tel.value,"Please enter a valid Phone Number.");
error += checkEmail(theform.email.value,"Please enter a valid Email Address.");
error += isBlank(theform.services_required.value,"Please list the Services you require.");
error += isBlank(theform.project_description.value,"Please describe your Project Requirements.");

if(error != ""){ alert(error); return false; }  // else { return true; }
}

function CheckApp(theform){

var error = "";
/*//*/
error += isBlank(theform.company.value,"Please enter your Company Name.");
error += dropdown(theform.title,"Please choose your Title.");
error += isBlank(theform.name.value,"Please enter your Name.");
error += isBlank(theform.surname.value,"Please enter your Surname.");
error += isBlank(theform.position.value,"Please enter your Position in the company.");
error += isEmptyNum(theform.tel.value,"Please enter a valid Phone Number");
error += checkEmail(theform.email.value,"Please enter a valid Email Address");
error += dropdown(theform.cat,"Please select you Nearest Region.");
error += isBlank(theform.country.value,"Please enter your Country.");
error += isBlank(theform.username.value,"Please enter a Username.");
error += isBlank(theform.password.value,"Please enter a Password.");
error += fieldmatch(theform.password.value,theform.password2.value,"Your passwords do no Match.");

if(error != ""){ alert(error); return false; }  // else { return true; }
}


function over(src,state){
	if(state == "on"){
	document.getElementById(src).src='images/salamanav-over_'+src+'.jpg';	
	}
	if(state == "off"){
	document.getElementById(src).src='images/salamanav_'+src+'.jpg';	
	} 
}
/*/ 
/*/
function ismaxlength(obj){

var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""

if (obj.getAttribute && obj.value.length>mlength)

obj.value=obj.value.substring(0,mlength)

}

 function http(field){
 field.value=field.value.replace('http://','');
 } function http(field){
 field.value=field.value.replace('http://','');
 }
 
 ////////////////
 
 

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
 
function isBlank(str,msg){
	var error = "";
	str = trim(str)
	if(str.length == 0){ error = msg +'\n'; }
	return error;
	}


function fieldmatch(str1,str2,msg){
	var error = "";
	if(str1 != str2){
	error = msg +'\n';
	}
	return error;

}



function checkEmail (strng,msg) {
var error="";
	if (isBlank(strng)) { error = msg + "\n"; }
	
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(strng))) { error = msg + "\n"; }
		else {
		   var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) { error = msg + "\n"; }
		}
	return error;    
}

function isEmptyNum(strng,msg) {
var error = "";
	if (isBlank(strng)) { error = msg + "\n"; } else {
		   var illegalChars= /[\@\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) { error = msg + "\n"; }
		}
	return error;	  
}
function valNum(strng,msg) {
var error = "";
	if(strng.length != 0){
		   var illegalChars= /[\@\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) { error = msg + "\n"; }
	}
	return error;	  
}


function radio(radiobut,strng){
var error = "";
var radio_choice = false;
for (i = 0; i < radiobut.length; i++){
if (radiobut[i].checked)
radio_choice = true; 
}
if (!radio_choice){ error = ""+strng+"\n"; }
return error; }

function dropdown(menu,strng){
var error = "";
 if ( menu.selectedIndex == 0 )
    {
        error = strng+" \n";
        valid = false;
    }
	return error; }
	


function toggleLayer(whichLayer){
if (document.getElementById) {
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = style2.display? "":"block";
}
else if (document.all){
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = style2.display? "":"block";
} else if (document.layers) {
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = style2.display? "":"block"; }
}

function dropother(menu,layer){
 if ( menu.selectedIndex == 1 ){
 	toggleLayer(layer); } else { 	
	if(document.getElementById(layer).style.display == "block"){
 	toggleLayer(layer); } }

}
function strMatch(f1,f2,msg){
var error = "";
 if (f1 != f2){
	 error = msg+"\n";
	 }

}


function linkhit(id){
element('niframe').src  = 'linkhit.php?id='+id; 	
	
}


/*
Rewrite #anchor links for pages with BASE HREF 
*/
function anchorlinks(){
var anchors = document.getElementsByTagName("a"); 
var basehref = document.getElementsByTagName("base")[0].href;
var url = window.location.href;
if(url.indexOf("#") > 0) url = url.substr(0, url.indexOf("#")); //strip hash

if(basehref) {
 for(var i = 0; i < anchors.length; i++) {
  var anchor = anchors[i];

 poundPos = anchor.href.indexOf("#");

 
 if (poundPos > 0) {
   anchor.href = url + "#"+anchor.href.substr(poundPos + 1);
   
  }
 }
}

} 


function validateLoginForm(thForm) {
	enteredHPCSAno = thForm.hpcsa.value.toUpperCase();
	if (enteredHPCSAno == "") {
		alert("You have to supply your HPCSA number to continue.\nPlease try again.");
		thForm.hpcsa.focus();
		return false;
	}
	if (enteredHPCSAno.length > 9) {
		alert("Your HPCSA number is too long. Please enter it in\nthe format explained in the form.");
		thForm.hpcsa.focus();
		return false;		
	}
	if (enteredHPCSAno.length < 9) {
		alert("Your HPCSA number is too short. Please enter it in\nthe format explained in the form.");
		thForm.hpcsa.focus();
		return false;		
	}	
	for (var i = 0; i < enteredHPCSAno.length; i++) {
		if (i < 2) {
			if (enteredHPCSAno.charCodeAt(i) < 65 || enteredHPCSAno.charCodeAt(i) > 90) {
				alert("The first two characters of your HPCSA number must be alphanumeric.\nPlease try again.");
				thForm.hpcsa.focus();
				return false;
			}
		} else {
			if (enteredHPCSAno.charCodeAt(i) < 48 || enteredHPCSAno.charCodeAt(i) > 57) {
				alert("The last seven characters of your HPCSA number must be numeric.\nPlease try again.");
				thForm.hpcsa.focus();
				return false;
			}		
		}
	}
}




/*//*/

-->

