function navigation(){
	
	//highlight relevant links
	if(window.nav && document.getElementById("nav-" + nav)){
		document.getElementById("nav-" + nav).className = "on";
	}
	if(window.sub_nav && document.getElementById("sub-nav-" + sub_nav)){
		document.getElementById("sub-nav-" + sub_nav).className = "on";
	}

}



navHighlight = function(){
	if(window.section && document.getElementById("nav-" + section)){
		document.getElementById("nav-" + section).className = "on";
	}
	if(window.sub_nav && document.getElementById("sub-nav-" + sub_nav)){
		document.getElementById("sub-nav-" + sub_nav).className = "on";
	}
}

function winOpen(theURL,name,width,height,status,resize,scrollbars){
	features = "width=" + width + ",height=" + height + ",status=" + status + ",resizable=" + resize + ",scrollbars=" + scrollbars;
	//alert(features);
	window.open(theURL,name,features);
}

function confirmSubmit(message){
	var send_me = confirm(message);
	if (send_me){
		return true;
	} else {
		return false;
	}
}


function discardId(id)	{
    
	var whichId = new Array();
	//alert(document.f1.discarded.value);
	
	
	if(!id)
	{
	 var newstr = document.f1.discarded.value
	 	if (newstr)
	 	{
	 	 whichId = newstr.split(',');
		}
	}
	else
	{
	 whichId[0] = id;
	 
			 if (document.f1.discarded.value == "")
			{
			 document.f1.discarded.value = whichId[0];
			}
			else
			{
			 document.f1.discarded.value +=  "," + whichId[0];
			}
	 
	 
	}
	
 
	//alert(document.f1.discarded.value);
	
    

	

	var len = whichId.length;
	 
		for(i=0;i<len;i++)
		{
		 var whichDiv = "alldetails" + whichId[i];
		        if(document.getElementById(whichDiv) )
				{
		 		document.getElementById(whichDiv).style.display = "none";
				}
		}

	

}
/*------------------------------------------------------------------------------
  cookie functions
------------------------------------------------------------------------------*/

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}


/* MENU FUNCTIONS */
function changeBullet(action,menu,imgid) {
	var img_source = '/images/' + menu + 'menu_item_bullet' + action + '.gif'
	var img_id = 'menu_item_bullet_' + imgid;
	document.getElementById(img_id).src = img_source;
}
function tabReact(tabID,action){
		document.getElementById(tabID).className = "tab" + action;
}
/* FORM FUNCTIONS */
function disableForm(form) {
	//Disables the submit buttons when a form is submitted
	if (document.all || document.getElementById) {
		
		for (i = 0; i < form.length; i++) {
		
			var tempobj = form.elements[i];
			//alert(tempobj.name);
			if (tempobj.name.toLowerCase() == "submit"){
				tempobj.disabled = true;
			}
		}
	}
	return true;
}
function confirmCancel(){
	var unsub =	confirm('Are you sure that you want to unsubscribe from SAP Professionals?\n\nClicking OK will completely erase all of your details.');
	if (unsub){
		return true;
	} else {
		return false;
	}
}
function confirmSubmit(message){
	var send_me = confirm(message);
	if (send_me){
		return true;
	} else {
		return false;
	}
}

/* *************** */


function view_details(target){
	//alert(target);
	window.location = target;
}

