// JavaScript Document
// screen thingies


function $(v) { return(document.getElementById(v)); }
function $S(v) { return(document.getElementById(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 sexyTOG() { document.onclick=function(){ $S('sexyBG').display='none'; $S('sexyBOX').display='none'; document.onclick=function(){}; }; }
function sexyBOX(v,b,h) {setTimeout("sexyTOG()",100); $S('sexyBG').height=XYwin(0)+'px'; $S('sexyBG').display='block'; $('sexyBOX').innerHTML=
 '<iframe id="cbpop" style="border:0" src ="'+v+'" width="100%" height="100%"><\/iframe><div class="sexyX">(click outside box to close)'+"<\/div>"; $S('sexyBOX').left=Math.round((XYwin(1)-b)/2)+'px'; $S('sexyBOX').height=h+'px'; $S('sexyBOX').width=b+'px';$S('sexyBOX').display='block'; }

function lyteframe(url,width,height) {
   var objLink = document.createElement('a');
   objLink.setAttribute('href',url);
   objLink.setAttribute('rel','lyteframe');
   objLink.setAttribute('rev','width:'+width+';height:'+height+';scrolling: no;')
   myLytebox.start(objLink, false, true);
}

function lytepop(url,ftitle) {
   var objLink = document.createElement('a');
   objLink.setAttribute('href',url);
   objLink.setAttribute('rel','lytebox');
   objLink.setAttribute('title',ftitle);
   myLytebox.start(objLink, false, false);
}

function lytegroup(url,ftitle,igroupname) {
   var objLink = document.createElement('a');
   objLink.setAttribute('href',url);
   objLink.setAttribute('rel','lytebox[' + igroupname+ ']');
   objLink.setAttribute('title',ftitle);
   myLytebox.start(objLink, false, false);
}


/*
switches off thumb_items 7 and up..
*/
function thumbsDown() {
var i=7;
	while (i<=36){
			if ($('th_'+i)){ $('th_'+i).style.display='none';}i++;
	}
	
	 contractcontent('openform')

}

function thumbsUp(){
var i=7;
		while (i<=36) {
		if ($('th_'+i)){$('th_'+i).style.display='';}	i++;
		}
}



var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)
ccollect=new Array();

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}
function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}
function expandcontent(cid){
if ($('cat_pic')) $('cat_pic').style.display='none';
thumbsUp();
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
$(cid).style.display=($(cid).style.display!="block")? "block" : "none";
$('opener').style.display  = ($('opener').style.display !="block")? "block" : "none";
$('closer').style.display  = ($('closer').style.display !="block")? "block" : "none";


}
}
function revivecontent(){

contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
if (!$('cat_pic')) {$(selectedComponents[i]).style.display="block"}
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";"                    , offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}
function saveswitchstate(){
var inc=0                                            , selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}
document.cookie=window.location.pathname+"="+selectedItem
}
function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined"){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0"
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
}
if (window.addEventListener)
window.addEventListener("load"                       , do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload"                          , do_onload)
else if ($)
window.onload=do_onload
if (enablepersist=="on" && $)
window.onunload=saveswitchstate


