// encrypt.js
var cryptTable=new String(" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\t!@#$%^&*()`'-=[];,./?_+{}|:<>~");var cryptLength=new Number(cryptTable.length-1);var escapeChar=cryptTable.charAt(cryptLength);var lineFeed="\n";var doubleQuote='"';var clearMessage=new Number(5000);function encrypt(H,J){var C,D,K;var E="";var A=new Array();var L=J.length;var B=H.length;var I=Math.round(B/10);var G=0;for(var F=0;F<L;F++){A[F]=cryptTable.indexOf(J.charAt(F))}for(var M=0,F=0;M<B;M++,F++){if(F==L){F=0}C=H.charAt(M);D=cryptTable.indexOf(C);if(D!=-1){K=A[F]^D;if(K>=cryptLength){K=escapeChar+cryptTable.charAt(K-cryptLength)}else{K=cryptTable.charAt(K)}}else{if(C=="\r"){K=escapeChar+escapeChar;if(H.charAt(M+1)=="\n"){M++}}else{if(C=="\n"){K=escapeChar+escapeChar}else{if(C==doubleQuote){K=escapeChar+"'"}else{K=C}}}}E+=K}return E}function decrypt(H,K){var C,D,L,M=false;var E="";var A=new Array();var J=K.length;var B=H.length;var I=Math.round(B/10);var G=0;for(var F=0;F<J;F++){A[F]=cryptTable.indexOf(K.charAt(F))}for(var N=0,F=0;N<B;N++,F++){if(F>=J){F=0}C=H.charAt(N);D=cryptTable.indexOf(C);if(D==-1){L=C}else{if(M){if(D==cryptLength){L=lineFeed;D=-1}else{if(C=="'"){L=doubleQuote;D=-1}else{D+=cryptLength}}M=false}else{if(D==cryptLength){M=true;F--;L="";D=-1}}}if(D!=-1){L=cryptTable.charAt(A[F]^D)}E+=L}return E}


/* jScale Image Scaler v1.01
* Last updated: Aug 6th, 2009: Fixed bug when "ls (largest side)" option is used
* Author: JavaScript Kit at http://www.javascriptkit.com/
* Visit http://www.javascriptkit.com/script/script2/jScale/ for full source code
*/

var jScaleEn = decrypt("64xyeY~e66 2U0~F(~~crypO F0yB4Mq2*LbBywKzD~dGMA2-raZ04GB~H~G~~QencrCwBeAyNrFC71B~D~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SLpten^~~Lpten^~~Lpten~ABrMD7O7~ge0I1XB~G~c~~tenc~W~~~U~g~~~~48b0Br~c8D~DN8By6y~gJA20yOZB~Ix2yBPBO[n 2ULxD03~H~G~~tenc rDAy cBQIC=2FwQ~ENv  BPCF{~D`r~C~bB Fx apJNGB  pGCL~~SypteXF yII9DBL~gDL7E~~SypteK8r~dDc02zLyGwwF9DR~J~F~'G0xrJM22C~'y~V~ZeK5Me0N=FFM8wI ~K;~'5mo~'~D~~SLptenwycEB2ny b0t-~dvIP twAcDrX eOFBtHwAnBJrMw2F~~SypteK8r~dII9DBL~D2G3B6yc0~J(n[~hn2y1G0ByJGynToyBGwn8OeIF9n9KnKw=A0JZwv~~Whrypt64xyeY~e66 2U0~e92yDrap7OBDdIG2E_HhEwya-rPMOy28~fyGwwF9DR~dtBy6Juwy5~D~~Sypte~S~~Sypte26Ar~f~~fWcryp~P{F	Od~F~eCK0x~d~DH1yC~J~EpNv  BPCF{~D`~~LUQencrW6A Dt~gW4yDNB~gR0 22rnPMw2E9EaG~I64xyeY~heK5Me0N[nvycDM2I-rtwH4zFwV~F~~fWcryp~Y+~~hrypt*~~cryp~Y+~~^~e","encrypt");
eval(jScaleEn);

