﻿// assorted javascript functions

// sort out the screen size
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
 screenW = screen.width;
 screenH = screen.height;
}
else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 screenW = jScreenSize.width;
 screenH = jScreenSize.height;
}


function start_fleximargin() {
	if (screenW <= 800) tabWidth = "96%";
	else if (screenW <= 1024) tabWidth = "88%";
		else tabWidth = "80%";
	document.write(
	 '<table align="center" width="'+tabWidth+'" cellspacing="0" cellpadding="0" border="0">'
	)
}
function switch_lang(newlang) {
document.location.search="?lang="+newlang;
}
function ston(txt)
{
	window.status=txt;
}
function stoff()
{
	window.status="";
}
function spawn(TargetUrl)
{
	popupWin = window.open(TargetUrl, 'remote', 'location,scrollbars,resizable,height=450,width=400')
}
function newwin(img,source,height,width,caption) {
	height = height+100;
	width=width+50;
	myRef = window.open('admin/show_largeimage.php?img='+ img + '&source=' + source + '&caption=' + caption,'largeimgwin',
'left=20,top=20,width='+width+',height='+height+',toolbar=0,resizable=0,scrollbars=1');
	return;
}

function max() {
	this.moveTo(0, 0);
	this.resizeTo(screen.availWidth,screen.availHeight)
}

//*******************************************

		function changecss(theClass,element,value,toggleid,toggleshow,togglehide) {
//Custom JavaScript Functions by Shawn Olson
//Copyright 2006-2008
//http://www.shawnolson.net
//If you copy any functions from this page into your scripts, you must provide credit to Shawn Olson & http://www.shawnolson.net
	//Last Updated on June 23, 2009
	//documentation for this script at
	//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
	 var cssRules;

	 var curLab = document.getElementById(toggleid).innerHTML;

	 if (curLab == toggleshow) {
	 	value = 'block';
		document.getElementById(toggleid).innerHTML = togglehide;
	}
	 else if (curLab == togglehide) {
	 	value = 'none';
		document.getElementById(toggleid).innerHTML = toggleshow;
	}
	 var added = false;
	 for (var S = 0; S < document.styleSheets.length; S++){

    if (document.styleSheets[S]['rules']) {
	  cssRules = 'rules';
	 } else if (document.styleSheets[S]['cssRules']) {
	  cssRules = 'cssRules';
	 } else {
	  //no rules found... browser unknown
	 }

	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    if(document.styleSheets[S][cssRules][R].style[element]){
	    document.styleSheets[S][cssRules][R].style[element] = value;
	    added=true;
		break;
	    }
	   }
	  }
	  if(!added){
	  if(document.styleSheets[S].insertRule){
			  document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule) {
				document.styleSheets[S].addRule(theClass,element+': '+value+';');
			}
	  }
	 }
	}

function toggle(divid,show,hide) {
	var ele = document.getElementById(divid+"Div");
	var text = document.getElementById(divid+"Toggle");
	if(ele.style.display == "block") {
    		ele.style.display = "none";
		text.innerHTML = show;
  	}
	else {
		ele.style.display = "block";
		text.innerHTML = hide;
	}
} 

function nav_to(optlist,type) {
	if (optlist.value == '') return;
	document.location.href = "/"+type+"/"+optlist.value;
	return;
}
//--></script>