function trimstring (str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}



function popup_msg(msg)
      {
      if (trimstring(msg) != ""){
	      msg = "<div style='vertical-align:bottom;'>" + msg + "</div>";
	      jQuery(document).ready(function() {
	      jQuery.lightbox(jQuery(msg + " "), {'width':400,'height':100});
		  });
	      }
      }

  (function (jQuery) {
jQuery.fn.vAlign = function() {
	return this.each(function(i){
	var h = jQuery(this).height();
	var oh = jQuery(this).outerHeight();
	var mt = (h + (oh - h)) / 2;	
	jQuery(this).css("margin-top", "-" + mt + "px");	
	jQuery(this).css("top", "50%");
	jQuery(this).css("position", "absolute");	
	});	
};
})(jQuery);

(function (jQuery) {
jQuery.fn.hAlign = function() {
	return this.each(function(i){
	var w = jQuery(this).width();
	var ow = jQuery(this).outerWidth();	
	var ml = (w + (ow - w)) / 2;	
	jQuery(this).css("margin-left", "-" + ml + "px");
	jQuery(this).css("left", "50%");
	jQuery(this).css("position", "absolute");
	});
};
})(jQuery);

jQuery(document).ready(function() {

jQuery(".disabledLink").live("click",function(){
alert("disabled!");
return false;

});


jQuery(".launchVideos").click( function(){
		return false;
    alert("OK");
    jQuery('#videoModal').modal({overlayClose:true,minHeight:465,minWidth:820,maxWidth:820,maxheight:465,opacity:95});


});

jQuery(".vidLink").live('click', function() {
content=jQuery(this).html();
id=jQuery(this).attr('id');
id=id.replace("vid","");
jQuery("#topPopout").html('<h2>HFA Video Series</h2><iframe id="embedVideo" src="http://player.vimeo.com/video/'+id+'?title=0&amp;byline=0&amp;portrait=0&amp;autoplay=1" width="500" height="350" frameborder="0"></iframe><p id="vidInfo"><a href="/27640297">Benefits of Affiliating with HFA</a> from <a href="/harryfoxagency">Harry Fox Agency (HFA)</a> on <a href="/">Vimeo</a>.</p>');
jQuery("#vidInfo").html(content);

}); 



jQuery("#noJavaScript").hide();
jQuery("#jscript").show();
//end popout

	if ( jQuery("#leftColsNav").length > 0 )
			setAccordion('leftColsNav','subOpen');
			
	if ( jQuery("#leftLinks").length > 0 )
			setAccordion('leftLinks','lLinkOpen');
			
	 jQuery('#leftColsNav h3 b').hover(function(){jQuery(this).addClass('hover'); jQuery(this).prev().addClass('hover');}, function(){jQuery(this).removeClass('hover'); jQuery(this).prev().removeClass('hover');});
	 jQuery('#leftLinks li h3 b').hover(function(){ jQuery(this).addClass('hover'); }, function(){ jQuery(this).removeClass('hover'); });
	 
	 jQuery('button, .loginButn input').hover(function(){jQuery(this).css('background-position','left bottom');}, function(){jQuery(this).css('background-position','left top');});
	 jQuery('.searchSubmit').hover(function(){jQuery(this).parent(".searchHere").css('background-position','left bottom');}, function(){jQuery(this).parent(".searchHere").css('background-position','left top');});
	 
	 //jQuery('#mainNav li').hover(function(){  if(process==0){ process=1; jQuery(this).children('ul').slideDown('fast',function(){process=0}); jQuery(this).addClass('hover'); } }, function(){ if(process==0){ jQuery(this).children('ul').hide(); jQuery(this).removeClass('hover'); }});
	 
	 jQuery('#mainNav li').hover(function(){ jQuery(this).addClass('hover'); }, function(){ jQuery(this).removeClass('hover'); });
	 
	 
	 
	 //form tab display
	 jQuery(".comnTab em").click( function(){
		jQuery('.comnTab .comnTab').hide();
		jQuery('.comnTab .tabMain').hide();
		jQuery('.comnTab .butn_div').hide();
		jQuery('.comnTab em').removeClass('tabOpen');
		
		jQuery(this).addClass('tabOpen');
		jQuery(this).next('.tabMain').show();
		jQuery(this.parentNode).find('.butn_div').show()
	 } );
	 
	 jQuery('.butnNextImgry').click( function(){
		var res = formValidation();
		if( res ){
			jQuery('.comnTab .comnTab').hide();
			jQuery('.comnTab .tabMain').hide();
			jQuery('.comnTab .butn_div').hide();
			jQuery('.comnTab em').removeClass('tabOpen');
			
			jQuery('#cc_tab2 em').addClass('tabOpen');
			jQuery('#cc_tab2 .tabMain').show();
			jQuery('#cc_tab2 .butn_div').show();
		}
	 } );
	 
	 jQuery('.butnNextDisplay').click( function(){
	 	var res = formValidation();
		if( res ){
			jQuery('.comnTab .comnTab').hide();
			jQuery('.comnTab .tabMain').hide();
			jQuery('.comnTab .butn_div').hide();
			jQuery('.comnTab em').removeClass('tabOpen');
			
			jQuery('#cc_tab3 em').addClass('tabOpen');
			jQuery('#cc_tab3 .tabMain').show();
			jQuery('#cc_tab3 .butn_div').show();
		}
	 } );
	 jQuery('.butnNextMeta').click( function(){
	 	var res = formValidation();
		if( res ){
			jQuery('.comnTab .comnTab').hide();
			jQuery('.comnTab .tabMain').hide();
			jQuery('.comnTab .butn_div').hide();
			jQuery('.comnTab em').removeClass('tabOpen');
			
			jQuery('#cc_tab4 em').addClass('tabOpen');
			jQuery('#cc_tab4 .tabMain').show();
			jQuery('#cc_tab4 .butn_div').show();
		}
	 } );
	 
	 
	 jQuery('#qckLInk1 input:even').click(function(){ jQuery("#quickLinkBox").slideDown(); });
	 jQuery('#qckLInk1 input:odd').click(function() { jQuery("#quickLinkBox").slideUp();   });
	 
	 jQuery('#qckLInk2 input:even').click(function(){ jQuery("#homePageBox").slideDown(); });
	 jQuery('#qckLInk2 input:odd').click(function() { jQuery("#homePageBox").slideUp();   });
	 
	 //limit text input for the textarea of class 'limitTextArea'
	 
	 jQuery('.charCount1').keyup( function(e){
	 	
		if( jQuery(this).val().length>50 ){
			var tmp = jQuery('#hpc1').val();
			tmp = tmp.substr(0,50);
			jQuery('.charCount1').val(tmp);
		}
		jQuery('#hpcc1').html( jQuery(this).val().length );
		return false;
	 } );
	 jQuery('.charCount2').keyup( function(e){
	 	
		if( jQuery(this).val().length>50 ){
			var tmp = jQuery('#hpc2').val();
			tmp = tmp.substr(0,50);
			jQuery('.charCount2').val(tmp);
		}
		jQuery('#hpcc2').html( jQuery(this).val().length );
		return false;
	 } );
	 
	//table hover effect  
	jQuery('.tbl_04 tr, .tbl_05 tr, .tbl_02 tr').hover(function(){ jQuery(this).addClass('clr_01'); }, function(){ jQuery(this).removeClass('clr_01'); } );
	jQuery('.tbl_03 tr').hover(function(){ jQuery(this).addClass('clr_02'); }, function(){ jQuery(this).removeClass('clr_02'); } );
	jQuery('.tbl_01 tr').hover(function(){ jQuery(this).addClass('clr_01'); jQuery(this).removeClass('clr_02'); }, function(){ jQuery(this).addClass('clr_02'); jQuery(this).removeClass('clr_01'); } );

	 //if sub links are unavailable, then hide [+/-];
	 var allLiTags = jQuery('#leftColsNav').children('li');
	 for(i=0; i < allLiTags.length; i++){
		 if(jQuery(allLiTags[i]).find('ul').length == 0)
		 	jQuery(allLiTags[i]).find('h3 b').hide();
	 }
	 
	 jQuery('.editPop').click(
		function(){
			jQuery(this).nextAll(".popUpByEdit").show("slow");
			if(jQuery(this.parentNode).hasClass("bFeature")){
				jQuery("#botmFeature").css('z-index','5');
			}
		}
	);
	
	jQuery('.closePop').click(
		function(){
			jQuery(this).offsetParent().hide("slow");
			var allPopInBFeature = jQuery('.bFeature .popUpByEdit');
			var index=jQuery('.bFeature .submitPop').index(this);
			var reSetZIndex=1;
			for(i=0; i < allPopInBFeature.length; i++){
				if(index!==i && !jQuery(allPopInBFeature[i]).is(":hidden")){
					reSetZIndex=0;
				}
			}
			if(jQuery(this.parentNode.parentNode.parentNode.parentNode).hasClass("bFeature") && reSetZIndex==1 ){
				jQuery("#botmFeature").css('z-index','1');
			}
		}
	);
	 
});

	function setAccordion(id,cls){
		jQuery('#'+ id +' h3 b').click(
			function() {
				if (jQuery(this).parent().next().is(":hidden")){
					jQuery(this).parent().next().slideDown("slow");
					jQuery(this).parent().parent().addClass(cls);
					jQuery(this).parent().parent().siblings().find('ul').slideUp("slow", function(){jQuery(this.parentNode).removeClass(cls);});
				}
				else{
					jQuery(this).parent().parent().find('ul').slideUp("slow", function(){jQuery(this.parentNode).removeClass(cls);});
				}
			}
		);
	}


  



