var DHTML = (document.getElementById || document.all || document.layers);
var obj;

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function invi(who, flag)
{
	if (!DHTML) return;
	var x = window.document.getElementById(who);
	if (flag == '1') x.style.visibility = 'visible';
	if (flag == '0') x.style.visibility = 'hidden';
}

function togglecheckbox(box, who)
{
  var the_box = window.document.getElementById(box);
  var x = window.document.getElementById(who);
  if (the_box.checked == false) {
    x.style.visibility = 'hidden';
  } else {
    x.style.visibility = 'visible';
  }
}

function inviall() 
{
    var argv = inviall.arguments;
    var argc = argv.length;
    for (var i = 0; i < argc; i++) {
	var x = window.document.getElementById(argv[i]);
	x.style.visibility = 'hidden';
    }
}


var texttop = 400;

function move(amount)
{
	if (!DHTML) return;
	var x = new getObj('active');
	texttop += amount;
	x.style.top = texttop;
}


function changeCol(x, col)
{
	if (!DHTML) return;
	x.style.color = col;
}

function changeW()
{
	if (!DHTML) return;
	var x = new getObj('active');
	x.style.color = '#ffffff';
}

function undrln(x, whet)
{
	if (!DHTML) return;
	if (whet=='yes') x.style.textDecoration='underline';
	if (whet=='no') x.style.textDecoration='none';
}

function swap(oldname, newname)
{
	if (!DHTML) return;
	window.document.getElementById(oldname).src = newname;
}

function clearhistory()
{
history.replace('http://www.gmx.net');
}

function clearText(el) 
{
	if (el.defaultValue==el.value) el.value = "";
}

function changeText(id, newtext) {
  window.document.getElementById(id).innerText = newtext;
 }
 
function swapImages(imgNm, newSrc, cont) {
	window.document.getElementById(cont).filters[0].Apply();
	document.getElementById(imgNm).src = newSrc;
	window.document.getElementById(cont).filters[0].Play();
}

function checkBrowser() {
var x = navigator.appName;
if (x != "Microsoft Internet Explorer") {
	newwindow=window.open("","new1","width=100,height=100");
	newwindow.document.write("<center>You are using "+x+" browser. <br>This page is best viewed with Internet Explorer 5.5 or higher.<br>You can still browse the page but you will lose some functionality.</center>");
	}
}

function showHlp() {
newwindow=window.open("help.htm","new1","width=300,height=300");

}

function swapImage(imagefile) {
	window.document.side_t_default.src = imagefile;
}

function swapImageRestore() {
	window.document.side_t_default.src = "images/side_t_default.jpg";
}

function checkPassField(field) {
	if(field.value && field.value.length<4) {
		alert('Your password must be more than 4 characters long!');
		field.focus();
		field.select();
	}
}

function resetMarquee() {
	targetobject = document.getElementById("marquee");
	targetobject.value="Move mouse over any of the buttons above for more details...";
}
  
function setMarquee(target) {
	targetobject = document.getElementById("marquee");
	text = "Coming soon...";
	if(target=="home") text = "Index page";
	if(target=="store") text = "Online store - huge inventory";
	if(target=="order") text = "Place an order online or in any other way";
	if(target=="catalog") text = "Online catalog of all items";
	if(target=="resources") text = "Huge collection of various resources";
	if(target=="support") text = "Let us know if something with your order is wrong and we will make it right";
	if(target=="contact") text = "Our contact information - mail, telephone, fax, email";
	targetobject.value=text;
}

function newwin() {
	picWindow = window.open('static/encl-codes.htm','EnclWin','resizable=yes,width=380,height=360,scrollbars=yes')
}

function winman() {
	picWindow = window.open('tables/mancodes.htm','EnclWin','resizable=yes,width=380,height=360,scrollbars=yes')
}

function checkEmail(frm) {
	if((frm.s_email.value.indexOf(".") > 2) && (frm.s_email.value.indexOf("@") > 0) && (frm.s_email.value.length > 0)) {
		return true;
	}
	alert("You need to provide a valid email address.");
	return false;
}

function checkSearch(frm) {

	if(frm.searchforme.value.length > 0) {
		if (!frm.safeway.checked && !frm.baldor.checked && !frm.marathon.checked && !frm.uselectric.checked) {
			alert("You need to select at least one catalog to search in");
			return false;
		}
		return true;
	} 
	alert("You need to enter a phrase to search for");
	return false;
}

function toggle(divid) {
	var par = 1;
	var fill = "";
	while(arguments[par] != null) {
		fill += "&nbsp;&nbsp;&nbsp;<a class='items' href='redirect.php?target=catalog&type="+arguments[par++]+"'>"+arguments[par++]+"</a><br>";
	}
	if(document.getElementById(divid).innerHTML == "")
		document.getElementById(divid).innerHTML = fill;
	else document.getElementById(divid).innerHTML = "";
}



