	
	$(function(){
   		$('.sendToFriend').unbind('click').click(showShareModal);	
	});
	
	function trimByWord(sentence) { //function to trim the description to 15 words
	var result = sentence; //assign the passed value to a variable
	var resultArray = result.split(" "); //spilt it up by spaces
		if(resultArray.length > 15){ //get the first 15 elements in the array
		resultArray = resultArray.slice(0, 15); //slice her up
		result = resultArray.join(" ") + "…"; //add elipses at the end
		}//end if
	return result; //return it
	}

	//initiate GLOBAL vars
	var shareURL; 
	var shareTitleText = document.title; //encode the title for passing in a url string to the web services
    var shareTitle = encodeURIComponent(document.title); //encode the title for passing in a url string to the web services
    var serviceURL; //initialize the service URL
	var windowTitle; //initialize the windowTitle
    var shareWinOpts = 'toolbar=1,status=0,scrollbars=yes,width=635,height=520'; //popupwindow options
    var pageType;
    var subject;
    var message;
    var price;
  
	
	function getAlteredUrl(shareApp){ // this function is adapted from the send2friend.js file this 
		var locationurl = top.location.href; //get the url of the top window
        var splitUrlArray = ""; //initalize variable 
        var splitUrlArray1 = ""; //initalize variable
        var splitUrlArray2 = ""; //initalize variable
        var mvVar=""; //initalize variable
		var shareAppPrefix = 'mv='; //set this prefix
		var shareAppTrack = shareAppPrefix + shareApp; //put the url variables together
        
		if (locationurl.indexOf("mv") != null & locationurl.indexOf("mv") > 0) { //if statement taken from the send2friend.js file
                splitUrlArray = locationurl.split("mv");
        	if(splitUrlArray !=null && splitUrlArray.length > 0 ){
        		splitUrlArray1 = splitUrlArray[0];
        		splitUrlArray2 = splitUrlArray[1];
        		if (splitUrlArray2.indexOf("&") != null & splitUrlArray2.indexOf("&") > 0) {
        		     if(splitUrlArray2.indexOf('&')> 0 ){ 
        		     	var startindex = splitUrlArray2.indexOf("&") ; 
        		     	var endindex = splitUrlArray2.length; 
        		     	var remUrl = splitUrlArray2.substring(startindex , endindex);
        		     	locationurl = splitUrlArray1+shareAppTrack+remUrl;
        		     }
        		}else {
        		    locationurl = splitUrlArray1+shareAppTrack;
        		}
        	}
        }else
        {
          if (locationurl.indexOf("?") != null & locationurl.indexOf("?") > 0) {	
          	locationurl = locationurl+"&"+shareAppTrack;
          }else{
          	locationurl = locationurl+"?"+shareAppTrack;
          }
        }
		return locationurl; 
	}
	
	function showShareModal(){
		closeShareModal();
		$('body').append(shareThisVar);
		var module = $('#shareThisWrap');
		module.show();
		shareWidgetjs();
		var offset = $(this).offset(); //get the offset of the element that was clicked in this case the "share this item" link
		var outWidthThis = $(this).outerWidth(); //get the actual width of the clicked element
		var outHeightThis = $(this).outerHeight(); //get the actual height of the clicked element
		var outWidth = module.outerWidth(); //get the width of the modal
		var setMenuTop = (offset.top + outHeightThis) + 'px'; //set the correct value for the top offset in pixels
		var setMenuLeft = (offset.left - outWidth + outWidthThis)  + 'px'; //set the correct value for the left offset in pixels
		module.css({'top' : setMenuTop, 'left' : setMenuLeft} ); //position the modal from the top and left
		$('#smsNumber').mask("(999) 999-9999");
		omnShare(1);
		return false; //return false
	}
    function closeShareModal(){
			$('#shareThisWrap').remove(); //remove the instance of the modal
			$('#shareThisWrap').css('width', '350px');
	}
    function shareAction(){
		var desc = $('#desc1 p:first').text(); //Get the text in the first paragraph in the description 
		if(desc){
			var descFirstSentence = trimByWord(desc); //Split that string at the first sentence.
			var shareDesc = encodeURIComponent( descFirstSentence ); //encode the sentence to pass in the URI
		}
		else{
			var shareDesc = '';
		}
		var shareImageSrc = $('.slider img:first').attr('src'); //get the src of the productImage
		if(shareImageSrc){
			var shareImageArray = shareImageSrc.split('?'); //remove the extra variables at the end of the image src, if we don't do this, it'll error
			var shareImage = encodeURIComponent('<img src="'+shareImageArray[0]+'" width="200" style="float:left; margin:0px 10px 10px 0px;" >'); //encode the img html into something a url can accept
		}
		else{
			var shareImage = '';
		}
		var testClick = $(this).attr('id'); //get the id of what was clicked
		var bodyid = $('body').attr('id');
		var price = null;
		var defaultMsg = '';
		var subject = '';
		if($('.qvPopUpLayer').length > 0){
          		var pageType = 'quickView';
				defaultMsg = '';
				var desc = $('div#description div.qvContentMain p').text(); //Get the text in the first paragraph in the description 
				if(desc){
					var descFirstSentence = trimByWord(desc); //Split that string at the first sentence.
					var shareDesc = encodeURIComponent( descFirstSentence ); //encode the sentence to pass in the URI
				}
				else{
					var shareDesc = 'Quickview product';
				}
				var shareTitle = $('#overview h2 a').text();
				subject = $('#overview h2 a').text();
        }else{
			switch(bodyid){  
				case 'keysearch':
				  var pageType = 'search';
				  var keyword = $.query.get('keyword');
				  subject = 'Search for '+keyword+' at Sears.com';
				  defaultMsg = 'I came across these search results for '+keyword+' at Sears.com.  Check it out...';
				  break;
				case 'vertical':
				  var pageType = 'vertical';
				  var vert = $('.breadcrumb .location').html();
				  subject = vert+' products, sold by Sears.com';
				  defaultMsg = 'I came across these '+vert.replace(/\&amp;/g,'&')+' products at Sears.com that I thought you might be interested in.  Check it out...';
				  break;
				case 'compare':
				  var pageType = 'compare';
				  subject = 'Compare items at Sears.com';
				  defaultMsg = '';
				  break;
				case 'productOptions':
				  var pageType = 'productOptions';
				  subject = 'Product options for '+$('.main_item_details a').text()+', sold by Sears.com';
				  defaultMsg = '';
				  break;
				case 'dyn_NB':
				  var pageType = 'whatsNew';
				  subject = 'What\'s new at Sears.com';
				  defaultMsg = 'What\'s new at Sears.com? -'+$('h1').eq(0).text();
				  break;
				case 'subcategory':
					var pageType = 'subcategory';
				  	var subcat = $('#content .breadcrumb .location').next().html();
				  	subject = subcat+' products sold by Sears.com';
				 	defaultMsg = 'I came across these '+subcat.replace(/\&amp;/g,'&')+' products at Sears.com that I thought you might be interested in.  Check it out...';
				case 'category':
				  var pageType = 'category';
				  var vert = $('#content .breadcrumb .location').html();
				  subject = vert+' products sold by Sears.com';
				  defaultMsg = 'I came across these '+vert.replace(/\&amp;/g,'&')+' products at Sears.com that I thought you might be interested in.  Check it out...';
				  break;
				default: //the default is set to email
				  var pageType = 'product';
				  if($('body').attr('class') == 'collection'){
				  	var pageType = 'collection';
				  }else{
				 	var price = $('#p0_price span.pricing').text();
				  }
				  defaultMsg = 'I came across this '+shareTitleText+' at Sears.com and I thought you might be interested.  Check it out...';
				  subject = shareTitleText;
			}
			defaultMsg = defaultMsg.replace(/\s+/g,' ');
			defaultMsg = defaultMsg.substring(0, 198);
			subject = subject.replace(/\&amp;/g,'&');
			subject = subject.replace(/\s+/g,' ');
	    }
		
		var shareTitle = encodeURIComponent(document.title); //encode the title for passing in a url string to the web services
		
        switch(testClick) 	
        {  
        case 'shareDigg':
		  windowTitle = 'Digg';
		  shareURL = encodeURIComponent( getAlteredUrl('digg') ); //encode the url for passing 
          serviceURL = 'http://digg.com/submit?url='+shareURL+'&amp;title='+shareTitle+'&amp;bodytext='+shareDesc; //construct the appropriate service call
          window.open(serviceURL,windowTitle,shareWinOpts); //open the popup
          omnShare(2,windowTitle);
          break;
        case 'shareFacebook':
		  windowTitle = "Facebook";
		  shareURL = encodeURIComponent( getAlteredUrl('facebook') );
          serviceURL = 'http://www.facebook.com/sharer.php?u='+shareURL+'&amp;t='+shareTitle;
          window.open(serviceURL,windowTitle,shareWinOpts);
          omnShare(2,windowTitle);
          break;
        case 'shareMyspace':
		  windowTitle = 'MySpace';
		  shareURL = encodeURIComponent( getAlteredUrl('myspace') );
          serviceURL = 'http://www.myspace.com/Modules/PostTo/Pages?t='+shareTitle+'&u='+shareURL+'&c='+shareDesc; //myspace lets us add extra fancy stuff to 'c' variable which is essentially the description
          window.open(serviceURL,windowTitle,shareWinOpts);
          omnShare(2,windowTitle);
          break;
          case "shareSMS":
           $('#shareThis').hide();
           $('#sendSMSWrapper').show();
           var newLeft = null;
           var newLeft = parseInt($('#shareThisWrap').css('left')) - 224;
           $('#shareThisWrap').css({ width: '574px', left: newLeft +'px'});
           readyBackSMS();
           break;
		case 'shareDelicious':
		  windowTitle = 'Delicious';
		  shareURL = encodeURIComponent( getAlteredUrl('delicious') );
          serviceURL = 'http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url='+shareURL+'&amp;title='+shareTitle;
          omnShare(2,windowTitle);
          window.open(serviceURL,windowTitle,shareWinOpts);
          break;
		case 'shareTwitter':
		  windowTitle = 'Twitter';
		  shareURL = getAlteredUrl('twitter'); //for twitter we don't encode the url because it is not passing through the browser
          serviceURL = 'http://twitter.com/home?status='+shareTitle+' '+shareURL;
          omnShare(2,windowTitle);
          window.open(serviceURL,windowTitle,shareWinOpts);
          break;
		case 'shareStumbleUpon':
		  windowTitle = 'StumbleUpon';
		  shareURL = encodeURIComponent( getAlteredUrl('stumbleupon') );
          serviceURL = 'http://www.stumbleupon.com/submit?url='+shareURL+'&amp;title='+shareTitle;
          omnShare(2,windowTitle);
          window.open(serviceURL,windowTitle,shareWinOpts);
          break;
		default: //the default is set to email
          $('#shareThis').hide();
          $('#sendEmailWrapper').show(); //open and close the email wrapper div
          $('#message').val(defaultMsg);
   		  readyBack(subject, price);
		  omnShare(2,'Email');
        }//end switch
    }//end shareAction func
	
	function charCount198(){
		maxLen = 198; // max number of characters allowed
		if ( $(this).val().length >= maxLen) {
			$(this).val( $(this).val().substring(0, maxLen) );
			$('#sendEmailWrapper #charLeft').text( maxLen - $(this).val().length + ' Characters Left');
		}
		else{ 
			$('#sendEmailWrapper #charLeft').text( maxLen - $(this).val().length + ' Characters Left');
		}
	}//end char count function
    function charCount120(){
		maxLen = 120; // max number of characters allowed
		if ( $(this).val().length >= maxLen) {
			$(this).val( $(this).val().substring(0, maxLen) );
			$('#sendSMSWrapper #charLeft').text( maxLen - $(this).val().length + ' Characters Left');
		}
		else{ 
			$('#sendSMSWrapper #charLeft').text( maxLen - $(this).val().length + ' Characters Left');
		}
	}//end char count function

