// JavaScript Document
function checklogin() {
// ** START **
x=document.getElementsByTagName('form')[1].id;
var elem = (document.getElementById) ? document.getElementById(x) : ((document.all) ? document.all[x] : null);
 if (isValid(elem)) {
    //elem.onsubmit();
    elem.submit();
 }
 
  // ** END **

}

function checkEnter(e,ourform){ //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)
  checklogin(); //submit the form
return false 
}
else{
return true 
}

}

function isValid(k) {
  
if (k.txtSubId.value == '') {
    alert( "Please enter your login id" );
    k.txtSubId.focus();
    return false ;
  }
  
 if (isEmpty(k.txtEmailAddress)) {
 		alert( "Please enter your password." );
    	k.txtEmailAddress.focus();
		k.txtEmailAddress.select();
    	return false ;
 	}
 else {
 	if (!isEmail(k.txtEmailAddress.value)) { 
    	alert( "Please enter your password." );
   		k.txtEmailAddress.focus();
		k.txtEmailAddress.select();
    	return false ;
  	}
   }
 
  return true
  
}

//function moveIt(q) {
	//if (q.length > 1) {
		//window.scrollBy(100, 200);
	//}
//}

function checkIt(q) {
 if (q.length > 1) {
	qstr = q.substring(1,3);
	if (qstr == "go") {
		showDiv();
	}
	else {
		window.scrollBy(100, 200);	
	}
 }  
}

function popitup(url) {
	newwindow=window.open(url,'name','height=400,width=450');
	if (window.focus) {newwindow.focus()}
	return false;
}

function isEmail (s)
{   if (isEmpty(s))
    // is s whitespace?
    if (isWhitespace(s)) return false;
    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isWhitespace (s)
{   var i;
    // Is s empty?
    if (isEmpty(s)) return true;
    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}

function isEmpty(s)
{
   return ((s == null) || (s.length == 0));
}
// Returns true if string s is empty or
// whitespace characters only.

function clickIt() {
   hideDiv();
   var elem = (document.getElementById) ? document.getElementById("frmPwd") : ((document.all) ? document.all["frmPwd"] : null);
   elem.submit();
}

function hideDiv() { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideshow').style.visibility = 'hidden'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideshow.visibility = 'hidden'; 
		} 
		else { // IE 4 
			document.all.hideshow.style.visibility = 'hidden'; 
		} 
	}
	
	if (window.location.search.length > 1) {
		window.location = "http://www.liquorguide.com.au/index.asp";
	}
}

function showDiv() { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideshow').style.visibility = 'visible'; 
	 } 
else { 
	if (document.layers) { // Netscape 4 
		document.hideshow.visibility = 'visible'; 
	} 
else { // IE 4 
	document.all.hideshow.style.visibility = 'visible'; 
	} 
  } 
} 