var $j = jQuery.noConflict();

//if(!$j.browser.msie){
//document.write('<script type="text/javascript" src="assets/js/flashEmbed.js"></script>');
//}

jQuery(document).ready(function($j){ 

// SWAP YOUTUBE VIDEOS
$j("a.youtube").click(function() {
	var video = $j(this).attr("alt");
	$j("#youtube").html(video);			   
});

// MAKE SEARCH FIELD BLANK WHEN CLICK IN
  $j("input[type=text]").focus(function () {
			if($j(this).hasClass('datepicker')){
			}
			else{
					$j(this).val("");
			}
    });

// TRANSFORM HR 
$j("hr").replaceWith("<div id='hr'><div>");

// TABS
// perform JavaScript after the document is scriptable. 
$j(function() { 
    // setup ul.tabs to work as tabs for each div directly under div.panes 
    $j("ul.tabs").tabs("div.panes > div"); 
});

// QUICK EDIT
$j("a.QE_Link").text("Edit");

// TRIM LATEST NEWS TITLE

	//set the desired length of string here
	var strlength1 = 30;
	
	//Go through all tag that match
	$j("span.trim").each(function() {
		//Get length of current string
		var textToTrim = $j(this).html().length;
		//Initialize as string
		var tagText = "";
		
		//If it is greater than the set number...
		if(textToTrim > strlength1){
		
		//Get the current text
		tagText = $j(this).html();
		
		//Trim it to the specified length
		tagText = tagText.substring(0,strlength1);
		
		//Make overwrite current text with the new truncated text
		$j(this).html(tagText);
		
		//Add periods to the end
		$j(this).append('...');
		}
		else{
		//do nothing
		}
	});

// TRIM UPCOMING EVENT TITLE

	//set the desired length of string here
	var strlength2 = 25;
	
	//Go through all tag that match
	$j("#upcoming-content a.trim").each(function() {
		//Get length of current string
		var textToTrim = $j(this).html().length;
		//Initialize as string
		var tagText = "";
		
		//If it is greater than the set number...
		if(textToTrim > strlength2){
		
		//Get the current text
		tagText = $j(this).html();
		
		//Trim it to the specified length
		tagText = tagText.substring(0,strlength2);
		
		//Make overwrite current text with the new truncated text
		$j(this).html(tagText);
		
		//Add periods to the end
		$j(this).append('...');
		}
		else{
		//do nothing
		}
	});

// TRIM YOUTUBE VIDEO TITLES ON HOME PAGE

//set the desired length of string here
	var strlength3 = 38;
	
	//Go through all tag that match
	$j("a.embedYouTube").each(function() {
		//Get length of current string
		var textToTrim = $j(this).html().length;
		//Initialize as string
		var tagText = "";
		
		//If it is greater than the set number...
		if(textToTrim > strlength3){
		
		//Get the current text
		tagText = $j(this).html();
		
		//Trim it to the specified length
		tagText = tagText.substring(0,strlength3);
		
		//Make overwrite current text with the new truncated text
		$j(this).html(tagText);
		
		//Add periods to the end
		$j(this).append('...');
		}
		else{
		//do nothing
		}
	});

// EFORM VALUE FIX
	$j("#form1 input#name").val("Full Name");
	$j("input#name").blur(function(){
		nameText = $j("input#name").val();
	  if(nameText == "") {
		  $j("input#name").val("Full Name");
		  }
	});
	
  $j("#form1 input#street").val("Street Address");
	$j("input#street").blur(function(){
		streetText = $j("input#street").val();
	  if(streetText == "") {
		  $j("input#street").val("Street Address");
		  }
	});


	$j("#form1 input#city").val("City");
		$j("input#city").blur(function(){
		cityText = $j("input#city").val();
	  if(cityText == "") {
		  $j("input#city").val("City");
		  }
	});

	
  $j("#form1 input#state").val("State");
  	$j("input#state").blur(function(){
		stateText = $j("input#state").val();
	  if(stateText == "") {
		  $j("input#state").val("State");
		  }
	});

  $j("#form1 input#zip").val("Zip");
  	$j("input#zip").blur(function(){
		zipText = $j("input#zip").val();
	  if(zipText == "") {
		  $j("input#zip").val("Zip");
		  }
	});

  $j("#form1 input#email").val("Email");
  	$j("input#email").blur(function(){
		emailText = $j("input#email").val();
	  if(emailText == "") {
		  $j("input#email").val("Email");
		  }
	});

  $j("#form1 input#telephone").val("Telephone Number");
  	$j("input#telephone").blur(function(){
		phoneText = $j("input#telephone").val();
	  if(phoneText == "") {
		  $j("input#telephone").val("Telephone Number");
		  }
	});
	


});
