function showElement(elementName)
	{
	document.getElementById(elementName).style.display="block";
	}
 function hideElement(elementName)
	{
	document.getElementById(elementName).style.display="none";
	}

 
 function getXMLHTTPRequest()
{
var request = false;
try
  {
    request = new XMLHttpRequest();
  }
catch(err1)
  {
  try
    {
    request = new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch(err2)
    {
    try
      {
      request = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(err3)
        {
        request = false;
        }
    }
  }
return request;
}

var xmlhttp = getXMLHTTPRequest();

function callAjax(landing, useScript, addVar, printVar) {
  var serverPage = useScript;
  myRand = parseInt(Math.random()*9999999);
  var modurl = serverPage+"?rand="+myRand+addVar+printVar;
  xmlhttp.open("GET", modurl, true);
  xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    document.getElementById(landing).innerHTML = xmlhttp.responseText;
   } else {
  document.getElementById(landing).innerHTML = 'Please Wait....';
  }
}
xmlhttp.send(null);
}

function callAjax2(landing, useScript, addVar, printVar) {
  document.getElementById(landing).innerHTML = "Loading...";
  var serverPage = useScript;
  myRand = parseInt(Math.random()*9999999);
  var modurl = serverPage+"?rand="+myRand+addVar+printVar;
  xmlhttp.open("GET", modurl, true);
  xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    document.getElementById(landing).innerHTML = xmlhttp.responseText;
   } else {
    
  }
}
xmlhttp.send(null);
}

function selectRadio(radioId){
  document.getElementById(radioId).checked='checked';
}  

function showOther(other_id, d_value){
  if (d_value == 'Other'){
    document.getElementById(other_id).style.display='inline';
  }else{
    document.getElementById(other_id).style.display='none';
  }
}

function validEmail(email) {
	invalidChars = " /:,;"
	
	if (email == "") {
		return false
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}
	if (periodPos+3 > email.length) {
		return false
	}
	return true
}

function submitIt(contactusForm) {
        document.getElementById('submit_bttn').disabled=true;
        contactMethod = -1
	for (i=0; i<document.contactusForm.contact.length; i++) {
		if (document.contactusForm.contact[i].checked) {
			contactMethod = i
		}
	}
	if (contactMethod == -1) {
		alert("Please select a preferred contact method.")
		document.getElementById('submit_bttn').disabled=false;
	}else if (document.contactusForm.first_name.value == "") {
		alert("Please enter your name.")
		document.getElementById('submit_bttn').disabled=false;
	}else{
	document.contactusForm.submit();
	}
}

function checkEmail(contactusForm) {
	if (!validEmail(contactusForm.email.value)) {
		alert("Please enter a valid email address.")
		contactusForm.email.focus()
		contactusForm.email.select()
		return false
	}
	
	return true
}

function checkPhone(contactusForm) {
	if (document.contactusForm.phone.value == "") {
		alert("Please enter a phone number.")
		contactusForm.phone.focus()
		contactusForm.phone.select()
		return false
	}
	return true
}

function checkName(contactusForm) {
	if (document.contactusForm.first_name.value == "") {
		alert("Please enter your name.")
		contactusForm.name.focus()
		contactusForm.name.select()
	}
	document.contactusForm.submit();
}

function setStyle(x)
{
if (document.getElementById(x).value == "email@email.com")
{
document.getElementById(x).style.color="black";
document.getElementById(x).value="";
}
return true
}

function setEmail(x)
{
if (document.getElementById(x).value == "")
{
document.getElementById(x).value="email@email.com";
document.getElementById(x).style.color="#aeaeae";
}
return true
}

function useEmail(email)
{
if (document.contactusForm.email.value == "email@email.com")
{
alert("Please enter a valid email address or select contact by phone.")
document.contactusForm.email.focus()
document.contactusForm.email.select()
return false
}
return true
}

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(e, id) {

  var el;
  var x, y;              

  dragObj.elNode = document.getElementById(id);

  if (dragObj.elNode.nodeType == 3){
      dragObj.elNode = dragObj.elNode.parentNode;
    }
    
if(document.addEventListener) {
  window.captureEvents(Event.CLICK);
  x = e.pageX;
  y = e.pageY;
}
else if(document.attachEvent) {
  document.attachEvent('onclick');
  x = e.x;
  y = e.y;
}

dragObj.cursorStartX = x;
dragObj.cursorStartY = y;
dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10);
dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10);
if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 0;
dragObj.elNode.style.zIndex = ++dragObj.zIndex;

if (document.addEventListener) {
    document.addEventListener("mousemove", dragGo, true);
    document.addEventListener("mouseup", dragStop, true);
    e.preventDefault();
  }else{
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup", dragStop);
    e.cancelBubble = true;
    e.returnValue = false;
  }
}    

function dragGo(e) {

  var x, y;

  if(document.addEventListener) {
  window.captureEvents(Event.CLICK);
  x = e.pageX;
  y = e.pageY;
}
else if(document.attachEvent) {
  document.attachEvent('onclick');
  x = e.x;
  y = e.y;
}

  dragObj.elNode.style.left =
    (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  =
    (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";
    
  if (document.attachEvent) {
    e.cancelBubble = true;
    e.returnValue = false;
  }
  else if (document.addEventListener) {
    e.preventDefault();
}

}

function dragStop(event) {

  if (document.attachEvent) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup", dragStop);
  }
  else if (document.addEventListener) {
    document.removeEventListener("mousemove", dragGo, true);
    document.removeEventListener("mouseup", dragStop, true);
  }
}

billBoard = new Array(4);

billBoard[1] = "<img src='/images/pressure_seal_billboard01.jpg' alt='Pressure Seal Forms' style='padding:0 8px;' ";

billBoard[2] = "<img src='/images/pressure_seal_billboard02.jpg' alt='Pressure Seal Forms' style='padding:0 8px;' ";

billBoard[3] = "<img src='/images/pressure_seal_billboard03.jpg' alt='Pressure Seal Forms' style='padding:0 8px;' ";

billBoard[4] = "<img src='/images/pressure_seal_billboard04.jpg' alt='Pressure Seal Forms' style='padding:0 8px;' ";

var i = 1;
var stat = "on";
var onLo =  "onload='slideShow()' />"
var offLo =  "/>"

 function changeImage(num) {
   if (stat == "on"){cont = onLo;}else{cont = offLo;}
   document.getElementById('billboard').innerHTML = billBoard[num] + cont;
 }

 function nextImage() {
    if (i < 4) {i = i + 1;}else{i = 1;}
    if (stat == "on"){cont = onLo;}else{cont = offLo;}
    document.getElementById('billboard').innerHTML = billBoard[i] + cont;
 }

 function slideShow() {
    stat = "on";
    s_show = setTimeout("nextImage(onLo)",4000);
 }

function preloadImages() {
 if (document.images) {
	psbb1 = new Image
	psbb2 = new Image
	psbb3 = new Image

	psbb1.src = "/images/pressure_seal_billboard02.jpg"
	psbb2.src = "/images/pressure_seal_billboard02.jpg"
	psbb3.src = "/images/pressure_seal_billboard02.jpg"
 }
}