// Copyright Acro Media Inc. 1998-2002, www.acromediainc.com

graphicsDir = "/graphics/toolbar/";

function submitPO(form) {
  form.onsubmit = "";
  var newdiv = document.createElement('div');
  newdiv.innerHTML = "<input type='hidden' name='po' value=1>";
  document.getElementById('section1').appendChild(newdiv);
  form.submit();  
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = 0 + dc.indexOf(prefix);
	if (begin == -1){
		return 0;
	}
	begin += prefix.length;
	var end = 0 + document.cookie.indexOf(";", begin);
	if (end == -1){
		end = dc.length;
	}
	return unescape(dc.substring(begin, end));
}	

entryPoint = document.referrer;
entryPoint.toLowerCase();
if(entryPoint.indexOf("tonsoftoner") == -1){
	var expires = new Date();
	expires.setTime(expires.getTime() + 3E11);   // about 10 years = "forever"
	setCookie("entryPoint", document.referrer, 0, "/", ".tonsoftoner.com");
}

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function openUp(windowURL, windowWidth, windowHeight) {
	var topPos = "";
	var leftPos = "";
	if(!windowWidth) windowWidth = 0;
	if(!windowHeight) windowHeight = 0;
	if(windowWidth == 0){
		if(screen){
			windowWidth = screen.availWidth -10;
		}
		else{
			windowWidth = 790;
		}
		leftPos = ",left=0";
	}
	if(windowHeight == 0){
		if(screen){
			windowHeight = screen.availHeight -30;
		}
		else{
			windowHeight = 790;
		}
		topPos = ",top=0";
	}


	newWin = window.open(windowURL,"acromedia","toolbar=no,menubar=0,width="+windowWidth+",height="+windowHeight+topPos+leftPos+",scrollbars=yes,resizable=no");

//	if(javascript_version > 1.0){
//		setTimeout('newWin.focus();',100);
//	}
}

function checkValue(name){

	if(eval("document.detailsForm."+name+".value") == ""){
		eval("document.detailsForm."+name+".value = '1'");
	}
	else{
		eval("document.detailsForm."+name+".value = ''");
	}

}

function checkBox(name, otherName){
  var quantityValue = eval("document.detailsForm."+otherName+".value");
  
  if(quantityValue == "" || quantityValue == 0){
		eval("document.detailsForm."+name+".checked = false");
	}
	else{
		eval("document.detailsForm."+name+".checked = true");
	}
}

function setCursor(){
	if(document.forms.manufacturerSearchForm){
		document.forms.manufacturerSearchForm.workingKeywords.focus();	
	}
}

/*addLoadEvent
************
add another event to the window.onload  event
*/
function addLoadEvent(newOnload){
  var oldOnload = window.onload;
  if(typeof window.onload != 'function'){
    window.onload = newOnload;
  }
  else{
    window.onload = function(){
      if(oldOnload){
        oldOnload();
      }
      newOnload();
    }
  }
}

function clearValue(field) {
  if (field.defaultValue == field.value)
    field.value = ""; 
}

function showCVM() {
  var section1 = document.getElementById('section1');
  var section0 = document.getElementById('section0');
  
  section1.className='showLayer';
  section0.className='hideLayer';  
}

function closeCVMWindow() {
  var section1 = document.getElementById('section1');
  var section0 = document.getElementById('section0');
  
  section1.className='hideLayer';
  section0.className='showLayer';  
}

function show(theDiv, theHideDiv){
  document.getElementById(theDiv).style.display = 'block';
  document.getElementById(theHideDiv).style.display = 'none';
}

function hide(theDiv, theHideDiv){
  document.getElementById(theDiv).style.display = 'none';
}

//setup the onload functions
addLoadEvent(setCursor);

