leftpos =0
if(screen) {
leftpos = screen.width
}
rightpos=0
if (screen) {
rightpos = screen.height
}


function isEmpty(inputStr){
	if ( inputStr == null || inputStr == "" ) {
   	return true
}
else {
 		return false  
}
}  

function ValidEmail(Str)
{
	var invalid = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	var valid = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/;

	return (!invalid.test(Str) && valid.test(Str))
}


function openpanel(theURL,winName,features) 
{
window.open(theURL,winName,features);
}

function cancel(lang) {
	

	if(lang == 'Spanish'){
		
			 if (confirm("¿Está seguro que quiere cancelar su inscripción?\n\nEs permitido cancelar su inscripción y regresar a la página de inicio\nCancelar para regresar a inscripción")){
		 	 location = "start.asp"
		 	}
		 
		
	}else if (lang == 'Portuguese'){
			 if (confirm("Você tem certeza que desja cancelar seu registro?\n\nOK para cancelar seu registro\n e voltar à página inicial.")){
		 	 location = "start.asp"
			 }
			
		}else{
	
    		if (confirm("Are you sure you wish to cancel your registration?\n\nOK to cancel your registration and return to the start page.\nCancel to return to your registration.")){
		 	 location = "start.asp"
    		}
		}
	
}


function ZipCodeLookup(){

	if (document.mainform.zipCode) var querystr = "?" + "zip=" + document.mainform.zipCode.value;
	
	
	// Process ZipCode lookup
	if (window.showModalDialog)
  {
    retval = showModalDialog("zips.php" + querystr,"","dialogWidth:20;dialogHeight:10;center:1;status=1");
  }
  else
  {
    winModalWindow = window.open ("zips.php" + querystr,"","dependent=yes,width=20,height=10")
  }

	
	// Fill in form fields with returned values IE
	if (navigator.appName == 'Netscape') {
	}
	else{
	if(retval[1] != ''){
		if(document.mainform.city) 	document.mainform.city.value = retval[1];
		if(document.mainform.idState) 	document.mainform.idState.value = retval[2];
		if(document.mainform.idCountry)	document.mainform.idCountry.value = 'United States';
	}
	}
	
}


function IsNum(ValueIn) {
   ValidFlag = true
   if (ValueIn == "") {
      ValidFlag = false
   }
   for (i=0; i<ValueIn.length; i++) {
      if (ValueIn.charAt(i) < "0") {
          ValidFlag = false
      }
      if (ValueIn.charAt(i) > "9") {
          ValidFlag = false
      }
   }
   return ValidFlag
}

function PartNo_onBlur(){
PartNoLookupAjax()
}

function PartNoLookupAjax(){

	var retval;
	var querystr;
	var strResponse;
	//var resp = "test";
	
	if (document.partNo.calmark){
		
	 	querystr = "crossref.php?calmark=" + document.partNo.calmark.value;
	 
	}
	
	if(document.partNo.calmark.value != ''){
		
		
		loadXMLDoc(querystr, "partNo");

		
	}



}


//Set the ajax reusable variables
//


var xmlhttp;
var resp;

//

function loadXMLDoc(url, type)
{
xmlhttp=null
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  	xmlhttp=new XMLHttpRequest()
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  }
	if (xmlhttp!=null)
	  {
	  	if(type == "partNo"){ //allow for this to be used with other functions
	 		xmlhttp.onreadystatechange=partNo_Change
	 	}
	  	xmlhttp.open("GET",url,true)
	  	xmlhttp.send(null)
	  }
	else
	  {
	  	PartNoLookup();
	  }
}

function partNo_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {
    	retval =  xmlhttp.responseText;
		
		if(retval != '')
		{
	
			if(retval.indexOf('ERRORS') != -1)
			{
					document.getElementById('error').innerHTML = retval;
					document.partNo.simonResult.value = '';
			}
			else if(document.partNo.simonResult)
			{
				document.partNo.simonResult.value = retval;
				document.getElementById('error').innerHTML = '';
			}
		}
		else
		{		
			document.partNo.simonResult.value = "Invalid Response";
		}
		
    	
    }
    
  else
    {
    	retval =  "";
    }
  }
}

