// JavaScript Document
$(document).ready(function(){
	$('a').click(function(){
		if($(this).attr("href")=="#"){
			return false;
		}
	});
	$('ul#nav > li').hover(function() {
			$('ul:first', this).show();
		},
		function() {
			$('ul:first', this).hide();
		});
		$('ul#nav li li').hover(function() {
			$('ul:first', this).each(function() {
				$(this).css('top', $(this).parent().position().top );
				$(this).css('left', $(this).parent().position().left );
				$(this).show();
			});
		},
		function() {
		$('ul:first', this).hide();
	});
});

function setHeight(){
	$('div#footerContainer').css("margin-top", 0);	
    var footHeight = $('div#mainContent').height();
    var docHeight = $(document).height();
    if ((docHeight - footHeight) > 55){
		$('div#footerContainer').css("margin-top", docHeight - 55);
    } else {	
		$('div#footerContainer').css("margin-top", footHeight + 30);
    }
	$('div#footerContainer').show();
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Please enter a valid Email Address")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Please enter a valid Email Address")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Please enter a valid Email Address")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Please enter a valid Email Address")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Please enter a valid Email Address")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Please enter a valid Email Address")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Please enter a valid Email Address")
		return false
	 }

	 return true					
}