function createRequestObject() {
	var request_o;
	var browser=navigator.appName;
	if(browser=="Microsoft Internet Explorer"){
		request_o=new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o=new XMLHttpRequest();
	}
	return request_o;
}

function correctPNG(){  return false;
	/*check if version is not 7*/
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    if (MSIEOffset == -1) {
        return 0;
    } else {
        var verno = parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
		if(verno>=7)return 0;
		for(var i=0; i<document.images.length; i++) {
			var img = document.images[i];
			var imgName = img.src.toUpperCase();
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText;
				if (img.align == "left") imgStyle = "float:left;" + imgStyle;
				if (img.align == "right") imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='scale');\"><\/span>";
				img.outerHTML = strNewHTML;
				i = i-1;
			}
		}
	}
}

if(navigator.appVersion.indexOf("MSIE") != -1) {
	window.attachEvent("onload", correctPNG);
}

var timeoutRun;

function shownavhelp(navtype) {
	clearTimeout(timeoutRun);
	var helpnav = document.getElementById('helpdiv');
	var helpinfo = '';
	if (navtype == '1') { helpinfo = helpinfo+'Click this link to search for practices listed on practice4sale.com.au.  You must be logged in to see the results, so join today for FREE.'; }
	if (navtype == '2') { helpinfo = helpinfo+'Click this link to list your practice on this site.  You must be a registered member to list.'; }
	if (navtype == '3') { helpinfo = helpinfo+'Click this link to search for jobs listed on practice4sale.com.au.  It\'s free to search, so start searching now.'; }
	if (navtype == '4') { helpinfo = helpinfo+'Click this link to register a job position with us.  You must be registered and logged in to access this section.  Sign-up for free today.'; }
	helpnav.innerHTML = helpinfo;
}

function hidenavhelp() {
	timeoutRun = setTimeout("document.getElementById('helpdiv').innerHTML = '&nbsp;'",'1000');
}
var medicisites={
	relocate:function(){
		var siteURL=document.getElementById('siteURL').options[document.getElementById('siteURL').selectedIndex].value;
		var isok=confirm('You will now be transferred to your selected Practice4Sale affiliate website ('+siteURL+'). Click OK to confirm the transfer, or CANCEL to stay on Practice4Sale.');
		if(isok){
			window.location=siteURL;
		}
	}
}
var menu={
	showHide:function(obj){
		var bgimg=obj.firstChild.style.backgroundImage;
		obj.firstChild.style.backgroundImage=((bgimg==''&&(obj.className.indexOf('alt')<=0))||(bgimg.indexOf('min')>0))?'url(/images/p4s/search_box_max.gif)':'url(/images/p4s/search_box_min.gif)';
		obj.firstChild.style.backgroundPosition='center left';
		document.getElementById(obj.id+'Sub').style.display=((bgimg==''&&(obj.className.indexOf('alt')<=0))||(bgimg.indexOf('min')>0))?'none':'block';
	}
}
var tab={
	//show tab
	show:function(item){
		var divs=document.getElementById('tabable').childNodes;
		var tabs=document.getElementById('tabs').getElementsByTagName('ul')[0].getElementsByTagName('li');
		for(var i=0;i<divs.length;i++){
			if(divs[i].tagName=='DIV'&&divs[i].parentNode.id=='tabable')
				divs[i].className=((item+'Div')==divs[i].id)?'visible':'hide';
		}
		for(var i=0;i<tabs.length;i++){
				tabs[i].className=(item==tabs[i].firstChild.id)?'visible':'hide';
				tabs[i].firstChild.className=((item)==tabs[i].firstChild.id)?'visible':'hide';
			}
		return false;
	}
}
var aumap={
	//australian map
	swapMap:function(state){
		var map=document.getElementById('map');
		map.src=map.src.replace(/[a-z]+\.gif/g, state+".gif");
	},
	restoreMap:function(){
		aumap.swapMap('aus');
	}

}
function swapImage(obj){
		document.getElementById('imageWindow').getElementsByTagName('IMG')[0].src=obj.src;
}
function clearhistory(){
	var http=createRequestObject();
	http.open('get','/practice/?action=clearhistory');
	http.onreadystatechange=function(){
		http.readyState==4?document.getElementById('recentlyviewed').innerHTML='<table><tr><td><img alt="Error" src="/images/icons/error.png" /></td><td class="error">Practice History cleared</td></tr></table>':'';
	}
	http.send(null);
}
