// JavaScript Document


// BASIC SHOW/HIDE

function showHide(event,node) {
	event.cancelBubble=true;
	document.getElementById(node).style.display =
		 (document.getElementById(node).style.display == "none")?"":"none";
	event.cancelBubble=true;
}

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

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

// NEW WINDOW HANDLER

function popWin(src,wd,ht) {

	tmpStr = "location=no,menubar=no,directories=no,toolbar=no,status=no,personalbar=no,titlebar=no,scrollbars=no,dependent=yes,resizable=no,width="+wd+",height="+ht+"";	
	newWindow = window.open(src,'newWin',tmpStr);
	if (!newWindow) { return; }
	
	var xPos = (screen.availWidth - wd)/2;
	var yPos = (screen.availHeight - ht)/2;
	newWindow.moveTo(xPos,yPos);
	
	newWindow.focus();	
	winStatus = 1;
}



// POP-UP DIV HANDLERS

function showInfo (wd,ht,src) {

	var popDiv = top.document.getElementById('popDiv');
	var popBody = top.document.getElementById('popBody');
	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';
	if (winHeight <= scrollHeight) {
		popScrn.style.height = scrollHeight+'px';
	} else {
		popScrn.style.height = winHeight+'px';
	}
	
	popDiv.style.display = 'block';
	popDiv.style.width = wd+'px';
	popDiv.style.height = ht+'px';
	
	divWidth = wd + 40; // added width is determined by doubling popDiv padding and popDiv border in stylesheet
	divHeight = ht + 40; // added width is determined by doubling popDiv padding and popDiv border in stylesheet
	
	xPos = (winWidth - divWidth)/2;
	yPos = (winHeight - divHeight)/2 + scrHeight;

	popDiv.style.left = xPos+'px';
	popDiv.style.top = yPos+'px';
	popBody.innerHTML = "<iframe src="+src+" name=\"srcFrame\" width="+wd+" marginwidth=\"0\" height="+ht+" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\"></iframe>";
}

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 background = top.document.getElementById('bodyMain');
	
	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';
	if (winHeight <= scrollHeight) {
		popScrn.style.height = scrollHeight+'px';
	} else {
		popScrn.style.height = winHeight+'px';
	}
	
	background.style.filter = 'progid:DXImageTransform.Microsoft.Blur(strength=50)';
	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('bodyMain').style.filter='none';
	document.getElementById('popFrame').style.display='none';
	document.getElementById('popScrn').style.display='none';
	document.getElementById(id).style.display = 'none';
}

function showLarge(imgsrc,imgcap,path) {
	var thumb = document.getElementById(imgsrc);
	var src = thumb.getAttribute('src');
	var caption = imgcap;
	var imgWidth = ((thumb.width)*4);
	var imgHeight = ((thumb.height)*4);
	var fileName = src.substring(src.lastIndexOf('/'), src.length);
	//var path = loc + '/large'+fileName;
	document.getElementById('largeImg').src = path;
	//document.getElementById(large).style.backgroundImage = 'url('+path+')';
	showPop(imgWidth,imgHeight,path,caption);
}

// TAB HIGHLILGHTER

function doTab(obj) {
	var sibs = $(obj.parentNode).siblings();
	for (var i = 0; i < sibs.length; i++) {
		if (sibs[i].className == 'active') {			
			sibs[i].className = '';
		}
	}
	obj.parentNode.className='active';
}


// INPUT BOX CLEAR

function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}


// AUTO-SIZE IFRAME HEIGHT

function sizeFrame(iFr) {
	i = window.parent.document.getElementById(iFr);
	iHeight = document.body.scrollHeight;
	i.style.height = iHeight + "px";
}

// SEND TO PRINTER

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 = "";  
	}
}



//this fix circumvents the "click to view" hotfix implements for Windows XP and Windows 2003 server users with IE6
function flash_write(file, width, height, trackID) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="movie" ><param name="movie" value="'+file+'" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><param name="bgcolor" value="#FFFFFF" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><embed width="'+width+'" height="'+height+'" align="middle" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#ffffff" quality="high" src="'+file+'"/></object>');
}