function sendEmailValidateAndSend(subject, price) //most of this is legacy, improvements were made in regards to how the variables are collected etc
 {
	 	$('#emailToFriend input').removeClass('fail'); //remove all the failed classes from the inputs to restart validation
		$('.sendEmailError').text(''); //remove the text from the error divs
		
 		var name = $('#emailToFriend #yourName').val(); // get the values from the forms
 		var vEmail = $('#emailToFriend #yourEmail').val();
	    var fEmail = $('#emailToFriend #friendsEmail').val();
        var msg = $('#emailToFriend #message').val();
        var bodyid = $('body').attr('id');
        
          
        var locationurl = top.location.href;

        if(!nameValidation(name)){ //check and validate the name field
			$('#yourName').addClass('fail'); 
        	return false;
        }

       function nameValidation(name){ //function that validate the name it only returns false if there is something really wierd going on in there
       		var  regexpression = /^\s*[a-zA-Z\s][a-zA-Z0-9\s\.\-\\]*$/ ;
       		var yourName = name.replace( /^\s*/, "" );
	  		if(yourName.match(regexpression) || yourName.length == 0){
				return true;
			}	
			$('#yourName').addClass('fail');
			$('#nameError').text('The name you entered appears incorrect.');
			return false;
       }//end nameValidataion func


	if (!validateEmailAddress(vEmail.toLowerCase(),vEmail)){ //Run the users email address through the validator
                $('#yourEmail').addClass('fail');
				$('#yourEmailError').text('Please enter a valid E-mail Address.');
				return false;
        }


      var vArray = fEmail.split(";"); //Take the address in the friends email field and slipt them by a semi-colom and put them into an array
	 
	  for ( count=0; count < vArray.length; count++){ //loop through that array and attempt to valiadate each email address
			var vElem = vArray[count];
			if (!validateEmailAddress(vElem.toLowerCase(),vElem))
					{
					$('#friendsEmail').addClass('fail');
					$('#friendsEmailError').text('The E-mail address(es) you entered appear incorrect.');
					return false;
					}
	  }//end for loop


		if ((msg.length > 200)){ //check the length of the message, this check is another fail safe for message feature and will most likely fail only some times
			$('#messageError').text("Message exceeds 200 characters");
			$('#message').addClass('fail');;
	        return false;
        }
		
		var locationurl = getAlteredUrl('s2f'); //run through new enhanced tracking functionality
        
		var stringUrl = locationurl.replace(/&/g,"*"); //legacy feature
		var visitorName  = $('#yourName').val();
		var visitorEmail = $('#yourEmail').val();
		var friendsEmail = $('#friendsEmail').val();
		document.cookie = "userEmail="+visitorEmail+";" //legacy, don't know exactly what this does
		
		
		var ajaxurl = "SendToAFriendCmd?storeId="+storeId+"&type="+pageType+"&visitorName="+visitorName+"&visitorEmail="+visitorEmail+"&friendsEmail="+friendsEmail+"&subject="+encodeURIComponent(subject)+"&message="+encodeURIComponent(msg)+"&price="+encodeURIComponent(price)+"&url="+stringUrl;
	   
	    ajaxCall(ajaxurl,'dummytwo');
		
		$('#shareThisWrap input, #shareThisWrap textarea').val('');
        $('#sendEmailWrapper').hide(); 
        $('#shareThis').show();
        $('#shareThis .emailConf').fadeIn();
		$('#shareThis .emailConf').animate({opacity: '1'}, 3000, function(){ $(this).fadeOut(); });
  	return false;
}

