/**
 * syncHeight - jQuery plugin to automagically Snyc the heights of columns
 * Made to seemlessly work with the CCS-Framework YAML (yaml.de)
 * @requires jQuery v1.0.3
 *
 * http://blog.ginader.de/dev/syncheight/
 *
 * Copyright (c) 2007 
 * Dirk Ginader (ginader.de)
 * Dirk Jesse (yaml.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 1.0
 *
 * Usage:
 	$(document).ready(function(){
		$('p').syncHeight();
		$(window).resize(function(){ //if you want to update the columns after a Browser resize (optional)
			$('p').syncHeight();
		});
	});
 */

(function($) {
	$.fn.syncHeight = function(settings) {
		var max = 0;
		var browser_id = 0;
		var property = [
		   ['min-height','0px'],
			['height','1%']
		];

		// check for IE6 ...
		if($.browser.msie && $.browser.version < 7){
			browser_id = 1;
		}
		
		// get maximum element height ...
		$(this).each(function() {
			// fallback to auto height before height check ...
			$(this).css(property[browser_id][0],property[browser_id][1]);
			var val=$(this).height();
			val=val+10;
			if(val > max){
			   max = val;
			}
		});
		
		// set synchronized element height ...
 		$(this).each(function() {
  			$(this).css(property[browser_id][0],max+'px');
		});
		return this;
	};	
})(jQuery);


$(document).ready(function() {
   $('#searchForm input#search_term').attr("value", "");
   $('select#branch_state').change(function(){
      var wn_abbrev = $('select#branch_state option:selected').val();
      var wn_state = $('select#branch_state option:selected').text();
      newPage = "/locator/"+wn_abbrev;
      window.location = newPage;
   });
   $('.video-embed').each(function() {
      vidLink = $(this).find('a').attr('href');
      imgLink = $(this).find('img').attr('src');
      vidWidth = $(this).find('img').attr('width');
      vidHeight = $(this).find('img').attr('height');
      if (vidWidth=="") {vidWidth=445};
      if (vidHeight=="") {vidHeight=250};
      var totalHeight = parseInt(vidHeight) + 25;
      $(this).flash(
         {
            src: '/jcplayer.swf',
            width: parseInt(vidWidth),
            height: totalHeight,
            bgcolor: '#000000',
            align: "left",
            scale:"noscale",
            salign:"tl", 
            allowScriptAccess:"samedomain", 
            allowFullScreen:"true",
            flashvars: {videoURL:vidLink, autoPlay: 'false', scaleMode:'exactFit', startPhotoSource: imgLink, highlightColor:'#EDA525', width:parseInt(vidWidth), height:parseInt(vidHeight), backgroundColor1:"#000000"}
         },
         {version: 9}
         );
   });
   wrongLink= $('a#watch-live').attr('href');
   rightLink=wrongLink.substr(7);
   $('a#watch-live').attr({href:rightLink}); 


// Newsletter Signup
$("#mcms_newsletter_first_name").val("First Name").addClass("clickClear");
$("#mcms_newsletter_last_name").val("Last Name").addClass("clickClear");

 $('#newsletter_text').removeClass('clearClick').addClass('clickClear');
 $('input.clickClear').focus(function() {
    startText = $(this).val();
    $(this).val('').addClass('focus');
 });
 $('input.clickClear').blur(function() {
    blurText = $(this).val();
    if (blurText == '') {
       $(this).val(startText).removeClass('focus');
    };
 });
});

