var signScreenHeight	= 720;
var signScreenWidth	= 1280;
var screenPreviewWidth	= 320;
var screenPreviewHeight	= 180;
var screenPreviewLeft	= (screen.width * 0.95 - screenPreviewWidth);
var screenPreviewTop	= 80;


/* shows/hides specified div by given id, curId and all of its parent divs
 * Hide status bar msg II script- by javascriptkit.com 
 * Visit JavaScript Kit (http://javascriptkit.com) for script 
 * Credit must stay intact for use 
 * Note: doesn't work in Opera -KJ
 **********************************************************************/
 function hidestatus(){ 
	window.status='' 
	return true 
 } 
 if (document.layers) document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT) 
 document.onmouseover=hidestatus 
 document.onmouseout=hidestatus 


/* shows/hides specified div by given id, curId and all of its parent divs
 **********************************************************************/
 function showdivpath(curId) { 

	var ele = document.getElementById(curId);
	var action = (ele.style.display != 'block' ? 'block' : 'none');
	
	// set all parent divs
	while (ele = document.getElementById(ele.parentNode.id)) {
		ele.style.display = 'block'; //action; 
	}
	
	// set the specified div
	ele.style.display = 'block'; //action;
 }


/* shows/hides specified div by given id, curId
 * can explicity specify whether or not to collapse by setting collapse to true/false
 **********************************************************************/
 function showdiv(curId, collapse) { 
	var ele = document.getElementById(curId);
	if (collapse === undefined ) {
		ele.style.display = (ele.style.display != 'block' ? 'block' : 'none');
	}
	else {
		ele.style.display = (collapse ? 'none' : 'block');
	}
 }


/* toggles the plus and minus sign before each title
 **********************************************************************/
 function toggleCollapse(curId) {
	var str=document.getElementById(curId).innerHTML;
	if (str.charAt(0) != '-') {
		document.getElementById(curId).innerHTML = '-' + str.substr(1, str.length); 
	} 
	else {
		document.getElementById(curId).innerHTML = '+' + str.substr(1, str.length); 
	}
 }


/* sets the Preview attributes
 * bars need to be set individually rather than 'inherit' in css due to IE's lack of 
 * support for it.
 **********************************************************************/
 function setPreview() {
	var el = document.getElementById('previewScreen');
	var t_el = document.getElementById('previewTopBar');
	var b_el = document.getElementById('previewBottomBar');
	var l_el = document.getElementById('previewLeftBar');
	var r_el = document.getElementById('previewRightBar');
	
	el.style.top = screenPreviewTop + 'px';
	el.style.left = screenPreviewLeft + 'px';
	el.style.height = screenPreviewHeight + 'px';
	el.style.width = screenPreviewWidth + 'px';
	
	t_el.style.top = l_el.style.top = r_el.style.top = el.style.top;
	t_el.style.left = l_el.style.left = b_el.style.left = el.style.left;
	l_el.style.height = r_el.style.height = el.style.height;
	t_el.style.width = b_el.style.width = el.style.width;
 }

/* determines id's bar position
 * assumption: the position is contained in id. eg: leftBar
 **********************************************************************/
 function getBarPos(id) {
	var pos;
	
	if (id.search(/left/i) >= 0) {
		pos='left';
	}
	else if (id.search(/right/i) >= 0) {
		pos='right';
	}
	else if (id.search(/top/i) >= 0) {
		pos='top';
	}
	else if (id.search(/bottom/i) >= 0) {
		pos='bottom';
	}
	
	return pos;
 }


/* position is left/right/top/bottom sets a bar according to bar's thickness, 
 * percentage (of preview)
 **********************************************************************/
 function showPreviewBar(percentage, position) {
	var el;
	switch(position) {
		case "top":
			el = document.getElementById('previewTopBar');
			el.style.height = Math.round(screenPreviewHeight * percentage * .01) + "px";
			break;
		case "bottom":
			el = document.getElementById('previewBottomBar');
			el.style.height = Math.round(screenPreviewHeight * percentage * .01) + "px";
			el.style.top = screenPreviewTop + screenPreviewHeight - parseInt(el.style.height) + "px";
			break;
		case "left":
			el = document.getElementById('previewLeftBar');
			el.style.width = Math.round(screenPreviewWidth * percentage * .01) + "px";
			break;
		case "right":
			el = document.getElementById('previewRightBar');
			el.style.width = Math.round(screenPreviewWidth * percentage * .01) + "px";
			el.style.left = screenPreviewLeft + screenPreviewWidth - parseInt(el.style.width) + "px";
			break;
	}
	if (percentage > 0) {
		el.style.visibility = "visible";
	}
	else {
		el.style.visibility = "hidden";
	}
 }

/* like php's ucwords, this puts a string, str, to title case
 **********************************************************************/
 function ucwords (str) {
	return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase( ); } );
 }


/* mimicks built-in function of the same name since some browsers (eg: IE) do
 * not support it. 
 * use a try...catch with the built-in function
 **********************************************************************/
 function getElementsByClassName(clsName, tagType) {
	var els = document.getElementsByTagName(tagType);
	var arr = [];
	
	for (var i=0; i<els.length; i++) {
		if (els[i].className == clsName) arr[arr.length] = els[i];
	}
	return arr;
 }

