function changevalidateimage() {
	document.validateimage.src='/genCaptcha.cfm';
}

function viewimage(URL,productid) {
	var newwinwidth = 650;
	var newwinheight = 650;
	window.open(URL+'pop_viewimage.cfm?action=pop&productid=' + productid, "ViewPhoto", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=" +newwinwidth+",height=" +newwinheight+",top=0,left=0");
	}	

var _d = document;
function showTab(tab) {
 var tb=lt.id.substring(1); // pull out previous number
 ta=tab.id.substring(1); // pull out the current number
 lt.className='tabtextover'; // change previous to class o
 tab.className='tabtextover';
 lt=tab;

 // display table
 _d.getElementById('s'+tb).style.display="none";
 _d.getElementById('s'+ta).style.display="block";
 _d.getElementById('m'+ta).className='tabtextover';
  _d.getElementById('m'+tb).className='tabtext';
}

// toggle visibility code

function toggle(obj) {
 var el = document.getElementById(obj);
 el.style.display = (el.style.display != 'none' ? 'none' : '');
}

var browserName = navigator.appName;
		var browserVer = parseInt(navigator.appVersion);
		var version = "";
		var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
		if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
			// Blurring links:
		function blurLink(theObject)	{	//
			if (msie4)	{theObject.blur();}
		}


// disable right click
function click() {
if (event.button==2) {
alert('Sorry, this function is disabled.')
}
}
document.onMouseDown=click

// Contact Us Form Validation
	function contactsubmit()
	
	{
		if (FRMSubmit.contact_name.value == '')
		{
			alert("Please enter your name");
			FRMSubmit.contact_name.focus();
			return false;
		}
		if (FRMSubmit.contact_Email.value == '')
		{
			alert("Please enter your email address");
			FRMSubmit.contact_Email.focus();
			return false;
		}			
		if (FRMSubmit.contact_subject.value == '')
		{
			alert("Please enter a subject");
			FRMSubmit.contact_subject.focus();
			return false;
		}
		if (FRMSubmit.contact_comments.value == '')
		{
			alert("Please enter the message.");
			FRMSubmit.contact_comments.focus();
			return false;
		}
		
	return true;
	}

// search form validation
function searchsubmit() {
	if (FRMsearch.keyword.value == '')
		{
			alert("Please enter a keyword to search for");
			FRMsearch.keyword.focus();
			return false;
		}
}

// Extranet Login Form Validation
	function extranetloginsubmit()
	
	{
		if (FRMLogin.user_email.value == '')
		{
			alert("Please enter your username");
			FRMLogin.user_email.focus();
			return false;
		}
		if (FRMLogin.user_password.value == '')
		{
			alert("Please enter your password");
			FRMLogin.user_password.focus();
			return false;
		}
		
	return true;
	}

	function leftloginsubmit()
	
	{
		if (FRMLeftLogin.user_email.value == '')
		{
			alert("Please enter your username");
			FRMLeftLogin.user_email.focus();
			return false;
		}
		if (FRMLeftLogin.user_password.value == '')
		{
			alert("Please enter your password");
			FRMLeftLogin.user_password.focus();
			return false;
		}
		
	return true;
	}

// Email Password Form Validation
	
	function passreqsubmit()
	
	{
		if (FRMPasswordReq.email.value == '')
		{
			alert("Please enter your email address");
			FRMPasswordReq.email.focus();
			return false;
		}
		
	return true;
	}	
	
// Extranet Registration Form Validation
	function extranetregistrationsubmit()
	{	
			
		if (FRMRegister.Fname.value == '')
		{
			alert("Please enter your first name");
			FRMRegister.Fname.focus();
			return false;
		}
		if (FRMRegister.Sname.value == '')
		{
			alert("Please enter your surname");
			FRMRegister.Sname.focus();
			return false;
		}
		if (FRMRegister.nzmn.value == '')
		{
			alert("Please enter your NZ Medical Number");
			FRMRegister.nzmn.focus();
			return false;
		}		
		
		//basic email address syntax validation
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(FRMRegister.email.value) == false) {
			alert("Invalid E-mail Address! Please re-enter.");
			return false;
		}
		
		if (FRMRegister.companyname.value == '')
		{
			alert("Please enter your Practice name");
			FRMRegister.companyname.focus();
			return false;
		}	
		if (FRMRegister.address1.value == '')
		{
			alert("Please enter your address");
			FRMRegister.address1.focus();
			return false;
		}			
		if (FRMRegister.city.value == '')
		{
			alert("Please enter your city");
			FRMRegister.city.focus();
			return false;
		}					
				
		if (FRMRegister.user_password.value == '')
		{
			alert("Please enter your password")
			FRMRegister.user_password.focus();
			return false;
		}
		
		if (FRMRegister.user_password.value.length < 3) {
			alert("Please enter a password that is more than 3 characters long.")
			FRMRegister.user_password.focus();
			return false;
		}
		if (FRMRegister.user_password_confirm.value == '')
		{
			alert("Please enter your password confirmation");
			FRMRegister.user_password_confirm.focus();
			return false;
		}
		if (FRMRegister.user_password.value != FRMRegister.user_password_confirm.value  ) {
			alert("Your password and password confirmation do not match.\nPlease make sure your password and password confirmation are the same");
			FRMRegister.user_password_confirm.focus();
			return false;
		}
		if (FRMRegister.disclaimer.checked == false) {
			alert("You must accpet the site Terms & Conditions to proceed.");
			FRMRegister.disclaimer.focus();
			return false;
		}		
		
	return true;
	}

