function toggleDiv(id,flagit) {
if (flagit=="1"){
  if (document.layers) document.layers[''+id+''].visibility = "show"
  else if (document.all) document.all[''+id+''].style.visibility = "visible"
  else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
  if (document.layers) document.layers[''+id+''].visibility = "hide"
  else if (document.all) document.all[''+id+''].style.visibility = "hidden"
  else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}
function ChangeColor(tableRow, highLight){
  if (highLight){
    tableRow.style.backgroundColor = '#f2f4ff';
		
  }
  else{
    tableRow.style.backgroundColor = '#ffffff';
  }
}
function DoNav(theUrl){
  document.location.href = theUrl;
}
function rl(imgDocID,imgObjName) {
  document.images[imgDocID].src = "images/" + imgObjName + ".gif"
}

function setFocus(aField) {
document.forms[0][aField].focus();
}

function isAnEmailAddress(aTextField) {
// 1+@3+ [or x@x.x] is as close as we will test

if (document.forms[0][aTextField].value.length<5) {
return false;
}
else if (document.forms[0][aTextField].value.indexOf("@") < 1) {
return false;
}
else if (document.forms[0][aTextField].value.length - document.forms[0][aTextField].value.indexOf("@") < 4) {
return false;
}
else { return true; }
}

function isEmpty(aTextField) {
if ((document.forms[0][aTextField].value.length==0) || (document.forms[0][aTextField].value==null)) {
return true;
}
else { return false; }
}

function validate() {
  // Step 1: check that required fields are
  // filled in, alert and exit without
  // submitting if not
  
  // check that the name field is valued
  if (isEmpty("t_title")) {
  	alert("Please fill in all required fields.");
  	setFocus("t_title");
  	return false;
  }
  
  
  // if we get this far everthing is ok, so
  // let the form submit
  return true;
}

	
function processAjax(url) {
  if (window.XMLHttpRequest) { // Non-IE browsers
    //scr=url+'&'+o;
		req = new XMLHttpRequest();
  	req.onreadystatechange = targetDiv;
  	try {
  	  req.open("GET", url, true);
  	} catch (e) {
    	alert(e);
  	}
		req.send(null);
  } else if (window.ActiveXObject) { // IE
    req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
  	  req.onreadystatechange = targetDiv;
  		req.open("GET", url, true);
  		req.send();
    }
  }

}

function targetDiv() {
  if (req.readyState == 4) { // Complete
    if (req.status == 200) { // OK response
  	  document.getElementById('content').innerHTML = req.responseText;
		} else {
  		alert("Problem: " + req.statusText);
  	}
		$('#tabs').tabs();
	}
} 

function requestPLs(url) {
  //alert (url);
	if (window.XMLHttpRequest) { // Non-IE browsers
    req = new XMLHttpRequest();
  	req.onreadystatechange = targetDivPL;
  	try {
  	  //req.open("GET", url, true);
			req.open("GET", url, true);
  	} catch (e) {
    	alert(e);
  	}
  	req.send(null);
  } else if (window.ActiveXObject) { // IE
    req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
  	  req.onreadystatechange = targetDivPL;
  		//req.open("POST", url, true);
			req.open("GET", url, true);
  		req.send();
  	}
  }
}

function targetDivPL() {
  if (req.readyState == 4) { // Complete
    if (req.status == 200) { // OK response
  	  document.getElementById('partslists').innerHTML = req.responseText;
		} else {
  		alert("Problem: " + req.statusText);
  	}
		$('#tabs').tabs( "select" , 2 );
  }
} 

function processOrder(url,p) {
  scr=url+'?p='+p;
	if (window.XMLHttpRequest) { // Non-IE browsers
    //scr=url+'?p='+p;
		req = new XMLHttpRequest();
  	req.onreadystatechange = targetOrder;
  	try {
  	  req.open("GET", scr, true);
  	} catch (e) {
    	alert(e);
  	}
  	req.send(null);
  } else if (window.ActiveXObject) { // IE
    req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
  	  req.onreadystatechange = targetOrder;
  		req.open("GET", scr, true);
  		req.send();
  	}
  }
}

function processPartQty(url,oi_id,qty) {
  scr=url+'?oiid='+oi_id+'&q='+qty;
	//alert (scr);
	if (window.XMLHttpRequest) { // Non-IE browsers
    req = new XMLHttpRequest();
  	req.onreadystatechange = targetOrder;
  	try {
  	  req.open("GET", scr, true);
  	} catch (e) {
    	alert(e);
  	}
  	req.send(null);
  } else if (window.ActiveXObject) { // IE
    req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
  	  req.onreadystatechange = targetOrder;
  		req.open("GET", scr, true);
  		req.send();
  	}
  }
}

function targetOrder() {
  if (req.readyState == 4) { // Complete
    if (req.status == 200) { // OK response
  	  document.getElementById('order').innerHTML = req.responseText;
		} else {
  		alert("Problem: " + req.statusText);
		}
		$('#tabsside').tabs( "select" , 1 );
	}
} 

function openSideTab(tab){
  $('#tabsside').tabs( "select" , tab );
}