function dummytwo(){ 
	return;
}


function validateEmailAddress(tempemail,displayEmail){
var email = $.trim(tempemail); //jquery to trim whitespace, replacing the rtrim and ltrim function, 2-13-09

if(email == '' ){
        //alert("Email address is required");
		//$('#yourEmailError').text('Please Enter Your Email');
        return false;
}

var regex1 = /^[^\s@]+@([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]\.|[A-Za-z0-9]\.)+([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]|[A-Za-z0-9])$/; //legacy regex variables
var regex2 = /^(root@|abuse@|spam@)/; //legacy regex variables
var failedAlert = "The e-mail address you entered appears incorrect. (Example of a correct address: sears@sears.com.) Please check your information and try again.";
	
	if(!email.match(regex1)){
		//alert(failedAlert);
		return false;
	} else if(email.match(regex2)){
		alert(displayEmail + " is not allowed");
		return false;
	}else if(!checkEmailChar(email)){
		//alert(failedAlert);
		return false;
	}
return true;
}


function omnShare(typeOmn,nameClick) {   
  if (typeof s == 'undefined') {
  	return false;
  }
  
  if(typeof nameClick !='undefined'){
  	s.prop29=nameClick
  	s.linkTrackEvents = 'None';
  	s.tl(this,'o',nameClick);
  }else if(typeOmn==1){
  	omPrefix='Product Summary > Share This Item';
     s.t();
  }
  
  return false;
}