/***** DOM Utils ****/
var isNav4, isNav6, isIE4;

/*
 * Browser version snooper; determines your browser
 * (Navigator 4, Navigator 6, or Internet Explorer 4/5)
 */
function setBrowser()
{
    if (navigator.appVersion.charAt(0) == "4")
    {
        if (navigator.appName.indexOf("Explorer") >= 0)
        {
            isIE4 = true;
        }
        else
        {
            isNav4 = true;
        }
    }
    else if (navigator.appVersion.charAt(0) > "4")
    {
        isNav6 = true;
    }
}

/*
 *
 * Given an id and a property (as strings), return
 * the given property of that id.  Navigator 6 will
 * first look for the property in a tag; if not found,
 * it will look through the stylesheet.
 *
 * Note: do not precede the id with a # -- it will be
 * appended when searching the stylesheets
 *
 */
function getIdProperty( id, property )
{
    if (isNav6)
    {
        var styleObject = document.getElementById( id );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            if (styleObject[property])
            {
                return styleObject[ property ];
            }
        }
        styleObject = getStyleBySelector( "#" + id );
        return (styleObject != null) ?
            styleObject[property] :
            null;
    }
    else if (isNav4)
    {
        return document[id][property];
    }
    else
    {
        return document.all[id].style[property];
    }
}

/*
 *
 * Given an id and a property (as strings), set
 * the given property of that id to the value provided.
 *
 * The property is set directly on the tag, not in the
 * stylesheet.
 *
 */
function setIdProperty( id, property, value )
{
    if (isNav6)
    {
        var styleObject = document.getElementById( id );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            styleObject[ property ] = value;
        }
        
    }
    else if (isNav4)
    {
        document[id][property] = value;
    }
    else if (isIE4)
    {
         document.all[id].style[property] = value;
    }
}

function showdiv( divNum )
{
    if (getIdProperty(divNum, "display") != "block" )
    {
        setIdProperty(divNum, "display", "block");
        
    }
    else
    {
        setIdProperty(divNum, "display", "none");
        
    }
}

function imageset()
{
	document.getElementById("slideshow").innerHTML = '<img src="img/slideshow_1.jpg" alt="slideshow placeholder" />';	
}

function slidereturn()
{
	document.getElementById("slideshow").innerHTML = "<scr" + "ipt type=\"text/javascript\">new fadeshow(fadeimages,597, 301, 0, 4000, 1, 0);</scr" + "ipt>";
}

function popup(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}


var i;
function resize() {
  i=0;
//  if (navigator.appName == 'Netscape') i=20;
  if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1 && window.navigator.userAgent.indexOf('SV1') != -1) {
      i=30; //This browser is Internet Explorer 6.x on Windows XP SP2
  } else if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) {
      i=0; //This browser is Internet Explorer 6.x
  } else if (window.navigator.userAgent.indexOf('Firefox') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) {
      i=25; //This browser is Firefox on Windows
  } else if (window.navigator.userAgent.indexOf('Mozilla') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) {
      i=45; //This browser is Mozilla on Windows
  } else {
      i=80; //This is all other browsers including Mozilla on Linux
  }
  if (document.documentElement && document.documentElement.clientWidth) {
//    frameWidth = document.documentElement.clientWidth;
//    frameHeight = document.documentElement.clientHeight;

  imgHeight = document.images[0].height+40-i;
  imgWidth = document.images[0].width+20;

  var height = screen.height;
  var width = screen.width;
  var leftpos = width / 2 - imgWidth / 2;
  var toppos = height / 2 - imgHeight / 2;

    frameWidth = imgWidth;
    frameHeight = imgHeight+i;

  window.moveTo(leftpos, toppos);


//  window.resizeTo(imgWidth, imgHeight);
  window.resizeTo(frameWidth,frameHeight+i);
	}
  else if (document.body) {
    window.resizeTo(document.body.clientWidth, document.body.clientHeight-i);
  }
  self.focus();
}

function keycheck(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		PartNo_onBlur() //do the deed
		return false
	}
	else{
		return true
	}

}
