
// TREE TOGGLER

function doBranch(node) {

	if(node.parentNode.className == "closed") {
		node.parentNode.className = "open";
	}
	
	else if (node.parentNode.className == "open") {
		node.parentNode.className = "closed";
	}
}

function doFolder(node,iFr,src) {

	if(node.parentNode.className == "closed") {
		node.parentNode.className = "open";
	}
	window.parent.document.getElementById(iFr).src = src;
}	

function branchAll() {
	
	var nodes = document.getElementsByTagName('li');

	for (var i = 0; i < nodes.length; i++) {
	
		if (nodes[i].className == 'closed') {			
			nodes[i].className = 'open';
		}
	}	
}

function collapseAll() {
	
	var nodes = document.getElementsByTagName('li');

	for (var i = 0; i < nodes.length; i++) {
	
		if (nodes[i].className == 'open') {			
			nodes[i].className = 'closed';
		}
	}
}


function showHide(event,node) {
	event.cancelBubble=true;
	document.getElementById(node).className =
		 (document.getElementById(node).className == "hide")?"":"hide";
	event.cancelBubble=true;
}

function showME(id) {
	top.document.getElementById(id).style.display = 'block';
}

function hideME(id) {
	top.document.getElementById(id).style.display = 'none';
}


function compOver(obj,img,path) {
	if(!path) {
		path = '/__english/landing';
	}
	obj.style.backgroundImage = 'url(/_media'+path+'/'+img+'_o.jpg)';	
}

function compOut(obj,img,path) {
	if(!path) {
		path = '/__english/landing';
	}
	obj.style.backgroundImage = 'url(/_media'+path+'/'+img+'.jpg)';	
}

function genOver(obj,img,path) {
	if(!path) {
		path = '/__english/landing';
	}
	obj.style.backgroundImage = 'url(/_media'+path+'/'+img+'_o.jpg)';	
}

function genOut(obj,img,path) {
	if(!path) {
		path = '/__english/landing';
	}
	obj.style.backgroundImage = 'url(/_media'+path+'/'+img+'.jpg)';	
}

// PRINT FUNCTIONS

function printit(){  
	if (window.print) {
	    window.print() ;  
	} else {
	    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
	    WebBrowser1.ExecWB(6, 2); //Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
	}
}

function printFrame(iFr) {
	window.top[iFr].focus();
	window.top[iFr].print();
}

function printDiv(id) {
	var content = document.getElementById(id).innerHTML
	tmpStr = "location=no,menubar=no,directories=no,toolbar=no,status=no,personalbar=no,titlebar=no,scrollbars=yes,dependent=yes,resizable=yes";
	
	newWindow=window.open('','newWin',tmpStr);
	newWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>Print Page<\/title><link href="/_media/_css/main.css" rel="stylesheet" type="text/css" media="all"><link href="/_media/_css/printable.css" rel="stylesheet" type="text/css" media="all"><link href="/_media/_css/print_hide.css" rel="stylesheet" type="text/css" media="print"><link href="/_media/_css/sIFR-print.css" rel="stylesheet" type="text/css" media="all"><script type="text/javascript" src="/_media/_js/main.js" language="javascript"></script><\/head><body><div id="printable_buttons"><div style="float:left;"><input type="button" name="print" value="SEND TO PRINTER" onclick="printit();return false;" class="btn" \/><\/div><div align="right"><input type="button" name="close" value="CLOSE WINDOW" onclick="window.close();return false;" class="btn" \/><\/div><\/div>'+content+'<\/body><\/html>');
	
	winStatus = 1;
	
	newWindow.document.close();
	newWindow.focus();
}



// POP-UP DIV HANDLERS

function doBkg(id) {
	obj = document.getElementById(id);
	if(obj.currentStyle) {
	
	/****************************************
	
	IE Opera
	
	****************************************/
	
	src = obj.currentStyle.backgroundImage
	alert('background-image= '+src);
	alert('width= '+obj.currentStyle.width);
	alert('height= '+obj.currentStyle.height);
	var fileName = src.substring(src.lastIndexOf('/'), src.length);
	}
	else {
	
	/****************************************
	
	Firefox needs the full css code to work
	
	****************************************/
	src = getComputedStyle(obj,'').getPropertyValue('background-image');
	alert('background-image= '+getComputedStyle(obj,'').getPropertyValue('background-image'));
	alert('width= '+getComputedStyle(obj,'').getPropertyValue('width'));
	alert('height= '+getComputedStyle(obj,'').getPropertyValue('height'));
	var fileName = src.substring(src.lastIndexOf('/'), src.length);
	}
	alert (fileName);
}

function showPop(imgWidth,imgHeight,path,caption,id) {
	document.getElementById('largeImg').src = '/_media/spacer.gif';
	if (!caption) {
		caption = '';
	}
	if (!id) {
		id = 'popDiv';
	}	
	var popDiv = top.document.getElementById(id);
	var popCaption = top.document.getElementById('popCaption');
	var popScrn = top.document.getElementById('popScrn');
	var popFrame = top.document.getElementById('popFrame');
	
	var winWidth = top.document.documentElement.clientWidth;
	var winHeight = top.document.documentElement.clientHeight;
	var scrHeight = top.document.documentElement.scrollTop;
	var scrollHeight = top.document.documentElement.scrollHeight;
	
	popFrame.style.display = 'block';
	popFrame.style.height = scrollHeight+'px';
	
	popScrn.style.display = 'block';
	popScrn.style.height = scrollHeight+'px';
	
	popDiv.style.display = 'block';
	popDiv.style.width = imgWidth+'px';
	popDiv.style.height = imgHeight+'px';
	
	document.getElementById('largeImg').src = path;
	
	capWidth = imgWidth + 40; // added width is determined by doubling popDiv padding in stylesheet
	divWidth = imgWidth + 40; // added width is determined by doubling popDiv padding and popDiv border in stylesheet
	divHeight = imgHeight + 40; // added width is determined by doubling popDiv padding and popDiv border in stylesheet
	popCaption.style.width = capWidth+'px';
	popCaption.innerHTML = caption;
	
	xPos = (winWidth - divWidth)/2;
	yPos = (winHeight - divHeight)/2 + scrHeight;
	// alert ("total width: "+divWidth+" / total height: "+divHeight);
	// alert (winWidth+" / "+winHeight);
	// alert ("x: "+xPos+" / y: "+yPos);
	// alert ("scroll height: "+scrollHeight);
	popDiv.style.left = xPos+'px';
	popDiv.style.top = yPos+'px';
}

function hidePop(id) {
	if (!id) {
		id = 'popDiv';
	}
	document.getElementById('popFrame').style.display='none';
	document.getElementById('popScrn').style.display='none';
	document.getElementById(id).style.display = 'none';
}

function showLarge(imgsrc,imgcap,id) {
	var thumb = document.getElementById(imgsrc);
	var src = thumb.getAttribute('src');
	if (!imgcap) {
		var caption = '';
	} else {
		var caption = imgcap;	
	}
	var imgWidth = ((thumb.width)* 4 );
	var imgHeight = ((thumb.height)*4);
	var fileName = src.substring(src.lastIndexOf('/'), src.length);
	var path = '/ax_gallery/desc_large'+fileName;
	document.getElementById('largeImg').src = path;
	showPop(imgWidth,imgHeight,path,caption);
}