var readyBack = function(pageType, subject, price){
	
	$('#sendEmailWrapper a.back').click(function(){
		$('#shareThis').show();
		$('#sendEmailWrapper, #sendSMSWrapper').hide();
		return false;
	});
	
	$('#sendEmailWrapper .sendEmail').click(function(){
		sendEmailValidateAndSend(pageType, subject, price);
		return false;
	});
};

var readyBackSMS = function(){
	switch($('body').attr('id')){ //switch case
    case 'compare':
	  	$("#sendSMSWrapper .message strong").html('Compare Items');
    	break;
    case 'keywordSearch':
   		var keyword = $.getURLParam('keyword');
	  	$("#sendSMSWrapper .message strong").html('Search Results for "'+keyword+'"');
    	break;
	default: //the default is set to email
    	$("#sendSMSWrapper .message strong").html(shareTitleText);
	}//end switch
	
	var smsMessageField = $("#sendSMSWrapper #message");

	smsMessageField.bind('keydown',charCount120); //bind a function for the character count
	smsMessageField.bind('keyup',charCount120); //bind a function for the character count
	smsMessageField.bind('change',charCount120);  //bind a function for the character count
	$('#sendSMSWrapper a.back').unbind('click').click(function(){
		var newLeft = parseInt($('#shareThisWrap').css('left')) + 224;
		$('#shareThisWrap').css({width: '350px', left: newLeft + 'px'});
		$('#shareThis').show();
		$('#sendEmailWrapper, #sendSMSWrapper').hide();	
		return false;
	});
	$('#smsSubmit').unbind('click').click(function(){
		var smsNumber = $('#smsNumber').val().replace(/[^0-9]/g, '');
		var smsName = $('#sms_firstName').val();
		var smsMessage;
		if(smsNumber == ''){
			$('#sendSMSWrapper #messageError').empty().html('Please enter your friend\'s SMS/Text number');
			return false;
		}else{
			
			var locationurl = top.location.href;
			var locationurl = getAlteredUrl('s2f'); //run through new enhanced tracking functionality
			var stringUrl = locationurl.replace(/&/g,"*"); //legacy feature
			stringUrl = encodeURIComponent(stringUrl);
			$.ajax({
				type: "GET",
				url: "GetTinyURLCmd?longURL="+stringUrl,
				cache: false,
				success: function(responseURL){
				$('#getTinyURL').html(responseURL);
 				var tinyURL = $('#tinyURL').val();
 				tinyURL = encodeURIComponent(tinyURL);
 				$('#getTinyURL').html('');
					if(smsName){
						smsMessage = 'From '+smsName+'- '+smsMessageField.val()+' '+tinyURL;
					}else{
						smsMessage = smsMessageField.val()+' '+tinyURL;
					}
					var ajaxurl = "SendSMSCmd?number="+smsNumber+"&message="+smsMessage;
			    	ajaxCall(ajaxurl,'dummytwo');
			    	$('#sendSMSWrapper #messageError').empty();
			    	var newLeft = parseInt($('#shareThisWrap').css('left')) + 224;
					$('#shareThisWrap').css({width: '350px', left: newLeft + 'px'});
					$('#sendEmailWrapper, #sendSMSWrapper').hide();	
					$('#shareThis').show();
       				$('#shareThis .smsConf').fadeIn();
					$('#shareThis .smsConf').animate({opacity: '1'}, 3000, function(){ $(this).fadeOut(); });
				}
			});
		}
		return false;
	});
};
	
