
var menuTimeout = 0;

String.prototype.ReplaceMultiple = function(searchstr, replacestr) {
	var str = this;
	while ( str.indexOf(searchstr) >= 0 ) {
		str = str.replace(searchstr, replacestr);
	}
	return str;
};

function popWindow(url, winWidth, winHeight) {
	childWindow = window.open(url, '_blank', 'resizeable=no,width='+winWidth+',height='+winHeight+',scrollbars=yes');
	if ( childWindow.opener == null ) {
		childWindow.opener = self;
	}
}

// show some elements, hide others
function showHide(elName) {
	document.getElementById('features').style.display='none';
	document.getElementById('requirements').style.display='none';
	document.getElementById('warranty').style.display='none';
	document.getElementById(elName).style.display='';
}

// switch the picture out
function switchPic(elName, newsrc) {
	//document.images[elName].src = '/images/loading_image.gif';
	document.images[elName].src = newsrc;
}

function setHTML(elName, txtHTML) {
	document.getElementById(elName).innerHTML=txtHTML;
}

function showDiv(elName) {
	document.getElementById(elName).style.display='block';
	void(0);
}

function hideDiv(elName) {
	document.getElementById(elName).style.display='none';
	void(0);
}

function showElement(elName) {
	document.getElementById('menuadmin').style.display='none';
	document.getElementById('menupwclift').style.display='none';
	document.getElementById('menuboatlift').style.display='none';
	document.getElementById('menudockproducts').style.display='none';
	document.getElementById(elName).style.display='block';
	//menuTimeout = setTimeout("hideElement('"+elName+"')", 2000);
	
}

function hideElement(elName) {
	document.getElementById('menuadmin').style.display='none';
	document.getElementById('menupwclift').style.display='none';
	document.getElementById('menuboatlift').style.display='none';
	document.getElementById('menudockproducts').style.display='none';
	if ( elName != '' ) {
		document.getElementById(elName).style.display='none';
	}
}

/*function lPop(popname, imgname, poptitle, popimg) {
	popDiv = document.createElement("div");
	popDiv.id = 'pop_'+popname;
	popDiv.className = 'popup';
	
	popTitleDiv = document.createElement("div");
	popTitleDiv.className = "desc";
	popTitleDiv.innerText = poptitle;
	popDiv.appendChild(popTitleDiv);
	
	popNavDiv = document.createElement("div");
	popNavDiv.className = "nav";
	
	popNav = document.createElement("a");
	popNav.href = 'javascript:hideDiv(\'pop_'+popname+'\');';
	popNavText = document.createTextNode('[X]');
	popNav.appendChild(popNavText);
	
	popNavDiv.appendChild(popNav);
	popDiv.appendChild(popNavDiv);
	
	popImage = document.createElement("img");
	popImage.id = 'popimg_'+popname;
	popImage.src = popimg;
	popDiv.appendChild(popImage);
	
	void(0);
	
}*/

function subShopBasicPopOpen(elName,picName,popPicName) {
	var el;
	var leftpos;
	var picleftpos;

	el = document.getElementById(elName);
	pic = document.getElementById(picName);
	el.style.display='inline';
	leftpos = findPos(el);
	picleftpos = findPos(pic);
	if ( leftpos > 700 ) {
		//el.style.left = picleftpos - document.getElementById(popPicName).width - 10;
		//el.left = picleftpos - document.getElementById(popPicName).width - 10;
		el.style.left = picleftpos - 315;
		el.left = picleftpos - 315;
	}
}

function subShopBasicPopClose(elName) {
	var el;

	el = document.getElementById(elName);
	el.style.display='none';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	} else {
		curleft = obj.left;
	}
	return curleft;
}

function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}

function prdrop(elName) {
    document.getElementById(elName).style.display='block';
    if ( document.all ) {
	document.getElementById(elName).style.left = (document.body.offsetWidth - 350) + 'px';
    } else {
	document.getElementById(elName).style.left = (window.innerWidth - 350) + 'px';
    }
}

function prdrophide(elName) {
	document.getElementById(elName).style.display='none';
}

function pagePicPopup(popimg,caption) {
	window.open('/popup_picture.php?src='+escape(popimg)+'&caption='+escape(caption),'_blank','width=850,height=625,scrollbars');
	void(0);
}

function lSetup()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  return xmlHttp;
}

lXmlHttp = lSetup();

function lReq() {
	var myp = escape(document.location.href);
	lXmlHttp.open("GET", "/bi/l.php?p="+myp, true);
	lXmlHttp.send(null);
}

if ( lXmlHttp != false ) {
	// setup timer here
	lXmlHttp.onreadystatechange = function() { }
	
}