function $S(v) { 
	return($(v).style); 
}
function agent(v) { 
	return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); 
}
function isset(v) { 
	return((typeof(v)=='undefined' || v.length==0)?false:true); 
}
function XYwin(v) { 
	var z=agent('msie')?Array(document.body.clientHeight,document.body.clientWidth):Array(window.innerHeight,window.innerWidth); 
	return(isset(v)?z[v]:z); 
}
function sTog() { 
	document.onclick=function(){ 
		$S('sBg').display='none'; 
		$S('sBox').display='none'; 
		//new Effect.Fade($('sBg'), {duration: 0, from: 0.75, to: 0});
		//new Effect.Fade($('sBox'), {duration: 0, from: 1, to: 0});
		$('sContent').innerHTML = '';
		$S('sSpinner').display='block';
		document.onclick=function(){
		}; 
	}; 
}
function closeBox() {
	//new Effect.Fade($('sBg'), {duration: 0, from: 0.75, to: 0});
	//new Effect.Fade($('sBox'), {duration: 0, from: 1, to: 0});
	$S('sBg').display='none';
	$S('sBox').display='none';
	
	$('sContent').innerHTML = '';
	$S('sSpinner').display='block';
	document.onclick=function(){
	};
	
	
	//any updates
	if(sUpdateCloseUrl != '' && sUpdateCloseDiv != ''){
		
		//update origin page
		getlink(sUpdateCloseUrl, sUpdateCloseDiv, 'blank', 'blank');
		
		//reset
		sUpdateCloseUrl = '';
		sUpdateCloseDiv = '';
	}
	
}
function clearInside() {
	$('sContent').innerHTML = '';
}
function resizeSBox(sWidth, sHeight) {
	
	var defaultHeight = window.innerHeight-50;
	
	var sWidth = (sWidth == null) ? 760 : sWidth;
    var sHeight = (sHeight == null) ? defaultHeight : sHeight;
	var actualW = sWidth+52;
	var actualH = sHeight+52;
	
	var fromTop = ((window.innerHeight*.38)-(actualH/2));
	if(fromTop < 70) {
		fromTop = 70;
	}
	
	$S('sBox').width=sWidth+'px'; 
	$S('sBox').height=sHeight+'px';	
	
	$S('sBox').top=Math.round(fromTop)+'px'; 
	$S('sBox').top='15px'; 
	$S('sBox').left=Math.round((XYwin(1)-actualW)/2)+'px'; 
	
	csWidth = sWidth;
	csHeight = sHeight-38;
	$S('sContainer').width=csWidth+'px'; 
	$S('sContainer').height=csHeight+'px';
}




var sUpdateCloseUrl = '';
var sUpdateCloseDiv = '';


function sBox(url, sWidth, sHeight, isUpdateCloseUrl, isUpdateCloseDiv) { 

	
	//set vars to update a div with a url on closeBox();
	if(isUpdateCloseUrl != null && isUpdateCloseDiv != null){
		sUpdateCloseUrl = isUpdateCloseUrl;
		sUpdateCloseDiv = isUpdateCloseDiv;
	}

	//clear sBox if anything's inside
	$('sContent').innerHTML = '';
	
	//fill sbox
	if(url != null) getlink(url, 'sContent', 'sSpinner', 'sSpinner');
	
	
	var defaultHeight = window.innerHeight-95;
	
	var sWidth = (sWidth == null) ? 760 : sWidth;
    var sHeight = (sHeight == null) ? defaultHeight : sHeight;
	var actualW = sWidth+52;
	var actualH = sHeight+52;
	
	var fromTop = ((window.innerHeight*.38)-(actualH/2));
	if(fromTop < 36) {
		fromTop = 36;
	}

	
	//setTimeout("sTog()",100); 
	
	
	$S('sBg').height=XYwin(0)+'px'; 
	//$S('sBg').display='block'; 
	new Effect.Appear($('sBg'), {duration: 0, from: 0.0, to: .5});
	
	//$('sBox').innerHTML=v+'<div class="sexyX">(click outside box to close)'+"<\/div>"; 
	$S('sBox').top=Math.round(fromTop)+'px'; 
	$S('sBox').left=Math.round((XYwin(1)-actualW)/2)+'px'; 
	//override
	//$S('sBox').top='15px'; 
	//$S('sBox').left='15px'; 
	
	$S('sBox').width=sWidth+'px'; 
	$S('sBox').height=sHeight+'px';
	
	csWidth = sWidth;
	csHeight = sHeight-38;
	$S('sContainer').width=csWidth+'px'; 
	$S('sContainer').height=csHeight+'px';
	
	$S('sBox').display='block'; 
	//new Effect.Appear($('sBox'), {duration: 0, from: 0.0, to: 1});
	
	/*$('sBox').onclick = function () {
		document.onclick=function(){};
	}
	$('sBox').onmouseup = function () {
		setTimeout('sTog()',1);
	}*/
}

var gcloseUrl;
var gcloseUpdate; 

function ifBox(url, sWidth, sHeight, closeUrl, closeUpdate) {

	
	gcloseUrl = (closeUrl == null) ? null : closeUrl;
	gcloseUpdate = (closeUpdate == null) ? null : closeUpdate;
    
    
	$('sContent').innerHTML = '';
	
	//$S('sSpinner').display='none';
	
	
	var sWidth = (sWidth == null) ? 760 : sWidth;
    var sHeight = (sHeight == null) ? 454 : sHeight;
	var actualW = sWidth+52;
	var actualH = sHeight+52;
	
	//$S('sBox').padding='10px 10px 0 10px';
	
	$('sContent').innerHTML = '<iframe onload="hideIfrSpinner();" src="'+url+'/layout:iframe" id="ifBox" width="'+sWidth+'px" height="'+sHeight+'px" frameborder="0"></iframe>';
	
	
	var fromTop = ((window.innerHeight*.38)-(actualH/2));
	if(fromTop < 70) {
		fromTop = 70;
	}

	
	//setTimeout("sTog()",100); 
	
	
	$S('sBg').height=XYwin(0)+'px'; 
	//$S('sBg').display='block'; 
	new Effect.Appear($('sBg'), {duration: 0, from: 0.0, to: .4});
	
	//$('sBox').innerHTML=v+'<div class="sexyX">(click outside box to close)'+"<\/div>"; 
	$S('sBox').top=Math.round(fromTop)+'px'; 
	$S('sBox').left=Math.round((XYwin(1)-actualW)/2)+'px'; 
	//override
	$S('sBox').top='15px'; 
	//$S('sBox').left='15px'; 
	
	$S('sBox').width=sWidth+'px'; 
	
	var extH = sHeight+20;
	$S('sBox').height=extH+'px';
	
	//$S('sBox').display='block'; 
	new Effect.Appear($('sBox'), {duration: 0, from: 0.0, to: 1});
	
	/*
	$('sBox').onclick = function () {
		document.onclick=function(){};
	}
	$('sBox').onmouseup = function () {
		setTimeout('sTog()',1);
	}
	*/
}
function hideIfrSpinner() {
	$S('sSpinner').display='none';
}


function sTitleBar(content) {
	
	if(content == 'restore') {
		$('sTitleBar').innerHTML = $('sTitleBarHolder').innerHTML;
	} else {
		$('sTitleBar').innerHTML = content;
	}
	
}






































