﻿/* dom constructor */
function getRef(id) {
		return (document.getElementById ? document.getElementById(id) : document.all[id]);
}

var currentFlyout;
var currentHover;

function showFlyout(elm, flyOutId, topPos, leftPos)
{
    if(currentFlyout){
        hideFlyout();
    }
    if(navigator.appName == "Netscape")
    {
        topPos += 14;
        leftPos -= 250;
    }
    currentFlyout = document.getElementById(flyOutId);
    currentFlyout.style.display = 'block';
    setLyr(elm, topPos, leftPos);
}

function setLyr(obj,topPos, leftPos)
{
    var coors = findPos(obj, topPos, leftPos);
    currentFlyout.style.top = coors[1] + 'px';
    currentFlyout.style.left = coors[0] + 'px';
}

function findPos(obj,topPos,leftPos)
{
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
	        curleft += obj.offsetLeft + leftPos;
	       // curleft +=;
	        curtop += obj.offsetTop + topPos;
        }
    }
    return [curleft,curtop];
}

function hideFlyout()
{
    currentFlyout.style.display = 'none';
}

function productCatalogueImageRoll(div, img, iSrc, clsName) //div (id of the containing div), img (id of img), iSrc (src of new image), clsName (class name of div hover)
{
    img = document.getElementById(img);
    div = document.getElementById(div);
    img.src = iSrc;
    div.className = clsName;
}

function showTab(div)
{
    document.getElementById('divOverview').className = 'notabdiv';
    if (document.getElementById('divFeatures') != null) document.getElementById('divFeatures').className = 'notabdiv';
    if (document.getElementById('divStandard') != null) document.getElementById('divStandard').className = 'notabdiv';
    if (document.getElementById('divOptional') != null) document.getElementById('divOptional').className = 'notabdiv';
    document.getElementById('divWorkTools').className = 'notabdiv';
    document.getElementById(div).className = 'tabdiv';
}

function tabStyle(li)
{
    var tabNav = document.getElementById('tab').getElementsByTagName('li');
    for(var i=0; i < tabNav.length; i++)
    {
        tabNav[i].className = 'unselected';
    }
    li.className = 'selected';
}

function clearSearchBox(elm)
{
    if(elm.value == "Search The Cat Rental Store")
    {
        elm.value = "";
    }   
}

/* returns the value of the specified query string */
function getQueryString(theStr) {
	var strTmp = window.location.search;
	var strStart = strTmp.indexOf(theStr);
	var result = "";
	if (strStart != -1) {
		var strEnd = strTmp.indexOf("&",strStart+theStr.length+1);
		if (strEnd != -1) {
			result = strTmp.substring(strStart+theStr.length+1, strEnd);
		}
		else {
			result = strTmp.substring(strStart+theStr.length+1, strTmp.length);
		}
	}
	return result;
}

/* sets a divs display to block */
function showBlock(id) {
	var theDiv = getRef(id);
	theDiv.style.display = "block";
}
/* sets a divs display to none  */
function hideBlock(id) {
	var theDiv = getRef(id);
	theDiv.style.display = "none";
}