// JavaScript Document

$(document).ready(function() {
	matchHeights();	
	addEv();
	sfHover();
	styleMenus();
});


function sfHover() {
	// for IE6
	  $("#subnav li").mouseover(function(){
     $(this).addClass("sfhover");
    }).mouseout(function(){
      $(this).removeClass("sfhover");
    });
	
}


function matchHeights() {
var maxH=0; // on selected divs with class match
	maxH=0;	$.each($(".match"),function(){if( $(this).height() > maxH ) { maxH=$(this).height(); }});					   
	$(".match").height(maxH);
	maxH=0;	$.each($(".match2"),function(){if( $(this).height() > maxH ) { maxH=$(this).height(); }});					   
	$(".match2").height(maxH);
	maxH=0;	$.each($(".match3"),function(){if( $(this).height() > maxH ) { maxH=$(this).height(); }});					   
	$(".match3").height(maxH);
}

function addEv() {
	// conditional add events
	// see MP form.js for additional mod
	
var eml="Your email"; // initial text

 $("#lpml").attr("value",eml); 
	
 $("#mp_submit").click(function () { 
			if( $("#lpml").attr("value")==eml ) { $("#lpml").attr("value", ""); }     
	}); 	
 
 $("#mp_submit").hover(function () {	$("#lpml").blur(); if( $("#lpml").attr("value")==eml ) { $("#lpml").attr("value", ""); }     }); 	 
	 
	 // open external links in new window
	 $("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");  
}


function styleMenus(topID) {

	if(topID==7) { // clinic
		$("#nav .current_page_item a,#nav .current_page_parent a,#nav .current_page_ancestor a").css({'background-color' : '#BCE0D4', 'color' : '#000000'	});
		$("#top").css({'border-bottom' : '3px solid #BCE0D4'});
		$("#subnav, #subnav a").css({'background-color' : '#DDECE7', 'color' : '#000000'});
		$("#logo").attr({src: "/wp-content/themes/lp/images/tpl/logoClinic.gif"});
		  $("#subnav a").hover(
      function () {  $(this).css({'background-color' : '#FFF', 'color' : '#000000'});  }, 
      function () {  $(this).css({'background-color' : '#DDECE7', 'color' : '#000000'}); }
    		);
		
	} else if (topID==9) { // training
		$("#nav .current_page_item a,#nav .current_page_parent a,#nav .current_page_ancestor a").css({'background-color' : '#FF9C04', 'color' : '#000000'	});
		$("#top").css({'border-bottom' : '3px solid #FF9C04'});
		$("#subnav, #subnav a").css({'background-color' : '#FFAD34', 'color' : '#000000'});
		$("#logo").attr({src: "/wp-content/themes/lp/images/tpl/logoTraining.gif"});
		  $("#subnav a").hover(
      function () {  $(this).css({'background-color' : '#FFF', 'color' : '#000000'});  }, 
      function () {  $(this).css({'background-color' : '#FFAD34', 'color' : '#000000'}); }
    		);
	}
	
	
}



function checkML() {
// add some extra space to form	
//var tlh=$("#listform").height();
//$(".thelist").height(tlh);

//alert(tlh);

	if( $("#lpml").attr("value")=="" ) { 
		alert('please enter an email address'); 
		$("#lpml").focus();
		return false;
	}
return true;
}