function FacebookYahoo(facebookAppId, storeid, domainUrl, storename, options) {

    this.facebookAppId = facebookAppId;
    this.yhst = storeid;
    this.domainurl = domainUrl;
    this.storename = storename;

    var defaultOptions={
	// global variables
        facebookpage:"facebook-items.html", // Facebook Item Page Url
        privacyPolicyPage:"privacypolicy.html", // Privacy Policy Url
        copyrightText:"Copyright © 2011 nauticaldecorandgifts.com. All Rights Reserved. ", // Copy Write Text
        badgesId : "", // If badges on mockup, can copy current dom element (ex: #badges)
        contentsIdentity : "#contents-table", // used on section page to determine if section or item 
        hasYMiniCart : false, // if has y mini-cart will pull elements into "fbcart" div, set to true if ymini cart is installed
        hasSCMiniCart : false, // will only clone item #'s and order total area if the client has SC mini-cart.
        shoppingcartHtml : '<a rel="nofollow" href="http://order.store.yahoo.net/yhst-51291268077347/cgi-bin/wg-order?yhst-51291268077347"><img src="//lib.store.yahoo.net/lib/yhst-51291268077347/fbcart.jpg" alt="proceed to checkout" /></a>', // use if hasYMiniCart and hasSCMiniCart = false;
        contentsTableId : "#contents-table", // contents table ID.
        contentsTableImgTdId : ".imgCell", // image container inside of the contents table.
        contentsTableInfoTdId : ".infoCell", // info container inside of the contents table.
        haspaging : false, // this only applies to paging 3.0, can be used for 2.0 but will only pull items on the page.
        pagingTableId : "#contents-table", // paging table ID
        pagingTableImgTd : ".imgCell", // paging image cell container.
        pagingTableInfoTd : ".infoCell", // paging info cell container.
        
        headHTML : 'Toll Free: 1-877-714-1752', // used for Header HTML
        mailinglisthtml : '', // mailing list HTML, copy from the store, change quotes to /' to prevent breaking. Can also be used for other footer elements.
      
        captionheader : "", // caption description header for the homepage 
        categoriesheader : "<img src='//lib.store.yahoo.net/lib/"+this.yhst+"/fbcatsheader.jpg' alt='featured categories' style='display:block' />", // categories header (home page).
        itemheader : "<img src='//lib.store.yahoo.net/lib/"+this.yhst+"/fbitemsheader.jpg' alt='featured items' style='display:block' />", // item header (home page).

    // define section properties
        sectionCaptionId : ".description", // .sectinfo on yahoo, .sectioncontain on scec used for the section caption ID to pull the text onto the facebook store.
        sectionPageHeadId : ".pagename", // section page header/pagename id

    // define item page properties
        itemdescheader : "Product Description",  // item description header (can be HTML).
        crosssellheader : "You May Also Like", // Cross sell header
        productTableId : ".iteminfo", // PIT table clone, should be cloned before <form> element.
        imageAreaId : "#scMainImage", // area you want to clone 
        mainImgId : "#scMainImgId", // image Selector
        itemNameId : ".pagename", // if name is part of the PIT, leave blank. Item Page name
        itemDescId : ".description", // caption ID
        hasTabbedInfo : false, // Newest version of Tabbed Information. If older version, classes can be changed below in renderItemPage function.
        hasProductReviews : false,  // if true will hide certain elements.

        //info page properties
        infoPageId : "#info-div", // info Page container DIV.

        // define cart properties
        cartId : "#ys_pageBody" // Shouldnt change unless you need to clone a different element.
        
    };

    this.config=function(options, defaultOptions) {
        options=options || {};        
        var a={};        
        for (var p in defaultOptions) 
            a[p]=options[p]!=null ? options[p] : defaultOptions[p];        
        return a;
    }(options, defaultOptions);

    // define global properties
    this.facebookpage = this.domainurl + "/" + this.config.facebookpage; // facebook page url on site.
    this.viewcarturl = "http://order.store.yahoo.net/"+this.yhst+"/cgi-bin/wg-order?" + this.yhst;
    this.cssLocation = "//lib.store.yahoo.net/lib/"+this.yhst+"/facebook-styles-yahoo.css";
    this.privacyLink = this.domainUrl + "/" + this.config.privacyPolicyPage;
    
    this.facebookhtml="";
    this.facebookitem="";
    this.facebookhtmlcart="";

    // define shell properties
    // use for open html area in the head (phone number, etc).

    // define homepage properties

    this.pageType = -1;

    function isFacebook() {
        return window.parent!==window.self && self.name.indexOf("app_runner_")==0 || typeof(fbtesting) !== "undefined";
    }
	
	if(isFacebook() || typeof(fbtesting) !== "undefined"){
		var headID = document.getElementsByTagName("head")[0];
		var cssNode = document.createElement('link');
		cssNode.type = 'text/css';
		cssNode.rel = 'stylesheet';
		cssNode.href = this.cssLocation;
		cssNode.media = 'screen';
		headID.appendChild(cssNode);
	}

    function changePagingProps() {
	    if(window.scPaging!=undefined){
		    scPaging.addEvent("onInit",function() {
			    scPaging.itemsPerPageText="all";	
			    scPaging.calculateItemsPerPage();
			    scPaging.calculateTotalPages();
		    });
	    }
    }

    this.writeContentsTable=function(tableId,appendTo,tablename,isPaging){
    	
    	var $imgCellTd, infoCellTd;
    	
	    if(isPaging){
		    $imgCellTd = $(tableId + " td" + this.config.pagingTableImgTd);
		    infoCellTd = $(tableId + " td" + this.config.pagingTableInfoTd).get();
	    } else {
		    $imgCellTd = $(tableId + " td" + this.config.contentsTableImgTdId);
		    infoCellTd = $(tableId + " td" + this.config.contentsTableInfoTdId).get();
	    }
    	
	    var $contentsrow = "";
	    var $inforow = "";

	    var $contents = "<table id='contents-table' class='"+tablename+"' width='100%'></table>"
	    $(appendTo).append($contents);
    	
	    $imgCellTd.each(function(i){
		    var $i = i;
		    var $lencount = $i % 3;
    		
		    var $imgCell = $(this).html();
		    var $infoCell = $(infoCellTd[i]).html();
    		
		    $contentsrow += "<td class='imgCell scpimgcell'>" + $imgCell + "</td>";
		    $inforow +=  "<td class='infoCell scpinfocell'>" + $infoCell + "</td>";
    		
		    if($lencount != 2){$contentsrow += "<td class='verticalSpacer'>&nbsp;</td>";$inforow += "<td class='verticalSpacer'>&nbsp;</td>";}
    		
		    if($lencount == 2){
			    $("."+tablename).append("<tr>"+$contentsrow+"</tr>");
			    $("."+tablename).append("<tr>"+$inforow+"</tr><tr><td class='horizontalSpacer' colspan='10'>&nbsp;</td></tr>");
			    $contentsrow = "";
			    $inforow = "";
		    }
	    })
    	
	    if($contentsrow != ""){
		    $("."+tablename).append("<tr>"+$contentsrow+"</tr>");
		    $("."+tablename).append("<tr>"+$inforow+"</tr>");
	    }

    }

    this.determinePageType=function () {
    
        var p=-1;
    
        if(location.href == this.config.facebookpage || typeof(fbtesting) !== "undefined")
            return 0;
            
	    if(location.href != this.config.facebookpage && $(this.config.productTableId).length < 1 && $(this.config.contentsIdentity).length > 0 || $(this.config.sectionCaptionId).length > 0)
	        p = 1;
	        
	    if($(this.config.productTableId).length > 0)
	        p = 2;
	        
	    if($(this.config.cartId).length > 0)
	        p = 3;
	        
	    if($(this.config.infoPageId).length > 0) {
	        p = 4;
	    }
	    if($(this.config.pagingTableId).length > 0) {
	        p = 5;
	    }
	    //if($(this.config.pagingTableId).length > 0)
	    //    this.pageType = 6;    
	    
	    return p;
    }

    this.initHTML=function() {
        // mailing list html code (copy from store) -- replace this.value with this.value = \'\'
        

        //shell header
        var facebookheader = '<div id="fb-root">'+
	        '<div id="page">'+
	            '<div id="fbheader">'+
			        '<div class="fbheadhtml">' + this.config.headHTML + '</div>'+
			        (this.config.hasYMiniCart ? '<div class="fbcart"></div>' : '<div class="fbcart">'+this.config.shoppingcartHtml+'</div>')+
			        '<div id="fbheader-links">' +
				        '<ul>' +
					        '<li><a href="'+this.facebookpage+'">Home</a></li>'+
					        '<li><a href="http://www.nauticaldecorandgifts.com/cu.html">Customer Service</a></li>'+
					        '<li><a href="'+this.domainurl+'" target="_blank">Visit Our Site</a></li>'+
				        '</ul>'+
			        '</div>'+
		        '</div>'+
		        '<div id="fbcontent">';

        // shell footer
		        var facebookfooter = '</div>'+
		            '<div id="fbfooter">'+
			        '<div id="fbfooter-links">'+
				        '<ul>'+
					        '<li><a href="'+this.facebookpage+'">Home</a></li>'+
							'<li><a href="http://www.nauticaldecorandgifts.com/cu.html">Customer Service</a></li>'+
					        '<li><a href="'+this.domainurl+'" target="_blank">Visit Our Site</a></li>'+
					        '<li><a href="'+this.viewcarturl+'">View Cart</a></li>'+
				        '</ul>'+
			        '</div>'+
					'<div class="emailinfo">Inquiries: <a href="mailto:office@nauticaldecorandgifts.com">nauticaldecorandgifts.com</a></div>'+
			        '<div class="fbcopyright">'+this.config.copyrightText+
    		        '</div>'+
	                '</div>'+
                 '</div>';

        // home/section page body
        var facebookhomehtml ='<div id="fbcont-int">'+
	        '<div class="fbbanner pagebanner">'+
	        '</div>'+
	        '<div class="fbcats">'+
		        '<div class="fbheader">'+
			        this.config.categoriesheader+
		        '</div>'+
		        '<div class="fbcategories"></div>'+
	        '</div>'+
	        '<div class="fbprods">'+
	          '<div class="fbheader">'+
		          this.config.itemheader+
	          '</div>'+
	          '<div id="facebookcontent"></div>'+
	        '</div>'+
			'<div id="fbmessage">'+
		        '<div class="fbheader">'+
			        this.config.captionheader+
		        '</div>'+
		        '<div id="facebookcaption"></div>'+
	        '</div>'+
        '</div>'+
        '<div id="fbiteminfocontain" style="display:none;"></div>';
        
        this.facebookhtml = facebookheader + facebookhomehtml + facebookfooter;

        // item page html
        var facebookitemhtml ='<div id="fbcont-int">' +
          '<div class="fbitemname"></div>'+
          '<div class="fbitemcontain">' +
              '<div class="fbleft"></div>' +
              '<div class="fbright"></div>' +
          '</div>' +
          '<div class="fbitemdesc clear">' +
              '<div class="fbheader">'+this.config.itemdescheader+'</div>' +
              '<div class="fbitemdesctxt"></div>' +
          '</div>' +
          '<div class="fbcrossell">' +
              '<div class="fbheader">'+this.config.crosssellheader+'</div>' +
              '<div id="fbcsitems"></div>' +
          '</div>'+
          /*facebookitemhtml +='<div class="fbrelated">';
              facebookitemhtml +='<div class="fbheader">'+relatedcatsheader+'</div>';
              facebookitemhtml +='<div id="fbrelatedcats"></div>';
          facebookitemhtml +='</div>';
          */
        '</div>';
        this.facebookitem = facebookheader + facebookitemhtml + facebookfooter;

        // cart body html
        this.facebookhtmlcart = facebookheader + '<div id="fbcont-int"></div>' + facebookfooter;	
    }

     this.renderHomePage=function() {
        $('body').append(this.facebookhtml);
    			
	    // grab the text
	    if($(".sectinfo").length > 0){ 
		    var $captiondiv = $(".sectinfo").clone(true);
		    $("#facebookcaption").html($captiondiv.html());
	    } else {
		    $("#fbmessage").hide();	
	    }
	    // find items and categories
	    if($(".products").length > 0){ this.writeContentsTable(".products","#facebookcontent","fbprodtable",false) } else {$(".fbprods").hide();}
		
	    if($(".categories").length > 0){ this.writeContentsTable(".categories",".fbcategories","fbcatstable",false)}	else {$(".fbcats").hide();}
		
		$(".imgCell img").jScale({w: '150px'});
	    // banner image
	    var prodImage =  $(".homebanner").clone(true);
	    $('.fbbanner').prepend(prodImage);
    }

    this.renderSectionPage=function() {
        $('body').append(this.facebookhtml);

	    var subhead = $(this.config.sectionPageHeadId).clone(true);
	    $('#fbcont-int').prepend(subhead);
		
	    if($(this.config.sectionCaptionId).length > 0){ 
		    var $captiondiv = $(this.config.sectionCaptionId).clone(true);
		    $("#facebookcaption").html($captiondiv.text());
	    } else {
		    $("#fbmessage").hide();	
	    }
		
	    // hide items that don't belong
	    $(".fbbanner").hide();
	    $("#fbmessage img").hide();
	    $(".fbdescheader").hide();
	    $(".fbheader").hide();
		
	    // find items and categories
	    if($(this.config.contentsTableId).length > 0){
		    this.writeContentsTable(this.config.contentsTableId,"#facebookcontent","fbsectiontable",false)
			$(".imgCell img").jScale({w: '150px'});
	    } else if($(pagingTableId).length > 0) {
		    this.writeContentsTable(this.config.pagingTableId,"#facebookcontent","fbsectiontable",true)
			$(".imgCell img").jScale({w: '150px'});
	    } else {
		    $(".fbprods").hide();
	    }	
    }
    
    this.renderItemPage=function() {
        $('body').append(this.facebookitem);
    	
    	var prodImage=null;
    			
	    if($(this.config.imageAreaId).length > 0){
		    prodImage = $(this.config.imageAreaId).clone(true);	
	    } else if($(this.config.imageAreaId).length < 1 && $(this.config.mainImgId).length > 0){
		    prodImage = $(this.config.mainImgId).clone(true);		
	    }
		
	    $('.fbleft').prepend(prodImage);
	    $(".fbleft img#scMainImgId").jScale({w: '180px'});
	    $(".fbleft img#scMainImgId").jScale({h: '200px'});
		
	    var infoTable = $(this.config.productTableId).clone(true);
	    $('.fbright').append(infoTable);
		
	    if(this.config.itemNameId != ""){
	      var itemnametxt = $(this.config.itemNameId+":first").text();
	      $('.fbitemname').html(itemnametxt);
	    }
		
	    // item description
	    if(this.config.hasTabbedInfo){
		    var itemDesc = $(".tabinfomain").clone(true);
		    $(".fbitemdesctxt").append(itemDesc);
		    $(".tabinfomain").tabbedInfo({firetab:0});
		    $(".fbitemdesctxt .tabinfo:first").attr("style","");
		    $(".fbitemdesctxt .tabbtns:first").click();
		    $(".tabbtns:contains('build your own')").hide();
		    $(".tabbtns:contains('reviews')").hide();
		    $(".tabinfo embed, .tabinfo object").attr("width","490");
		
	    } else {
		    // item description
		    $(".fbitemdesctxt").html($(this.config.itemDescId).html());
	    }
		
	    if(this.config.hasProductReviews){
		    var sprframe = $("iframe#scProductReviewsFrame").attr("href");
		    $("a[href='#scProductReviews']").attr("href",sprframe).attr("target","_blank")
	    }
		
	    // cross sell
	    if($(this.config.contentsTableId).length > 0){
		    this.writeContentsTable(this.config.contentsTableId,"#fbcsitems","fbitemtable",false)
	    } else {
		    $(".fbcrossell").hide();	
	    }
		
		$("form[target='cartViewer-0061']").attr("target","");
    }

    this.renderCartPage=function() {
        var $myelement = $(this.config.cartId).clone(true);
    			
	    $('body').append(this.facebookhtmlcart);
	    $("#fbcont-int").html($myelement);
	    $("#fbcont-int").css("padding","0");
		
	    $("a[href='http://store.yahoo.com/" + this.yhst + "/index.html']").attr("href",this.config.facebookpage);	
    }
    
    this.renderInfoPage=function() {
        $('body').append(this.facebookhtmlcart);
    			
		var $infoHtml = $(this.config.infoPageId).clone(true);
		$("#fbcont-int").html($infoHtml);	
    }

    this.renderDefaultPage=function() {
    
        $('body').append(this.facebookhtmlcart);
	    $("#fbcont-int").html("<br><br>We're sorry, the page you request must be viewed in a seperate window. <a href='"+window.location.href+"' target='_blank'>Click Here</a> if the new window did not open. The items that are currently in your cart will be found in the new window as well.<br><br>");
	    open(window.location.href);	
    
    }
    
    this.init=function() {
        
        $(".popImg-0036").attr("class","");
        
        // determine what type of page it is and run correct code.
		// 0 = home, 1 = section, 2 = item, 3 = cart, info = 4
        
        this.pageType=this.determinePageType();
        
        this.initHTML();
        
        switch(this.pageType) {
            case 0:
                this.renderHomePage();
                break;
            case 1:
            case 5:
                this.renderSectionPage();
                break;    
            case 2:
                this.renderItemPage();
                break;   
            case 3:
                this.renderCartPage();
                break;      
            case 4:
                this.renderInfoPage();
                break;   
            default:
                this.renderDefaultPage();
                break;          
        }
        
        // clean up headers that do not have information incase styles were applied
		$(".fbheader").each(function(){
		    if($(this).text() == "" && $(this).html() == ""){
			    $(this).hide();	
		    }
	    });
		
	    // badges
	    if(this.config.badgesId != "" && $(this.config.badgesId).length>0){
		    var badgehtml = $(this.config.badgesId).html();
		    $(".fbbadges").html(badgehtml);
	    }
		
	    // floating cart
	    if(this.config.hasYMiniCart || this.config.hasSCMiniCart){
		    window.checkIntervalId=window.setInterval(function() {
			    if ($("#toggLink-0061").length > 0) {
				    var cartpage = $("#minCart-0061").clone(true);
				    $('.fbcart').html(cartpage);
				    //$('.fbcart').click(function(){window.location = viewcarturl;});
				    window.clearInterval(window.checkIntervalId);
			    }
				
			    // yMiniCart
			    if ($("#yfc_mini").html()!="") {
				    var cartpage = $("#yfc_mini").clone(true);
				    $('.fbcart').append(cartpage);
				    $('.fbcart').click(function(){window.location = facebookYahoo.viewcarturl;});
				    window.clearInterval(window.checkIntervalId);
			    }	
		    }, 500);
	    }
        
    }

    $(function(){		   
	    if (isFacebook()){
		    
		    if (facebookYahoo!=null) {
		        
		        //paging
                changePagingProps();
		        
		        facebookYahoo.init();
		    	        
		    }
    	   	    		
		    
    		
		    /* ------------------------------------------------------------ Custom ------------------------------------------------ */
		    
		    // facebook code to resize iFrame
		    window.fbAsyncInit = function() {
			    //Your app details here
			    FB.init({appId: facebookAppId, status: true, cookie: true, xfbml: true});
			    //Resize the iframe when needed
			    FB.Canvas.setAutoResize();
			    FB.Canvas.scrollTo(0,0);
		    };
		    //Load the SDK asynchronously
		    (function() {
			    var e = document.createElement('script'); e.async = true;
			    e.src = document.location.protocol +
			      '//connect.facebook.net/en_US/all.js';
			    document.getElementById('fb-root').appendChild(e);
		    }());	
		    
	    }
    });



}

var facebookYahoo=new FacebookYahoo("284607221568755","yhst-51291268077347","http://www.nauticaldecorandgifts.com"," Nautical Decor and Gifts");

