// JavaScript Document
var v
//
function init(){
	//start newsletter subscription
	if($('#nlsignupHolder').length != 0){
		v = jQuery("#nlsignupForm").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#nlsignupHolder"
				});
			}
		});
	}
	//start newsletter unsubscribe
	if($('#nlsubscribeHolder').length != 0){
		v = jQuery("#nlsubscribeForm").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#nlsubscribeHolder"
				});
			}
		});
	}
	//
	if($('#refer').length > 0){
		v = jQuery("#referForm").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					//target: "#referReturn"
					target: "#refer"
				});
			}
		});
	}
	//contact
	if($('#contact').length != 0){
		$.post("scripts/php/ajax_calls/contact_regions.php", {}, function(data){loadContactRegions_callback(data);}, "html");
	}
	//
	setupNav();
	//
	$('.footerNav').columnize({ columns:3 });
	//
	if($('#Map').length != 0){
		$('area').bind("click", selectRegion);
	}
	//
	checkRight();
}

function loadContactRegions_callback(data){
	$('#e_region').html(data);
}

function selectRegion(e){
	//alert($(this));
	//alert($(this).attr("id"));
	$('#e_region').val($(this).attr("id"));
	return false;
}

function setupNav(){
	//$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li").mouseover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
		$(this).find(".hasDrop").addClass("hasDropHover");

		$(this).hover(function() {
		}, function(){			
			$(this).find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
			$(this).find(".hasDrop").removeClass("hasDropHover");
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
}
///
function checkRight(){
	$('.colBoxMid').prepend('<img src="images/colBoxTop.gif" height="24" width="230" style="padding:0;margin:0;border:none;">');
	$('.colBoxMid').after('<div class="colBox"><img src="images/colBoxBot.gif" alt="" width="230" height="24""></div>');
}