function openDetails(auth_id,details,use_credits,doc_name){
			features = "width=750px,height=450px,resizable=yes,scrollbars=yes";
			//alert(features);
			
			var loadingUrl = "/content/loading.shtml";
				if(details=="reg"){
					var theUrl = "/cgi/cims/client_search.pl?view_details=" + auth_id;
				}else if(details=="cv" || details=="cv2"){
					var theUrl = "/cgi/cims/client_search.pl?view_cv=" + auth_id;
					//var theUrl = "/clients/view-cv/" + doc_name;
					//alert(theUrl);
				}else if(details=="con" || details=="con2"){
					var theUrl = "/cgi/cims/client_search.pl?view_contact_details=" + auth_id;
				}
			//var newWin = "newWin";
			var newWin = auth_id; //open in unique window so can compare consultants
			var message = "Are you sure you want to purchase this Consultant's contact details? \n\nYour account will be deducted 1 credit";
			var noCredit = "Unfortunately you do not have enough credits to purchase \nthis Consultant's contact details. \n\nPlease contact us to top-up your account";
			
			var use_credits_field;
			
			var current_credits;
			
			 
			
			if(details=="con2" || (details=="cv2" && window.opener && !window.opener.closed ) )
			{
				currentCredits = window.opener.credits_left - 0;
				use_credits_field = eval("window.opener.document.f1.use_credits_" + auth_id);
				
			} 
			
			else 
			{
				currentCredits = credits_left - 0;
				use_credits_field = eval("document.f1.use_credits_" + auth_id);
			}
			
			//alert(currentCredits);
			
			var use_credits_field_val = use_credits_field.value;

	if(details=="reg" || details=="cv" || details=="cv2")
	{
		var detailsWin = window.open(loadingUrl,newWin,features); //load loading page
		detailsWin = window.open(theUrl,newWin,features); //load real page
		detailsWin.focus(); //set focus
	} else {
	  
	
		//check credits
		if(currentCredits <= 0 || currentCredits == ''){
			alert(noCredit);
		} else {
			if(details=="con"){
				 
				if (use_credits && use_credits_field_val)
				{
					
						
						 var detailsWin = window.open(loadingUrl,newWin,features); //load loading page
						 var ok = confirm(message);
							if(ok) {
								detailsWin = window.open(theUrl,newWin,features); //load real page
								var newTotal = credits_left - 1;
								 
						 		//document.getElementById('credits').innerHTML = newTotal;
						 		credits_left = newTotal;
								use_credits_field.value = "";
								var imgid = "contact_details_img_" + auth_id;
								//document.getElementById(imgid).src = "/images/client_bought_contact_details.gif";
								//document.getElementById(imgid).alt = "Contact Details";
								 detailsWin.focus(); //set focus
							} else {
								detailsWin.close();
							}
						
				}
				else
				{
						var detailsWin = window.open(loadingUrl,newWin,features); //load loading page
						detailsWin = window.open(theUrl,newWin,features); //load real page
						detailsWin.focus(); //set focus
				}
					 
			} else if(details=="con2"){
			
				if(use_credits && use_credits_field_val)
			     {
				 
				  var ok2 = confirm(message);
					if(ok2)
					{	
						 
						var newTotal = window.opener.credits_left - 1;
						 
						window.opener.document.getElementById('credits').innerHTML = newTotal;
						window.opener.credits_left = newTotal;
						 
						use_credits_field.value = "";
						var imgid = "contact_details_img_" + auth_id;
						window.opener.document.getElementById(imgid).src = "/images/client_bought_contact_details.gif";
						document.getElementById(imgid).src = "/images/client_bought_contact_details.gif";
						window.opener.document.getElementById(imgid).alt = "Contact Details"
						this.window.location = theUrl; //redirect the window
					}
				 
				 }
				 else
				 {
				 
				    
						//window.opener.credits_left = newTotal;
						this.window.location = theUrl; //redirect the window
				 
				 }	
			
				
			}
		}
	}
}

function job_over(id,react,results){
	var row = "job" + id;
	var title = "title" + id;
	var salary = "salary" + id;
	var type = "type" + id;
	var location = "location" + id;
		if(react == 'over'){
			var react_class = 'job_highlight';
		} else {
			var react_class = 'job_out';
		} 
	document.getElementById(title).className = react_class;
	document.getElementById(type).className = react_class;
	document.getElementById(location).className = react_class;
	
	if(results == true){
		document.getElementById(salary).className = react_class;
	} else {
		document.getElementById(row).className = react_class;
	}

}


var browser=navigator.appName
var is_ie;
if (browser=="Netscape"||browser=="Microsoft Internet Explorer")
{
 is_ie = 1;
}

function spawn(url)	{
  
 
  
var features = "width=750px,height=440px,resizable=yes,scrollbars=yes,toolbar=no,menubar=no";
 
var windowName = "newWindow";
 
 
var detailsWin = window.open(url,windowName,features);
 
  
  
  
  }
