$(document).ready(function(){
	// Let CSS know JS is here
	$('body').removeClass('js-false').addClass('js-true');
	$('#newsletterEmail').focus( function()  {
		$( '#newsletterEmail' ).val( '' ) ;
	}
	);
	
	$('#newsletterSubscribe').submit( function()  {
	
		return validateEmail( 'newsletterEmail' );
	}
	);
});
// JavaScript Document
var currentTab = null;
var currentList = null;
function onTabClick(_linkObj){
		var _classCurrent = 'current';
		
		//get current active tab if not set
		if(currentTab == null){
			currentTab = setCurrentTab(_classCurrent);	
		}
		
		if(currentTab == null || currentTab == 'undefined')
			return;
		
		//get current active list if not set
		if(currentList == null){
			currentList = setCurrentList(_classCurrent);	
		}
		
		if(currentList == null || currentList == 'undefined')
			return;		
		
		//get id-name of list to shownewsletterEmail
		var linkName = _linkObj.getAttribute('name');
		
		//get list to show
		//"-list" suffix = workaround for IE 6 
		var listToShow = document.getElementById(linkName+'-list'); 
		if(listToShow == null || listToShow == '')
			return;
		
		
		//clear old tab
		currentTab.className = '';
		//set new tab
		_linkObj.parentNode.className = _classCurrent;
		//save new tab for later
		currentTab = _linkObj.parentNode;
		
		//hide old list
		currentList.style.display = 'none';
 		//show current list
        if(document.all && navigator.userAgent.indexOf("Opera") == -1){
                    listToShow.style.display = 'block';
        }
        else{
                    listToShow.style.display = 'table';
        }
		//save current list for later
		currentList = listToShow;
}

function setCurrentTab(_className){
	var coll = document.getElementById('tabs').getElementsByTagName('li');
	for(var i=0; i<coll.length; i++){
		if(coll[i].className == _className){
			return coll[i];	
		}		
	}
	return 'undefined';
}

function setCurrentList(_className){
	var coll = document.getElementById('list-collection').getElementsByTagName('table');
	for(var i=0; i<coll.length; i++){
		if(coll[i].getAttribute('title') == _className){
			return coll[i];	
		}		
	}
	return 'undefined';
}

function showPop(u,w,h)
{
	mywin = window.open(u,"pop",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+w+',height='+h+'');
}

function FixSize()
{
	var x = document.pic.width + 32;
	var y = document.pic.height + 41;
	window.resizeTo(x,y);
}

function validateEmail( emailId ) {
	if(  $( '#'+emailId ).val() == '' ) { alert("You must enter an email"); $( '#'+emailId ).focus(); return false; }
	
		if($( '#'+emailId ).val() != '' )
		{
			Email = $( '#'+emailId ).val();
			at = Email.indexOf("@");
			dot = Email.indexOf(".");
			errmsg = "";
		
			if (Email == "") {
				errmsg = "Please enter email address.\n";
			}
			else if(at < 1 | dot < 1){
				errmsg = "The entered email address is not valid.\n";
			}
		
			if (errmsg != "") {
				alert(errmsg);
				return false;
			}
		}
		return true;
}