function shareWidgetjs(){
	$('ul.shareIt li').bind('click',shareAction);
		$('#shareThisWrap #closeButton').bind('click',closeShareModal);
		$("#shareThisWrap").bgiframe(); // apply the ie6 iframe plugin so that the modal appears above select elements
		$('body').click(function() {
		closeShareModal();
		return false;
	});//end body click func
	$('#shareThisWrap').click(function(event){
		event.stopPropagation(); //make sure if the user clicks within the modal, it doesn't disappear
		return false;
	});//end shareModalAbsoluteWrap click func
	$("#sendEmailWrapper #message").bind('keydown',charCount198); //bind a function for the character count
	$("#sendEmailWrapper #message").bind('keyup',charCount198); //bind a function for the character count
	$("#sendEmailWrapper #message").bind('change',charCount198);  //bind a function for the character count	  

}  

var shareThisVar=''
shareThisVar+='<div id="shareThisWrap">   \n'
shareThisVar+='	<a title="Close" id="closeButton">Close</a>         \n'
shareThisVar+='	<h2>Share This</h2>\n'
shareThisVar+='	<div id="shareThis">\n'
shareThisVar+='		<span class="emailConf" style="display:none;">E-mail sent successfully.</span>\n'
shareThisVar+='		<span class="smsConf" style="display:none;">SMS sent successfully.</span>\n'
shareThisVar+='		<h3>Select a Service for Sharing</h3>\n'
shareThisVar+='		<ul class="shareIt" title="Share This" id="services">                    \n'
shareThisVar+='			<li class="left" id="shareEmail" title="Email This">E-mail</li>   \n'
shareThisVar+='			<li id="shareSMS" title="SMS/Text This">SMS/Text</li>\n'
shareThisVar+='			<li id="shareFacebook" title="Add to Facebook">Facebook</li>   \n'
shareThisVar+='			<li class="left" id="shareTwitter" title="Twitter">Twitter</li>  \n'
shareThisVar+='			<li id="shareDelicious" title="Add to Delicious">Delicious</li>    \n'
shareThisVar+='			<li id="shareStumbleUpon" title="Stumble Upon">StumbleUpon</li>         \n'
shareThisVar+='			<li class="left" id="shareDigg" title="Digg This">Digg</li>                    \n'
shareThisVar+='			<li id="shareMyspace" title="Add to MySpace">MySpace</li>		\n'
shareThisVar+='		</ul>\n'
shareThisVar+='	</div>\n'
shareThisVar+='	<!--end share this--> \n'
shareThisVar+='	<!--sendemail wrapper-->           \n'
shareThisVar+='	<div id="sendEmailWrapper">\n'
shareThisVar+='		<a class="back" href="#">Back to Share This Services</a>\n'
shareThisVar+='		<h3>Send this to your friends</h3>\n'
shareThisVar+='		<p>Fill out the form below to share this item with your friends. Your information won\'t be used to send unsolicited emails or sold to any 3rd parties.<span class="requiredFields">* Required Fields</span></p>\n'
shareThisVar+='		<form action="javascript:;" id="emailToFriend">\n'
shareThisVar+='			<label title="Friend\'s First Name:" for="friendName">Friend\'s First Name</label>\n'
shareThisVar+='			<input type="text" id="friendName" title="Friend\'s First Name" name="friendName"/>\n'
shareThisVar+='			<label title="Friend\'s Email" for="friendsEmail">Friend\'s E-mail Address(es):*</label>\n'
shareThisVar+='			<input type="text" id="friendsEmail" title="Friend\'s Email" name="friendsEmail"/>\n'
shareThisVar+='			<div class="instructs">Separate email addresses with commas</div>\n'
shareThisVar+='			<div class="sendEmailError" id="friendsEmailError"></div>\n'
shareThisVar+='			<label title="Your Name:" for="yourName">Your Name:</label>\n'
shareThisVar+='			<input type="text" id="yourName" title="Your Name" name="yourName"/>\n'
shareThisVar+='			<div class="sendEmailError" id="nameError"></div>\n'
shareThisVar+='			<label title="Your E-mail" for="yourEmail">Your e-mail:*</label>\n'
shareThisVar+='			<input type="text" id="yourEmail" title="Your e-mail" name="yourEmail"/>\n'
shareThisVar+='			<div class="sendEmailError" id="yourEmailError"></div>\n'
shareThisVar+='			<div class="clear"></div>                            \n'
shareThisVar+='			<label class="message">Your message:</label>\n'
shareThisVar+='			<div class="textAreaWrapper">\n'
shareThisVar+='				<textarea rows="5" cols="31" title="Message" id="message" name="message"></textarea>\n'
shareThisVar+='			</div>\n'
shareThisVar+='			<!--end textAreaWrapper this div is necessary to fix an ie bug for rendering textareas-->\n'
shareThisVar+='			<div id="sendEmailButtonWrapper">\n'
shareThisVar+='				<div id="messageError"></div>\n'
shareThisVar+='				<span id="charLeft">198 Characters Left</span>\n'
shareThisVar+='				<input type="button" title="Send E-Mail" name="sendEmail" class="sendEmail" type="submit" />\n'
shareThisVar+='			</div>\n'
shareThisVar+='			<!--end sendEmailButtonWrapper-->\n'
shareThisVar+='		</form>\n'
shareThisVar+='	</div>\n'
shareThisVar+='	<!--end sendemail wrapper-->\n'
shareThisVar+='	<!--SMS wrapper-->           \n'
shareThisVar+='	<div id="sendSMSWrapper">\n'
shareThisVar+='		<a class="back" href="#">Back to Share This Services</a>\n'
shareThisVar+='		<h3>Share via SMS/Text</h3>\n'
shareThisVar+='		<p>We\'ll send your friend(s) a link to this page and a personalized message.</p>\n'
shareThisVar+='		<form action="javascript:;" id="smsToFriend">\n'
shareThisVar+='			<div class="floatWrap clearfix">\n'
shareThisVar+='				<div class="number">\n'
shareThisVar+='					<label title="SMS Number" for="smsNumber">Send SMS/Text Message to this number:</label>\n'
shareThisVar+='					<input type="text" id="smsNumber" title="Number" name="Number"/>\n'
shareThisVar+='					<div id="messageError"></div>\n'
shareThisVar+='					<label title="Your first name:" for="sms_firstName">Your first name:</label>\n'
shareThisVar+='					<input type="text" id="sms_firstName" title="Your first name:" name="sms_firstName"/>\n'
shareThisVar+='				</div>\n'
shareThisVar+='				<div class="message">\n'
shareThisVar+='					<strong>Whynter Eco-Friendly 12000 BTU Portable Air-Conditioner</strong>\n'
shareThisVar+='					<div class="textAreaWrapper">\n'
shareThisVar+='						<textarea rows="5" cols="39" title="Message" id="message" name="message">I thought you\'d be interested...</textarea>\n'
shareThisVar+='					</div>\n'
shareThisVar+='					<!--end textAreaWrapper this div is necessary to fix an ie bug for rendering textareas-->\n'
shareThisVar+='					<span id="charLeft">90 Characters Left</span>\n'
shareThisVar+='				</div>\n'
shareThisVar+='			</div>\n'
shareThisVar+='			<div class="buttonWrap">\n'
shareThisVar+='				<a id="smsSubmit" href="javascript:;">Share!</a>\n'
shareThisVar+='			</div>\n'
shareThisVar+='			<!--end send SMS Button Wrapper-->\n'
shareThisVar+='		</form>\n'
shareThisVar+='	</div>\n'
shareThisVar+='	<!--end SMS wrapper-->\n'
shareThisVar+='</div>\n'



