function popUp(URL,ID,WID,HEI,RESIZE,STATUS,SCROLL){
	if ( typeof(RESIZE) == 'undefined' ){ RESIZE = "yes" }
	if ( typeof(STATUS) == 'undefined' ){ STATUS = "yes" }
	if ( typeof(SCROLL) == 'undefined' ){ SCROLL = "yes" }
	var day = new Date();
	if ( !ID ){ ID = day.getTime(); }
	if ( !WID ){ WID = "500"; }
	if ( !HEI ){ HEI = "400"; }

	eval( "page" + ID + " = window.open('" + URL +"', '" + ID + "','copyhistory=no,toolbar=no,location=no,resizable=" + RESIZE +",status=" + STATUS + ",scrollbars=" + SCROLL + ",menubar=no,width=" + WID + ",height=" + HEI + "')" );
}
function divAlert(p,i){
	hideMe(p);
	document.getElementById( i ).innerHTML = "<a href=\"#\" onclick=\"divAlert('shadow','showMe')\">close</a><br /><a href=\"#\" onclick=\"callAjax('10200','/cgi-bin/ajax.pl','vcd186','dinosaur')\">wine</a>";
	hideMe(i);
}

var hideMeTimer = null;
function hideMe(e){
// will show/hide element
	var t = document.getElementById( e );
	// clear any timers that are running to hide div
	clearTimeout( hideMeTimer );
	hideMeTimer = null;
	// is it already showing?
	if ( t.style.display == "block" ){
    		hideMeTimer = setTimeout("reallyHide('" + e + "')", 500);
		//t.style.display = "none";
	}else{
		t.style.display = 'block';
	}
}
function reallyHide(div){
	document.getElementById( div ).style.display = 'none';
}

function toggleMe(action,element){
var status = document.getElementById(element);
	if ( action == "show" | action == "2" ){
	status.style.display = 'block';
	}else{
	status.style.display = 'none';
	}
}
function showHint(text,what,action){
	if ( action == "hide" ){ document.getElementById(what).style.display = "none"; }
		document.getElementById(what).innerHTML = text;
	if ( action == "show" ){ document.getElementById(what).style.display = "block"; }
}

// AJAX stuff by Greg Haywood 
function loadXMLDoc(url,div){
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.open("GET", url, true);
		req.onreadystatechange = processReqChange;
		req.send();
	// branch for IE/Windows ActiveX version
	} else if ( window.ActiveXObject ) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		req.open("GET", url, true);
		if (req) {
			req.onreadystatechange = processReqChange;
			req.send();
        	}
	}
}
function processReqChange(){
    // only if req shows "complete"
    if (req.readyState == 4) {
        // only if "OK"
        if ( req.status == 200 ) {
            // ...processing statements go here...
		if ( document.getElementById('suggestionList') ){
			document.getElementById('suggestionList').innerHTML = "";
			document.getElementById('suggestionList').innerHTML = req.responseText;
		}else{
			document.getElementById('showMe').innerHTML = "";
			document.getElementById('showMe').innerHTML = req.responseText;
		}
        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
return;
}
function callAjax(input,url,v1,v2,v3){
	/* first display loading image  */
	document.getElementById('showMe').innerHTML = "loading..<br /><img src=\"/siteimages/loading.gif\" class=\"waiting\">";
	if ( input ) { url += '?' + input; }
	if ( v1 ) { url += '&' + v1; }
	if ( v2 ) { url += '&' + v2; }
	if ( v3 ) { url += '&' + v3; }
	loadXMLDoc(url,'showMe');
}
function autoComplete(input,url,div,content){
	/* first display loading image  */
	if ( document.getElementById( div ).style.display == 'none' ){
		document.getElementById( div ).style.display = 'block';
	}
	document.getElementById( content ).innerHTML = "loading..<br /><img src=\"/siteimages/loading.gif\" class=\"waiting\">";
	if ( input ) { url += '?' + input; }
	loadXMLDoc(url,div);
}
// end AJAX stuff

// cookie stuff
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
// end cookie things

// Start set font stuff
function resetFont(){
	eraseCookie('font');
	document.location.reload();
	return true;
}
var min=8;
var max=18;
function setFont(){
	var fontSize = readCookie('font');
	if ( fontSize ){
	var p = document.getElementsByTagName('div','p');
		for(i=0;i<p.length;i++) {
			p[i].style.fontSize = fontSize+"px"
		}
	}
}
function increaseFontSize() {
var p = document.getElementsByTagName('div','p');
var newSize;
	for(i=0;i<p.length;i++) {
		if(p[i].style.fontSize) {
		var s = parseInt(p[i].style.fontSize.replace("px",""));
		} else {
		var s = 12;
		}
		if(s!=max) {
		s += 1;
		}
	newSize = s;
	p[i].style.fontSize = s+"px"
	}
setFontCookie(newSize);
}
function decreaseFontSize() {
var p = document.getElementsByTagName('div','p');
var newSize;
	for(i=0;i<p.length;i++) {
	if(p[i].style.fontSize) {
		var s = parseInt(p[i].style.fontSize.replace("px",""));
	} else {
		var s = 12;
	}
	if(s!=min) {
		s -= 1;
	}
	newSize = s; // keep size for setting cookie
	p[i].style.fontSize = s+"px"
	} 
setFontCookie(newSize);
}
function setFontCookie(fontSize){
	eraseCookie('font');
	createCookie('font',fontSize,'10');
}
// End set font stuff

// Are you sure on submit button
function ruSure(msg) {
	var agree = confirm( msg );
	if ( agree ){
		return true;
	}else{
		return false;
	}
}
// auto change of cat and subcat
function catSubcat(){
// clear list first
var cl = document.adminform.subcategory;
removeAllOptions(cl);

var argv = catSubcat.arguments;
var argc = argv.length;
var myList = new Array;
var myItems = new Array;

myList = argv[argv[0]].split(",");
myItems = myList[1].split("|");
var Items = myItems.length;
	for ( var i = 0; i < Items; i++) {
		var myText = myItems[i].split("=")[1];
		addOption(cl,myItems[i].split("=")[0],unescape(myText));
	}
}

function regionState(form){
// clear list first
var List = document.adminform.state;
removeAllOptions(List);
var argv = regionState.arguments;
var argc = argv.length;
var myList = new Array;
var myItems = new Array;

myList = argv[argv[0]].split(",");

var Items = myList.length;

	for ( var i = 0; i < Items; i++ ) {
		addOption(List,myList[i].split("=")[1],myList[i].split("=")[1]);
	}
}
function removeAllOptions(selectbox){
	var i;
	for(i=selectbox.options.length-1;i>=0;i--){
		selectbox.remove(i);
	}
}
function addOption(selectbox,value,text){
	var optn = document.createElement("option");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}
// form validation
function highLabel(e, value) { 
	e = document.getElementById(e.name); 
	if (e){
	e.style.background = value; 
	}
}
function checkForm(f) { 
	var e,i;
	for (i=0; i<f.elements.length; i++) { 
	e = f.elements[i]; 
	/* ignore fields with multiple elements */ 
		if (e.type == 'text' && !e.length) { 
		highLabel(this, '#ccf'); 
		} 
	} 
}
function pageLoad(){
	document.getElementById('page-loader-container').style.display = 'block';
	setTimeout( "endLoad()",1000 );
}
function endLoad(){
	document.getElementById('page-loader-container').style.display = 'none';
}

