/* $Header: /usr/local/cvsroot/newproj/elements/scripts/window.js,v 1.3 2009/11/04 23:29:52 tngsandiego Exp $ */
/* Displaying Elements */
function display(element) {
	var but = document.getElementById(element);
	but.style.display = 'block';
}
function hide(element) {
	var but = document.getElementById(element);
	but.style.display = 'none';
}
function hidedisplay(element){
	var but = document.getElementById(element);
	if(but.style.display == 'block'){
		but.style.display = 'none';
	}else{
		but.style.display = 'block';
	}
}
/* Flash Managing */
function visibleFlash(){
	var obj = top.document.getElementsByTagName("object");
	var emb = top.document.getElementsByTagName("embed");
	if(eval(obj.id)) obj.style.visibility = 'visible';
	if(eval(emb.id)) emb.style.visibility = 'visible';
}
function invisibleFlash(){
	var obj = top.document.getElementsByTagName("object");
	var emb = top.document.getElementsByTagName("embed");
	if(eval(obj.id)) obj.style.visibility = 'hidden';
	if(eval(emb.id)) emb.style.visibility = 'hidden';
}
function spitFlash(filename,width,height){
	if(!width) var width='100%';
	if(!height) var height='100%';
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" name="artist" id="artist" align="middle">');
		document.write('<param name="loop" value="false">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="' + filename + '" />');
		document.write('<param name="wmode" value="transparent">');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="bgcolor" value="#FFFFFF" />');
		document.write('<embed src="' + filename + '" loop="false" quality="high" width="'+width+'" height="'+height+'" name="artist" wmode="transparent" bgcolor="#FFFFFF" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
function spitVarFlash(filename,data,width,height){
	if(!width) var width='100%';
	if(!height) var height='100%';
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" name="artist" id="artist" align="middle">');
		document.write('<param name="loop" value="false">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="' + filename + '" />');
		document.write('<param name="wmode" value="transparent">');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="bgcolor" value="#FFFFFF" />');
		document.write('<param name="FlashVars" value="xml=' + escape(data) + '">');
		document.write('<embed src="' + filename + '" loop="false" FlashVars="xml=' + escape(data) + '" quality="high" width="'+width+'" height="'+height+'" name="artist" wmode="transparent" bgcolor="#FFFFFF" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
/* Flash */
function slideshow(filename,width,height,xmlLoc){
	if(!width) var width='100%';
	if(!height) var height='100%';
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="artist" align="middle">');
		document.write('<param name="loop" value="false">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="' + filename + '" />');
		document.write('<param name="wmode" value="transparent">');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="flashvars" value="overstretch=true&screencolor=0x800000&transition=blocks&shownavigation=false&file='+xmlLoc+'" />');
		document.write('<param name="bgcolor" value="#800000" />');
		document.write('<embed src="' + filename + '" flashvars="overstretch=true&screencolor=0x800000&transition=blocks&shownavigation=false&file='+xmlLoc+'" loop="false" quality="high" bgcolor="#800000" width="'+width+'" height="'+height+'" wmode="transparent" name="artist" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
/* Textbox */
function updateHeight(obj){
	var lines = parseInt(obj.scrollHeight/15);
	obj.rows = lines;
}
function charLimit(obj,who,limit){
if(who==undefined) who='char-left';
if(limit==undefined) limit=1500;
	var cu=obj.value.length;
	var cntr=document.getElementById(who);
	if(cu>limit){
	        obj.value=obj.value.substr(0,limit);
	        cu=limit;
	}
	cntr.innerHTML=parseInt(limit - cu);
}
/* Sizes */
function getHeight(id){
	var thisOne = document.getElementById(id);
	return thisOne.offsetHeight;
}
function getWidth(id){
	var thisOne = document.getElementById(id);
	return thisOne.style.width;
}

function resizeHeight(id, val){
	var totVal = parseInt(val);
	var thisOne = document.getElementById(id);
	thisOne.style.height = totVal + "px";
}
function resizeWidth(id, val){
	var totVal = parseInt(val);
	var thisOne = document.getElementById(id);
	thisOne.style.width = totVal + "px";
}
/* Margins */
function setMarginTop(id, val){
	var margine = parseInt(val);
	var thisOne = document.getElementById(id);
	thisOne.style.marginTop = margine + "px";
}
function setMarginBottom(id, val){
	var margine = parseInt(val);
	var thisOne = document.getElementById(id);
	thisOne.style.marginBottom = margine + "px";
}
function setMarginLeft(id, val){
	var margine = parseInt(val);
	var thisOne = document.getElementById(id);
	thisOne.style.marginLeft = margine + "px";
}
function setMarginRight(id, val){
	var margine = parseInt(val);
	var thisOne = document.getElementById(id);
	thisOne.style.marginRight = margine + "px";
}
/* Distances */
function findX(obj, relativeTo){
	if(eval(relativeTo)){ var difference = document.getElementById(relativeTo).offsetLeft; }else{ var difference = 0; }
	var curleft = 0;
	if(obj.offsetParent){
		while(1){
			curleft += obj.offsetLeft;
			if(!obj.offsetParent) break;
			obj = obj.offsetParent;
		}
	}else if(obj.x){
		curleft += obj.x;
	}
	curleft -= difference;
	
	return curleft;
}
function findY(obj, relativeTo){
	if(eval(relativeTo)){ var difference = document.getElementById(relativeTo).offsetTop; }else{ var difference = 0; }
	var curtop = 0;
	if(obj.offsetParent){
		while(1){
			curleft += obj.offsetTop;
			if(!obj.offsetParent) break;
			obj = obj.offsetParent;
		}
	}else if(obj.y){
		curtop += obj.y;
	}
	curtop -= difference;

	return curtop;
}
function setTop(id, val){
	var totVal = parseInt(val);
	document.getElementById(id).style.top = totVal + "px";
}
function setBottom(id, val){
	var totVal = parseInt(val);
	document.getElementById(id).style.bottom = totVal + "px";
}
function setLeft(id, val){
	var totVal = parseInt(val);
	document.getElementById(id).style.left = totVal + "px";
}
function getLeft(id){
	return document.getElementById(id).style.left;
}
function setRight(id, val){
	var totVal = parseInt(val);
	document.getElementById(id).style.right = totVal + "px";
}
function getRight(id){
	return document.getElementById(id).style.right;
}
/* Window */
function setWindowPosTop(val){
if(val==undefined) var val=0;
	document.body.scrollTop=0;
	document.documentElement.scrollTop=0;
}
function getWindowPosTop(){
	var hackSafari = parseInt(document.body.scrollTop);
	var winTop = parseInt(document.documentElement.scrollTop);
	if(winTop == 0) winTop = hackSafari;
	
	return winTop;
}
function getWindowPosLeft(){
	var hackSafari = parseInt(document.body.scrollLeft);
	var winLeft = parseInt(document.documentElement.scrollLeft);
	if(winLeft == 0) winLeft = hackSafari;

	return winLeft;
}
/* Body */
function getScreenH(){
	var hackSafari = parseInt(document.body.clientHeight);
	var size = parseInt(document.documentElement.clientHeight);
	if(size == 0) size = hackSafari;

	return size;
}
function getScreenW(){
	var hackSafari = parseInt(document.body.clientWidth);
	var size = parseInt(document.documentElement.clientWidth);
	if(size == 0) size = hackSafari;

	return size;
}
function getBodyH(){
	var hackSafari = parseInt(document.body.offsetHeight);
	var size = parseInt(document.documentElement.scrollHeight);
	if(size == 0) size = hackSafari;

	return size;
}
function getBodyW(){
	var hackSafari = parseInt(document.body.scrollHeight);
	var size = parseInt(document.documentElement.offsetHeight);
	if(size == 0) size = hackSafari;

	return size;
}