//FORM MASKING

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.K.w=5(b,c){2(3.7==0)6;2(14 b==\'15\'){c=(14 c==\'15\')?c:b;6 3.L(5(){2(3.M){3.N();3.M(b,c)}v 2(3.17){4 a=3.17();a.1x(O);a.1y(\'P\',c);a.18(\'P\',b);a.1z()}})}v{2(3[0].M){b=3[0].1A;c=3[0].1B}v 2(Q.R&&Q.R.19){4 d=Q.R.19();b=0-d.1C().18(\'P\',-1D);c=b+d.1E.7}6{t:b,S:c}}};4 q={\'9\':"[0-9]",\'a\':"[A-T-z]",\'*\':"[A-T-1a-9]"};$.1b={1F:5(c,r){q[c]=r}};$.K.U=5(){6 3.1G("U")};$.K.1b=5(m,n){n=$.1H({C:"1I",V:B},n);4 o=D W("^"+$.1J(m.1c(""),5(c,i){6 q[c]||((/[A-T-1a-9]/.1d(c)?"":"\\\\")+c)}).1e(\'\')+"$");6 3.L(5(){4 d=$(3);4 f=D 1f(m.7);4 g=D 1f(m.7);4 h=u;4 j=u;4 l=B;$.L(m.1c(""),5(i,c){g[i]=(q[c]==B);f[i]=g[i]?c:n.C;2(!g[i]&&l==B)l=i});5 X(){x();y();1g(5(){$(d[0]).w(h?m.7:l)},0)};5 Y(e){4 a=$(3).w();4 k=e.Z;j=(k<16||(k>16&&k<10)||(k>10&&k<1h));2((a.t-a.S)!=0&&(!j||k==8||k==1i)){E(a.t,a.S)}2(k==8){11(a.t-->=0){2(!g[a.t]){f[a.t]=n.C;2($.F.1K){s=y();d.G(s.1j(0,a.t)+" "+s.1j(a.t));$(3).w(a.t+1)}v{y();$(3).w(1k.1l(l,a.t))}6 u}}}v 2(k==1i){E(a.t,a.t+1);y();$(3).w(1k.1l(l,a.t));6 u}v 2(k==1L){E(0,m.7);y();$(3).w(l);6 u}};5 12(e){2(j){j=u;6(e.Z==8)?u:B}e=e||1M.1N;4 k=e.1O||e.Z||e.1P;4 a=$(3).w();2(e.1Q||e.1R){6 O}v 2((k>=1h&&k<=1S)||k==10||k>1T){4 p=13(a.t-1);2(p<m.7){2(D W(q[m.H(p)]).1d(1m.1n(k))){f[p]=1m.1n(k);y();4 b=13(p);$(3).w(b);2(n.V&&b==m.7)n.V.1U(d)}}}6 u};5 E(a,b){1o(4 i=a;i<b&&i<m.7;i++){2(!g[i])f[i]=n.C}};5 y(){6 d.G(f.1e(\'\')).G()};5 x(){4 a=d.G();4 b=l;1o(4 i=0;i<m.7;i++){2(!g[i]){f[i]=n.C;11(b++<a.7){4 c=D W(q[m.H(i)]);2(a.H(b-1).1p(c)){f[i]=a.H(b-1);1V}}}}4 s=y();2(!s.1p(o)){d.G("");E(0,m.7);h=u}v h=O};5 13(a){11(++a<m.7){2(!g[a])6 a}6 m.7};d.1W("U",5(){d.I("N",X);d.I("1q",x);d.I("1r",Y);d.I("1s",12);2($.F.1t)3.1u=B;v 2($.F.1v)3.1X(\'1w\',x,u)});d.J("N",X);d.J("1q",x);d.J("1r",Y);d.J("1s",12);2($.F.1t)3.1u=5(){1g(x,0)};v 2($.F.1v)3.1Y(\'1w\',x,u);x()})}})(1Z);',62,124,'||if|this|var|function|return|length||||||||||||||||||||||begin|false|else|caret|checkVal|writeBuffer|||null|placeholder|new|clearBuffer|browser|val|charAt|unbind|bind|fn|each|setSelectionRange|focus|true|character|document|selection|end|Za|unmask|completed|RegExp|focusEvent|keydownEvent|keyCode|32|while|keypressEvent|seekNext|typeof|number||createTextRange|moveStart|createRange|z0|mask|split|test|join|Array|setTimeout|41|46|substring|Math|max|String|fromCharCode|for|match|blur|keydown|keypress|msie|onpaste|mozilla|input|collapse|moveEnd|select|selectionStart|selectionEnd|duplicate|100000|text|addPlaceholder|trigger|extend|_|map|opera|27|window|event|charCode|which|ctrlKey|altKey|122|186|call|break|one|removeEventListener|addEventListener|jQuery'.split('|'),0,{}))

