/* Add by Ken on 2009-06-17 */
function displayOther(element, type, div, value)
{
	var divShow = document.getElementById(div);
	
	if(type == "option")
	{
		if(element.value == value)
			divShow.style.display = "block";
		else
			divShow.style.display = "none";
	}
				
	if(type == "checkbox")
	{
	
		if(element.checked == true)
			divShow.style.display = "block";
		else
			divShow.style.display = "none";
	}
}

function matchHeight() {
	
	// match content div height to nav or tools div, whichever is higher
	var navH = (parseInt(document.getElementById("nav").offsetHeight) - 257);
	var rhsH = (parseInt(document.getElementById("tools_wrap").offsetHeight) - 31);
	var conH = parseInt(document.getElementById("content_mid").offsetHeight);
	
	if(navH > rhsH) {
		useHeight = navH;
	}
	else {
		useHeight = rhsH;
	}
	
	if(conH < useHeight) {
		document.getElementById("content_mid").style.height = useHeight + "px";
	}
	
	// Show back to top if needed
	var y;
	if (self.innerHeight) {
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		y = document.documentElement.clientHeight;
	}
	else if (document.body) {
		y = document.body.clientHeight;
	}
	
	if((conH+150) > y && document.getElementById("bttop")) {
		document.getElementById("bttop").style.display = "block";
	} else if(document.getElementById("bttop")) {
		document.getElementById("bttop").style.display = "none";
	}
}

function ixRollovers() {
	// stk 02/2007
	var ixImgSuffix = "-over";
	var ixPreload = new Object();
	var ixImagesOff = new Array();
	var ixImagesOvr = new Array();
	var docImages = document.getElementsByTagName("*");
	
	for(var i=0; i<docImages.length; i++) {
		if(docImages[i].getAttribute("ixrollover")) {
			var imgSplit = docImages[i].src.split(".");
			imgSplit[((imgSplit.length)-2)] = imgSplit[((imgSplit.length)-2)] + ixImgSuffix;
			
			ixImagesOff[docImages[i].id] = docImages[i].src;
			ixImagesOvr[docImages[i].id] = imgSplit.join(".");
			ixPreload[docImages[i].id] = new Image();
			ixPreload[docImages[i].id].src = imgSplit.join(".");
			
			docImages[i].onmouseover = function() {
				this.src = ixImagesOvr[this.id];
			}
			
			docImages[i].onmouseout = function() {
				this.src = ixImagesOff[this.id];	
			}
		}
	}
}

function jumpTo(strURL) {
	if(strURL.length > 0) {
		window.location = strURL;
	}
}

function pdfLinks() {
	var allHref = document.getElementsByTagName("a");
	for(var i=0; i<allHref.length; i++) {
		if(allHref[i].href.indexOf(".pdf") > -1 && allHref[i].target != "pdf") {
			allHref[i].setAttribute("target", "pdf");
		}
	}
}

function bodyOnLoad() {
	ixRollovers();
	pdfLinks();
}
function changeme(id, action) {
       if (action=="show") {
            document.getElementById(id).style.visibility = "visible";
       }
       else if (action=="hide") {
            document.getElementById(id).style.visibility = "hidden"; 
       }
       else {
            document.getElementById(id).style.visibility = "hidden";
       }
}
function toggleEnquirySubjects(strVal) {
	
	var subjects = document.getElementById("EnquirySubject");
	subjects.options.length = 0;
	
	if(strVal != "") {		
		switch(strVal) {
			default:
				var opt = new Array("","Item tracking enquiry","Wish to become a contract customer","Product enquiry","Technical enquiry","Site comment","Complaints or compliments","Other");
			break;
			
			case "Other":
				var opt = new Array("","Wish to become a contract customer","Product enquiry","Technical enquiry","Site comment","Complaints or compliments","Other");
			break;
		}
		
		subjects.options[0] = new Option("Select","")
		for(var i=1; i<opt.length; i++) {
			subjects.options[i] = new Option(opt[i],opt[i])
		}
	}
}

function printPage() {
	var thisDoc = window.location + "";
	thisDoc = thisDoc.split("#");
	var popUpWin = open(thisDoc[0] + '?printPage=true', 'print_page', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+600+',height='+800+',left=50, top=50,screenX=50,screenY=50');
}

function playVideo(vpath) {
	var popUpWin = open('../../resources/flv/player.asp?vpath='+vpath, 'print_page', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+480+',height='+310+',left=100, top=100,screenX=100,screenY=100');
}

