var type = "IE";	//Variable used to hold the browser name

BrowserSniffer();

//detects the capabilities of the browser
function BrowserSniffer() {
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";		//Opera
	else if (document.all) type="IE";														//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";													//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";							//Mozila e.g. Netscape 6 upwards
	else type = "IE";		//I assume it will not get here
}
function SetFooter(){
	if (document.all) {
		document.getElementById("footer_img").style.marginBottom = "-5px"	
	}														//Internet Explorer e.g. IE4 upwards
	
}

//Show and hide a layer
//id is the name of the layer
//action is either hidden or visible
//Seems to work with all versions NN4 plus other browsers
function ShowLayer(id, action){
	if (type=="IE") eval("document.all." + id + ".style.visibility='" + action + "'");
	if (type=="NN") eval("document." + id + ".visibility='" + action + "'");
	if (type=="MO" || type=="OP") eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
}


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function checkValidation ( addressField ) {
    

    return ( false );
}

function linkCheckValidation ( formField ) {
    if ( checkValidation ( formField ) == true ) {
        alert ( 'E-Mail Address Validates OK' );
    }

    return ( false );
}

function stringEmpty ( address ) {
    // CHECK THAT THE STRING IS NOT EMPTY
    if ( address.length < 1 ) {
        return ( true );
    } else {
        return ( false );
    }
}

function noAtSign ( address ) {
    // CHECK THAT THERE IS AN '@' CHARACTER IN THE STRING
    if ( address.indexOf ( '@', 0 ) == -1 ) {
        return ( true )
    } else {
        return ( false );
    }
}

function nothingBeforeAt ( address ) {
    // CHECK THERE IS AT LEAST ONE CHARACTER BEFORE THE '@' CHARACTER
    if ( address.indexOf ( '@', 0 ) < 1 ) {
        return ( true )
    } else {
        return ( false );
    }
}

function noLeftBracket ( address ) {
    // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN CHECK FOR LEFT BRACKET
    if ( address.indexOf ( '[', 0 ) == -1 && address.charAt ( address.length - 1 ) == ']' ) {
        return ( true )
    } else {
        return ( false );
    }
}

function noRightBracket ( address ) {
    // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN CHECK FOR RIGHT BRACKET
    if ( address.indexOf ( '[', 0 ) > -1 && address.charAt ( address.length - 1 ) != ']' ) {
        return ( true );
    } else {
        return ( false );
    }
}

function noValidPeriod ( address ) {
    // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN WE ARE NOT INTERESTED
    if ( address.indexOf ( '@', 0 ) > 1 && address.charAt ( address.length - 1 ) == ']' )
        return ( false );

    // CHECK THAT THERE IS AT LEAST ONE PERIOD IN THE STRING
    if ( address.indexOf ( '.', 0 ) == -1 )
        return ( true );

    return ( false );
}

function noValidSuffix ( address ) {
    // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN WE ARE NOT INTERESTED
    if ( address.indexOf ( '@', 0 ) > 1 && address.charAt ( address.length - 1 ) == ']' )
        return ( false );

    // CHECK THAT THERE IS A TWO OR THREE CHARACTER SUFFIX AFTER THE LAST PERIOD
    var len = address.length;
    var pos = address.lastIndexOf ( '.', len - 1 ) + 1;
    if ( ( len - pos ) < 2 || ( len - pos ) > 3 ) {
        return ( true );
    } else {
        return ( false );
    }
}




function Form1_Validator(theForm)
{


  if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }

  if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.company.focus();
    return (false);
  }



  if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.phone.focus();
    return (false);
  }



  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();

    return (false);
  }

if ( stringEmpty ( theForm.email.value ) ) {
	alert ( "Error! There is no E-Mail address entered" );
	    theForm.email.focus();

    return (false);
  }
    else if ( noAtSign ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address does not contain an '@' character" );
            theForm.email.focus();

    return (false);
  }
    else if ( nothingBeforeAt ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain at least one character before the '@' character" );
            theForm.email.focus();

    return (false);
  }
    else if ( noLeftBracket ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address contains a right square bracket ']',\nbut no corresponding left square bracket '['" );
            theForm.email.focus();

    return (false);
  }
    else if ( noRightBracket ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address contains a left square bracket '[',\nbut no corresponding right square bracket ']'" );
            theForm.email.focus();

    return (false);
  }
    else if ( noValidPeriod ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain a period ('.') character" );
            theForm.email.focus();

    return (false);
  }
    else if ( noValidSuffix ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain a two or three character suffix" );
            theForm.email.focus();

    return (false);
  }
    else {
        return (true);
    }

  
  return (true);
}

function validContest(theForm) {
	  
	  if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }
  

 
  
    if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();

    return (false);
  }

if ( stringEmpty ( theForm.email.value ) ) {
	alert ( "Error! There is no E-Mail address entered" );
	    theForm.email.focus();

    return (false);
  }
    else if ( noAtSign ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address does not contain an '@' character" );
            theForm.email.focus();

    return (false);
  }
    else if ( nothingBeforeAt ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain at least one character before the '@' character" );
            theForm.email.focus();

    return (false);
  }
    else if ( noLeftBracket ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address contains a right square bracket ']',\nbut no corresponding left square bracket '['" );
            theForm.email.focus();

    return (false);
  }
    else if ( noRightBracket ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address contains a left square bracket '[',\nbut no corresponding right square bracket ']'" );
            theForm.email.focus();

    return (false);
  }
    else if ( noValidPeriod ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain a period ('.') character" );
            theForm.email.focus();

    return (false);
  }
    else if ( noValidSuffix ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain a two or three character suffix" );
            theForm.email.focus();

    return (false);
  }
    else {
        return (true);
    }
   
	
	return (true);
}

function validQuestion(theForm) {
	  
	  if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }
  

  
  
    if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();

    return (false);
  }

if ( stringEmpty ( theForm.email.value ) ) {
	alert ( "Error! There is no E-Mail address entered" );
	    theForm.email.focus();

    return (false);
  }
    else if ( noAtSign ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address does not contain an '@' character" );
            theForm.email.focus();

    return (false);
  }
    else if ( nothingBeforeAt ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain at least one character before the '@' character" );
            theForm.email.focus();

    return (false);
  }
    else if ( noLeftBracket ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address contains a right square bracket ']',\nbut no corresponding left square bracket '['" );
            theForm.email.focus();

    return (false);
  }
    else if ( noRightBracket ( theForm.email.value ) ) {
        alert ( "Error! The E-Mail address contains a left square bracket '[',\nbut no corresponding right square bracket ']'" );
            theForm.email.focus();

    return (false);
  }
    else if ( noValidPeriod ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain a period ('.') character" );
            theForm.email.focus();

    return (false);
  }
    else if ( noValidSuffix ( theForm.email.value ) ) {
        alert ( "Error! An E-Mail address must contain a two or three character suffix" );
            theForm.email.focus();

    return (false);
  }
    else {
        return (true);
    }
     
	    	  if (theForm.getElementsByTagName(question).value == "")
  {
    alert("Please enter a value for the \"Question\" field.");
    theForm.getElementByTagName(question).focus();
    return (false);
  } 
  
	return (true);
}