//Get URL VARIABLES

new function(settings){var $separator=settings.separator||'&';var $spaces=settings.spaces===false?false:true;var $suffix=settings.suffix===false?'':'[]';var $prefix=settings.prefix===false?false:true;var $hash=$prefix?settings.hash===true?"#":"?":"";var $numbers=settings.numbers===false?false:true;jQuery.query=new function(){var is=function(o,t){return o!=undefined&&o!==null&&(!!t?o.constructor==t:true)};var parse=function(path){var m,rx=/\[([^[]*)\]/g,match=/^([^[]+?)(\[.*\])?$/.exec(path),base=match[1],tokens=[];while(m=rx.exec(match[2]))tokens.push(m[1]);return[base,tokens]};var set=function(target,tokens,value){var o,token=tokens.shift();if(typeof target!='object')target=null;if(token===""){if(!target)target=[];if(is(target,Array)){target.push(tokens.length==0?value:set(null,tokens.slice(0),value))}else if(is(target,Object)){var i=0;while(target[i++]!=null);target[--i]=tokens.length==0?value:set(target[i],tokens.slice(0),value)}else{target=[];target.push(tokens.length==0?value:set(null,tokens.slice(0),value))}}else if(token&&token.match(/^\s*[0-9]+\s*$/)){var index=parseInt(token,10);if(!target)target=[];target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value)}else if(token){var index=token.replace(/^\s*|\s*$/g,"");if(!target)target={};if(is(target,Array)){var temp={};for(var i=0;i<target.length;++i){temp[i]=target[i]}target=temp}target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value)}else{return value}return target};var queryObject=function(a){var self=this;self.keys={};if(a.queryObject){jQuery.each(a.get(),function(key,val){self.SET(key,val)})}else{jQuery.each(arguments,function(){var q=""+this;q=q.replace(/^[?#]/,'');q=q.replace(/[;&]$/,'');if($spaces)q=q.replace(/[+]/g,' ');jQuery.each(q.split(/[&;]/),function(){var key=decodeURIComponent(this.split('=')[0]||"");var val=decodeURIComponent(this.split('=')[1]||"");if(!key)return;if($numbers){if(/^[+-]?[0-9]+\.[0-9]*$/.test(val))val=parseFloat(val);else if(/^[+-]?[0-9]+$/.test(val))val=parseInt(val,10)}val=(!val&&val!==0)?true:val;if(val!==false&&val!==true&&typeof val!='number')val=val;self.SET(key,val)})})}return self};queryObject.prototype={queryObject:true,has:function(key,type){var value=this.get(key);return is(value,type)},GET:function(key){if(!is(key))return this.keys;var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];while(target!=null&&tokens.length!=0){target=target[tokens.shift()]}return typeof target=='number'?target:target||""},get:function(key){var target=this.GET(key);if(is(target,Object))return jQuery.extend(true,{},target);else if(is(target,Array))return target.slice(0);return target},SET:function(key,val){var value=!is(val)?null:val;var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];this.keys[base]=set(target,tokens.slice(0),value);return this},set:function(key,val){return this.copy().SET(key,val)},REMOVE:function(key){return this.SET(key,null).COMPACT()},remove:function(key){return this.copy().REMOVE(key)},EMPTY:function(){var self=this;jQuery.each(self.keys,function(key,value){delete self.keys[key]});return self},load:function(url){var hash=url.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1");var search=url.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");return new queryObject(url.length==search.length?'':search,url.length==hash.length?'':hash)},empty:function(){return this.copy().EMPTY()},copy:function(){return new queryObject(this)},COMPACT:function(){function build(orig){var obj=typeof orig=="object"?is(orig,Array)?[]:{}:orig;if(typeof orig=='object'){function add(o,key,value){if(is(o,Array))o.push(value);else o[key]=value}jQuery.each(orig,function(key,value){if(!is(value))return true;add(obj,key,build(value))})}return obj}this.keys=build(this.keys);return this},compact:function(){return this.copy().COMPACT()},toString:function(){var i=0,queryString=[],chunks=[],self=this;var encode=function(str){str=str+"";if($spaces)str=str.replace(/ /g,"+");return encodeURIComponent(str)};var addFields=function(arr,key,value){if(!is(value)||value===false)return;var o=[encode(key)];if(value!==true){o.push("=");o.push(encode(value))}arr.push(o.join(""))};var build=function(obj,base){var newKey=function(key){return!base||base==""?[key].join(""):[base,"[",key,"]"].join("")};jQuery.each(obj,function(key,value){if(typeof value=='object')build(value,newKey(key));else addFields(chunks,newKey(key),value)})};build(this.keys);if(chunks.length>0)queryString.push($hash);queryString.push(chunks.join($separator));return queryString.join("")}};return new queryObject(location.search,location.hash)}}(jQuery.query||{});