// Extranet Registration Form Validation
	function extranetregistrationupdate()
	{	
			
		if (FRMRegister.Fname.value == '')
		{
			alert("Please enter your first name");
			FRMRegister.Fname.focus();
			return false;
		}
		if (FRMRegister.Sname.value == '')
		{
			alert("Please enter your surname");
			FRMRegister.Sname.focus();
			return false;
		}
		if (FRMRegister.nzmn.value == '')
		{
			alert("Please enter your NZ Medical Number");
			FRMRegister.nzmn.focus();
			return false;
		}		
		
		//basic email address syntax validation
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(FRMRegister.email.value) == false) {
			alert("Invalid E-mail Address! Please re-enter.");
			return false;
		}
		
		if (FRMRegister.companyname.value == '')
		{
			alert("Please enter your Practice name");
			FRMRegister.companyname.focus();
			return false;
		}	
		if (FRMRegister.address1.value == '')
		{
			alert("Please enter your address");
			FRMRegister.address1.focus();
			return false;
		}			
		if (FRMRegister.city.value == '')
		{
			alert("Please enter your city");
			FRMRegister.city.focus();
			return false;
		}					
				
		if (FRMRegister.user_password.value == '')
		{
			alert("Please enter your password")
			FRMRegister.user_password.focus();
			return false;
		}
		
		if (FRMRegister.user_password.value.length < 3) {
			alert("Please enter a password that is more than 3 characters long.")
			FRMRegister.user_password.focus();
			return false;
		}
		if (FRMRegister.disclaimer.checked == false) {
			alert("You must accpet the site Terms & Conditions to proceed.");
			FRMRegister.disclaimer.focus();
			return false;
		}		
		
	return true;
	}	
	
//Standard Functions
function open_new(url) {
	new_win = window.open(url,"new_win",'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1');
	}			
function open_email(url) {
	new_email = window.open(url,"new_email",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, width=450, height=500');
	}
function open_print(url) {
	new_print = window.open(url,"new_print",'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, width=630, height=600');
	}	
	
// navigation
function sendToPage(toLocation) {
	if (toLocation != "")
		top.location.href=toLocation;
	}

// open view photo window

function viewphoto (photoid,winwidth,winheight,viewthumb) {
	var TheUrl = siteurl;
	var newwinwidth = winwidth + 30;
	var newwinheight = winheight + 30;
	//alert (viewthumb);
	if (viewthumb == 1) {
		window.open(TheUrl + 'pop_viewphoto.cfm?photoid=' + photoid+'&viewthumb=yes', "ViewPhoto", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=" +newwinwidth+",height=" +newwinheight+",top=0,left=0");
	}
	else {
		window.open(TheUrl + 'pop_viewphoto.cfm?photoid=' + photoid, "ViewPhoto", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=" +newwinwidth+",height=" +newwinheight+",top=0,left=0");
	}
}

// open view photo window

function viewslideshow (photoid,winwidth,winheight,categoryid,viewthumb) {
	
	var TheUrl = siteurl;
	var newwinwidth = winwidth + 50;
	var newwinheight = winheight + 50;
	//alert (TheUrl);
	if (viewthumb == 1) {
		window.open(TheUrl + 'pop_viewslideshow.cfm?photoid=' + photoid+'&categoryid='+categoryid+'&viewthumb=yes', "ViewPhoto", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=" +newwinwidth+",height=" +newwinheight+",top=0,left=0");
	}
	else {
		window.open(TheUrl + 'pop_viewslideshow.cfm?photoid=' + photoid+'&categoryid='+categoryid, "ViewPhoto", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=" +newwinwidth+",height=" +newwinheight+",top=0,left=0");
	}
}

//existing site functions
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



// Global variables

var cookieQueries = new Array();
var isKonqueror = (navigator.vendor == 'KDE')
var isIE6 = ((window.ActiveXObject && !window.XMLHttpRequest) ? true : false);
var adHiders = [false, false, false]; // First element: Search suggestions, second: Browse categories menu, third: Community menu
var _nameidx, _lastbold; // Variables used to make new torrents on the today page bold


// Calculate real offset values of elements

function realOffset(el, offsetType) {

 var offset = 0;

 while(el) {
  offset += el[offsetType]; 
  el = el.offsetParent;
 }

 return offset;

}


// Array.indexOf fix

if(!Array.indexOf) {
 Array.prototype.indexOf = function(elValue) {

  for(var i=0; i<this.length; i++) {
   if(this[i] === elValue)
    return i;
  }

  return -1;

 };
}


// XMLHttpRequest fix for Internet Explorer

if(!window.XMLHttpRequest) {
 window.XMLHttpRequest = function() {
  var types = [
   'Microsoft.XMLHTTP',
   'MSXML2.XMLHTTP.5.0',
   'MSXML2.XMLHTTP.4.0',
   'MSXML2.XMLHTTP.3.0',
   'MSXML2.XMLHTTP'
  ];

  for(var i = 0; i < types.length; i++) {
   try {
    return new ActiveXObject(types[i]);
   } catch(e) {}
  }

  return false; // XMLHttpRequest not supported
 };
}


function updateAd() { // Checks if the top advertisement should be hidden or visible
 var ad = document.getElementById('adspot-a');

 if(ad != null) {
  if(adHiders[0] || adHiders[1] || adHiders[2])
   ad.style.visibility = 'hidden';
  else
   ad.style.visibility = 'visible';
 }
}