var elid = "";
var time_ticket = false;
var elid2 = "";
var time_ticket2 = false;

function $_(n) {
	if(!n) return false;
	if(!document.getElementById(n)) return false;
	return document.getElementById(n)
}

function show_block(el) {
	if ($_(el)) {
		$_(el).style.display = $_(el).style.display == "block" ? "none" : "block";
	}
}

function hide_fields(rows) {
	for (i=1; i<=rows; i++) {
		if ($_("fields_" + i)) $_("fields_" + i).className = "hide"; 
	}
}

function show_fields() {
	for (i=0; i<=arguments.length; i++) {
		if ($_("fields_" + arguments[i])) $_("fields_" + arguments[i]).className = "";
	}
}

function hide_field(field) {
	if ($_(field)) $_(field).className = "hide"; 
}

function show_field(field) {
	if ($_(field)) $_(field).className = ""; 
}

function show_hide(this_el,this_class,this_newclass,el) {
	if ($_(el)) {
		if ($_(el).style.display == "block") {
			$_(el).style.display = "none";
			if (this_el) {
				if (this_class) this_el.className = this_class;
			}
		} else {
			$_(el).style.display = "block";
			if (this_el) {
				if (this_newclass) this_el.className = this_newclass;
			}
		}
	}
}

function show_hide2 (this_el,el) {
	this_el.className = this_el.className == "" ? "show" : "";
	if ($_(el)) {
		$_(el).className = this_el.className == "show" ? "show" : "";
	}
}

function show_info(el) {
	if (elid != "") hide_time();
	if (time_ticket) {
		clearTimeout(time_ticket);
		time_ticket = false;
	}
	if ($_(el)) $_(el).style.display = "block";
}

function hide_info(el) {
	elid = el;
	time_ticket=setTimeout("hide_time()", 500);
}

function hide_time() {
	if ($_(elid)) $_(elid).style.display = "none";
	if (time_ticket) {
		clearTimeout(time_ticket);
		time_ticket = false;
	}
}

function set_innerHTML(_el, _txt){
	if ($_(_el)) {
		$_(_el).innerHTML = _txt;
	}
}

					
function getObj(name) {
  if (document.getElementById) { return document.getElementById(name).style;
  } else if (document.all) { return document.all[name].style;
  } else if (document.layers) { return document.layers[name];
  } else return false;
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
		return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
		return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
    } else {
		return false;
    }
} // getStyleObject


function hide_all() {
	
	if ($_(elid2)) $_(elid2).style.display = "none";
	if (time_ticket2) {
		clearTimeout(time_ticket2);
		time_ticket2 = false;
	}
}

function show_info2(el){
	//alert( document.body.clientWidth  );

	var the_style = getStyleObject(el);

	var the_left = 900;
	
	//alert( the_left  );
	
	var the_left = parseInt(document.body.clientWidth) - 300;
	
	//alert( the_left  );
	
	if (document.layers){
		the_style.left = the_left;
		//the_style.top = the_top;
	}else{
		the_style.left = the_left + "px";
		//the_style.top = the_top + "px";  
	}
	if (elid2 != "") hide_time2();
	if (time_ticket2) {
		clearTimeout(time_ticket2);
		time_ticket2 = false;
	}	
	$_(el).style.display = "block";
} 

function hide_info2(el) {
	elid2 = el;
	time_ticket2=setTimeout("hide_time2()", 500);
}

function hide_time2() {
	if ($_(elid2)) $_(elid2).style.display = "none";
	if (time_ticket2) {
		clearTimeout(time_ticket2);
		time_ticket2 = false;
	}
}

function el_disable(this_el,this_value,el1,el2) {
	if (this_el.value == this_value) {
		if ($_(el1)) $_(el1).disabled = true;
		if ($_(el1)) $_(el1).className = "txt disabled";
		if ($_(el2)) $_(el2).disabled = true;
	} else {
		if ($_(el1)) $_(el1).disabled = false;
		if ($_(el1)) $_(el1).className = "txt";
		if ($_(el2)) $_(el2).disabled = false;
	}
}

function PopupWindow(source, strWindowToOpen)
{
  // Set window features for the popup window
 var strWindowFeatures = "toolbar=no,resize=yes,titlebar=no,";
 strWindowFeatures = strWindowFeatures +
"location=no,directories=no,status=no,scrollbars=yes, resizable=yes,"
 strWindowFeatures = strWindowFeatures +
"menubar=no,width=1024,height=768,maximize=null";
 // Open the window
 window.open(strWindowToOpen, 'PopupWindow', strWindowFeatures);
}

function getScrollXY() {
    var x = 0, y = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
    return [x, y];
}
           
function setScrollXY(x, y) {
    window.scrollTo(x, y);
}

