

/* MENU ANIMATIONS */
$('#menu li')
		.css({backgroundPosition: "45px -7px"})
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(45px 0)"}, {duration:300});
			$(this).find('span').stop().animate({backgroundPosition:"(0 5px)"}, {duration:300});
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(45px -7px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "45px -7px"});
			}});
			$(this).find('span').stop().animate({backgroundPosition:"(0 0px)"}, {duration:200});
		});


function myFocus(element) {
     if (element.value == element.defaultValue) {
       element.value = '';
     }
   }
   function myBlur(element) {
     if (element.value == '') {
       element.value = element.defaultValue;
     }
   }

//LOGIN

$(document).ready(function() { 
						   
		jQuery.fn.fadeToggle = function(speed, easing, callback) {
	   return this.animate({opacity: 'toggle'}, speed, easing, callback);
	}; 				   

	$('#franchise_login_closed').click(
		function() {
		  $('#franchise_login_closed').fadeToggle(100);
		  $('#franchise_login_open').fadeToggle(0);
		  $('#franchise_login_open').animate({"top": "0px"}, 300);

		  return false;
	});
	

});

//TOOLTIP

this.imagePreview = function(){	
		xOffset = 250;

		yOffset = 30;
	
	$("a.preview").click(function(e){ return false; });
								  
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");	
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});


/* READ MORE */


$(function(){
	var slideHeight = 180; // px
	var defHeight = $('.col1').height();
	if(defHeight >= slideHeight){
		$('.col1').css('height' , slideHeight + 'px');
		$('.read-more1').append('<a href="#">+ READ MORE!</a>');
		$('.read-more1 a').click(function(){
			var curHeight = $('.col1').height();
			if(curHeight == slideHeight){
				$('.col1').animate({
				  height: defHeight
				}, "normal");
				$('.read-more1 a').html('- CLOSE');
			
			}else{
				$('.col1').animate({
				  height: slideHeight
				}, "normal");
				$('.read-more1 a').html('+ READ MORE!');
			}
			return false;
		});
	}
});



$(function(){
	var slideHeight = 180; // px
	var defHeight = $('.col2').height();
	if(defHeight >= slideHeight){
		$('.col2').css('height' , slideHeight + 'px');
		$('.read-more2').append('<a href="#">+ READ MORE!</a>');
		$('.read-more2 a').click(function(){
			var curHeight = $('.col2').height();
			if(curHeight == slideHeight){
				$('.col2').animate({
				  height: defHeight
				}, "normal");
				$('.read-more2 a').html('- CLOSE');
			
			}else{
				$('.col2').animate({
				  height: slideHeight
				}, "normal");
				$('.read-more2 a').html('+ READ MORE!');
			}
			return false;
		});
	}
});

$(function(){
	var slideHeight = 180; // px
	var defHeight = $('.col3').height();
	if(defHeight >= slideHeight){
		$('.col3').css('height' , slideHeight + 'px');
		$('.read-more3').append('<a href="#">+ READ MORE!</a>');
		$('.read-more3 a').click(function(){
			var curHeight = $('.col3').height();
			if(curHeight == slideHeight){
				$('.col3').animate({
				  height: defHeight
				}, "normal");
				$('.read-more3 a').html('- CLOSE');
			
			}else{
				$('.col3').animate({
				  height: slideHeight
				}, "normal");
				$('.read-more3 a').html('+ READ MORE!');
			}
			return false;
		});
	}
});


/* FRANCHISEE FORM VALIDATE */

$(document).ready(function() { 
$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });



  $("#submitfranchise").click(function() {
$('.error').hide();

		
	  var name = $("input#first_name").val();
		if (name == "First Name*" || name == " ") {
      $("label#name_error").show();
      $("input#first_name").focus();
      return false;
    }
	
	  var lname = $("input#last_name").val();
		if (lname == "Last Name*" || lname == " ") {
      $("label#lname_error").show();
      $("input#last_name").focus();
      return false;
    }
	
	  var email = $("input#email").val();
		if (email == "Email*" || email == " ") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
	
	  var phone = $("input#phone").val();
		if (phone == "Phone*" || phone == " ") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
	
	  var time = $("select#00N30000000fNn3").val();
		if (time == "Please Select an Option") {
      $("label#time_error").show();
      $("select#00N30000000fNn3").focus();
      return false;
    }
	
	 var capital = $("select#00N30000000fNjJ").val();
		if (capital == "Please Select an Option") {
      $("label#capital_error").show();
      $("select#00N30000000fNjJ").focus();
      return false;
    }
	
	 var mobile = $("input#mobile").val();
	 var city = $("input#city").val();
	 var state = $("input#state").val();
	 var territory_interest = $("input#00N30000000fNn4").val();
	 var lead_source = $("select#lead_source").val();
	 
	 var hidden1 = $("input#hidden1").val();
	 var hidden2 = $("input#hidden2").val();
	
	
	
		
		var dataString = 'name='+ name + '&lname=' + lname + '&email=' + email + '&phone=' + phone + '&time=' + time + '&capital=' + capital+ '&mobile=' + mobile+ '&city=' + city+ '&state=' + state+ '&territory_interest=' + territory_interest+ '&lead_source=' + lead_source;
		//alert (dataString);return false;
		

	});
});


 });
 

 
 
/* BACKGROUND POSITION SCRIPT */
(function($){if(!document.defaultView||!document.defaultView.getComputedStyle){var oldCurCSS=jQuery.curCSS;jQuery.curCSS=function(elem,name,force){if(name==='background-position'){name='backgroundPosition'}if(name!=='backgroundPosition'||!elem.currentStyle||elem.currentStyle[name]){return oldCurCSS.apply(this,arguments)}var style=elem.style;if(!force&&style&&style[name]){return style[name]}return oldCurCSS(elem,'backgroundPositionX',force)+' '+oldCurCSS(elem,'backgroundPositionY',force)}}var oldAnim=$.fn.animate;$.fn.animate=function(prop){if('background-position'in prop){prop.backgroundPosition=prop['background-position'];delete prop['background-position']}if('backgroundPosition'in prop){prop.backgroundPosition='('+prop.backgroundPosition}return oldAnim.apply(this,arguments)};function toArray(strg){strg=strg.replace(/left|top/g,'0px');strg=strg.replace(/right|bottom/g,'100%');strg=strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var res=strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]]}$.fx.step.backgroundPosition=function(fx){if(!fx.bgPosReady){var start=$.curCSS(fx.elem,'backgroundPosition');if(!start){start='0px 0px'}start=toArray(start);fx.start=[start[0],start[2]];var end=toArray(fx.options.curAnim.backgroundPosition);fx.end=[end[0],end[2]];fx.unit=[end[1],end[3]];fx.bgPosReady=true}var nowPosX=[];nowPosX[0]=((fx.end[0]-fx.start[0])*fx.pos)+fx.start[0]+fx.unit[0];nowPosX[1]=((fx.end[1]-fx.start[1])*fx.pos)+fx.start[1]+fx.unit[1];fx.elem.style.backgroundPosition=nowPosX[0]+' '+nowPosX[1]}})(jQuery);