// 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 FacebookStores(facebookAppId, storeid, domainUrl, options) {

    this.facebookAppId = facebookAppId;
    this.mid = storeid;
    this.domainurl = domainUrl;

    var defaultOptions={
	// global variables
        facebookpage:this.domainurl + "facebook-items.aspx/", // Facebook Item Page Url
        privacyPolicyPage:"privacy-policy.aspx", // Privacy Policy Url
        copyrightText:"Copyright &copy; 2011 www.certifiedguitarplayer.com. All Rights Reserved. ", // Copy Write Text
		headHTML : '', // 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.
		largeImgSize : "493",
      
		// Home page properties
		captionheader : "Welcome to our Facebook Store", // caption description header for the homepage 
        categoriesheader : "Featured Facebook Categories", // categories header (home page).
        itemheader : "Featured Facebook Items", // item header (home page).
		homebanner : "",
		homebannerlink: "",
		homebannerSize: "487",

    // define section properties
        sectionCaptionId : ".page-html-content", // .sectinfo on yahoo, .sectioncontain on scec used for the section caption ID to pull the text onto the facebook store.
        sectionPageHeadId : ".section-header", // section page header/pagename id
		sectionCategoryId: ".category-list td",
		sectionProductId: ".product-list",
		contentsImgSize: "125",

    // define item page properties
        itemdescheader : "Product Description",  // item description header (can be HTML).
        crosssellheader : "You May Also Like", // Cross sell header
        productTableId : "#product-detail-div", // PIT table clone, should be cloned before <form> element.
        itemNameId : ".product-detail h1:first", // if name is part of the PIT, leave blank. Item Page name
		itemImgSize : "200",
        hasTabbedInfo : false, // Newest version of Tabbed Information. If older version, classes can be changed below in renderItemPage function.
		
		/* Default Prod Info Table Selectors */
		priceSelector: ".prod-detail-cost-value",
		salePriceSelector: ".sale",
		reducedSelector: ".reduced",
		optionsSelector: ".option",
		youSaveSelector: ".saved",
		skuSelector: ".prod-detail-part-value",
		writeAddtoCart: true,

        //info page properties
        infoPageId : ".infopage", // info Page container DIV.

        // define cart properties
        cartId : "#ctl00_pageContent_checkoutPanel" // 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.cssLocation = "/facebook/facebook-styles-default.css";
    
    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;
    }
	
	if(isFacebook()){
		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);
	}


    this.determinePageType=function () {
        var p=-1;
        if(location.href == this.config.facebookpage){
            return 0; // home
		}
	    if(location.href != this.config.facebookpage && $(this.config.productTableId).length < 1 && $(".category-list-item").length > 0 || $(".product-list-item-container").length > 0){
	        p = 1; // section
		}
	    if($(this.config.productTableId).length > 0){ // item
	        p = 2;
		}
	    if($(this.config.cartId).length > 0){ // cart
	        return 3;
		}			
	    if($(this.config.infoPageId).length > 0) {
	        p = 4;
	    }
	 	if($(".cart-container").length > 0) {
		    p = 7;
	    }
	    return p;
		
    }

    this.initHTML=function() {
        //shell header
        var facebookheader = '<div id="fb-root">'+
	        '<div id="page">'+
	            '<div id="fbheader">'+
			        '<div class="fbheadhtml">' + this.config.headHTML + '</div>'+
			        '<div class="fbcart"></div>' +
			        '<div id="fbheader-links">' +
				        '<ul>' +
					        '<li><a href="'+this.config.facebookpage+'">Home</a></li>'+
					        '<li><a href="'+this.domainurl+'cart.aspx">View Cart</a></li>'+
					        '<li><a href="'+this.domainurl+'" target="_blank" class="fbviewsite ">Visit Our Site</a></li>'+
				        '</ul>'+
			        '</div>'+
		        '</div>'+
		        '<div id="fbcontent">';

        // shell footer
		        var facebookfooter = '</div>'+
		            '<div id="fbfooter">'+
			        this.config.mailinglisthtml+
			        '<div id="fbfooter-links">'+
				        '<ul>'+
					        '<li><a href="'+this.config.facebookpage+'">Home</a></li>'+
					        '<li><a href="'+this.domainurl+'" target="_blank">Visit Our Site</a></li>'+
							'<li><a href="'+this.config.privacyPolicyPage +'">Privacy Policy</a></li>'+
					        '<li><a href="'+this.domainurl+'cart.aspx">Shopping Cart</a></li>'+
				        '</ul>'+
			        '</div>'+
			        '<div class="fbcopyright">'+this.config.copyrightText+' <a href="http://yahoo.solidcactus.com/facebook-store">Facebook Store</a> by <a href="http://www.solidcactus.com/">Solid Cactus</a></div>'+
    		        '</div>'+
	                '</div>'+
                 '</div>';

        // home/section page body
        var facebookhomehtml ='<div id="fbcont-int">'+
	        '<div class="fbbanner pagebanner">'+
	        '</div>'+
	        '<div id="fbmessage">'+
		        '<div class="fbheader">'+
			        this.config.captionheader+
		        '</div>'+
		        '<div id="facebookcaption"></div>'+
	        '</div>'+
	        '<div class="fbcats">'+
		        '<div class="fbheader">'+
			        this.config.categoriesheader+
		        '</div>'+
		        '<div class="fbcategories results-grid"></div>'+
	        '</div>'+
	        '<div class="fbprods">'+
	          '<div class="fbheader">'+
		          this.config.itemheader+
	          '</div>'+
	          '<div id="facebookcontent" class="results-grid"></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" class=""></div>' + facebookfooter;	
    }

     this.renderHomePage=function() {
		 // grab image sizes to be used for scaling
		 var contImgSize = this.config.contentsImgSize;
		 var hbImgSize = this.config.homebannerSize;
		 
         $('#aspnetForm').append(this.facebookhtml);
	    // grab the text
	    if($(this.config.sectionCaptionId).length > 0){
	         var $captiondiv = $(this.config.sectionCaptionId).clone(true);
		    $("#facebookcaption").html($captiondiv.html());
	    } else {
		    $("#fbmessage").hide();	
	    }
	    
		// paging functionality.
	    if($(".product-list-results-header").length > 0){ 
			homeitems = $(".product-list-results-header").clone(true);
			$("#facebookcontent").append(homeitems);
		}
		
		// find items and categories
	    if($(this.config.sectionProductId).length > 0){ 
			homeitems = $(this.config.sectionProductId).clone(true);
			$("#facebookcontent").append(homeitems);
			$(".product-list-img").each(function() {
				if($(this).width() > contImgSize || $(this).height() > contImgSize)
					$(this).jScale({ls: contImgSize});
			});
		}
		
	    //if($(this.config.sectionCategoryId).length > 0){ 
		//	homecategories = $(this.config.sectionCategoryId).clone(true);
		//	$(".fbcategories").append(homecategories);
		//}
		if($(this.config.sectionCategoryId).length > 0){ 
			homecategories = "";
			$(this.config.sectionCategoryId).each(function() {
				homecategories += $(this).html();
			});
			$(".fbcategories").append(homecategories);
			$(".fbcategories .category-list-item-body a img").each(function() {
				if($(this).width() > contImgSize || $(this).height() > contImgSize)
				$(this).jScale({ls: contImgSize});
			});
		}
		
	    // banner image
	   	if(this.config.homebanner != ""){
			if(this.config.homebannerlink != ""){
				homeBannerHtml = "<a href='"+this.config.homebannerlink+"'<img src='"+this.config.homebanner+"' border='0' /></a>";
			} else {
				homeBannerHtml = "<img src='"+this.config.homebanner+"' border='0' />";
			}
			$('.fbbanner').prepend(homeBannerHtml);
			if($(".fbbanner img").width() > hbImgSize)
				$(".fbbanner img").jScale({ls: hbImgSize});	
		} else {
			$('.fbbanner').hide();	
		}
		
		 $("#wrapper select").remove();
    }

    this.renderSectionPage = function () {
		// grab image sizes to be used for scaling
		var contImgSize = this.config.contentsImgSize;
		 
        $('#aspnetForm').append(this.facebookhtml);
	    
		// grab the text
	    if($(this.config.sectionCaptionId).length > 0){
	         var $captiondiv = $(this.config.sectionCaptionId).clone(true);
		    $("#facebookcaption").html($captiondiv.html());
	    } else {
		    $("#fbmessage").hide();	
	    }
	    
		// paging functionality.
	    if($(".product-list-results-header").length > 0){ 
			homeitems = $(".product-list-results-header").clone(true);
			$("#facebookcontent").append(homeitems);
		}
		
		// find items and categories
	    if($(this.config.sectionProductId).length > 0){ 
			homeitems = $(this.config.sectionProductId).clone(true);
			$("#facebookcontent").append(homeitems);
			$(".product-list-img").each(function() {
				if($(this).width() > contImgSize || $(this).height() > contImgSize)
					$(this).jScale({ls: contImgSize});
			});
		}
		
	    if($(this.config.sectionCategoryId).length > 0){ 
			homecategories = $(this.config.sectionCategoryId).clone(true);
			$(".fbcategories").append(homecategories);
			$(".fbcategories .category-list-item-body a img").each(function() {
				if($(this).width() > contImgSize || $(this).height() > contImgSize)
				$(this).jScale({ls: contImgSize});
			});
		}
		
		var subhead = $(this.config.sectionPageHeadId).clone(true);
        $('.fbheader:first').text(subhead.text()).show();


        // hide items that don't belong
        $(".fbbanner").hide();
        $("#fbmessage img").hide();
        $(".fbdescheader").hide();
		$('.fbheader').hide();
		$('.fbheader:first').text(subhead.text()).show();
        
		$("#wrapper select").remove();
    }
    
    this.renderItemPage=function() {
		// grab image sizes to be used for scaling
		var itmImgSize = this.config.itemImgSize;
		
        $('#aspnetForm').append(this.facebookitem);
		
    	var prodImage=null;
    			
	    if($(".prod-detail-lt").length > 0){
		    prodImage = $(".prod-detail-lt").clone(true);
			$('.fbleft').prepend(prodImage);
	    }
		
		$(".prod-detail-lt img").each(function() {
			if($(this).width() > itmImgSize)
				$(this).jScale({w: itmImgSize});
	    		//$(this).jScale({h: itmImgSize});
		});
		
	    //var infoTable = $(this.config.productTableId).clone(true);
	    							
		var blah = $(".prod-detail-rt").clone(true);
		$(".fbright").append(blah);
		$("#wrapper select, #wrapper input").remove();
		
		
		// append hidden inputs to build form.
		formpid = $("input[name='pid']").attr("value");
		formmid = $("input[name='mid']").attr("value");
		
		$(".newfbform").append("<input name='pid' type='hidden' value = '"+formpid+"' /><input name='mid' type='hidden' value = '"+formmid+"' />");
		
	    if(this.config.itemNameId != ""){
	      var itemnametxt = $(this.config.itemNameId+":first").text();
	      $('.fbitemname').text(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($(".prod-detail-desc").html());
	    }
		
		$(".fbitemdesctxt a").each(function() {
			$(this).attr("target", "_blank");
		});
		
	    // cross sell
	    if($("#ctl00_pageContent_ctl111_productList").length > 0){
			homecategories = $("#ctl00_pageContent_ctl111_productList").clone(true);
			$("#fbcsitems").append(homecategories);		
	    } else {
		    $(".fbcrossell").hide();	
	    }
    }

    this.renderCartPage=function() {
        var $myelement = $(this.config.cartId).clone(true);
        $('#aspnetForm').append(this.facebookhtmlcart);
	    $("#fbcont-int").append($myelement);
	    $("#fbcont-int").css("padding", "0");
	    $("#wrapper select,#wrapper input,#wrapper textarea").remove();
    }
    
    this.renderInfoPage=function() {
        $('#aspnetForm').append(this.facebookhtmlcart);
		
		var $infoHtml = $(this.config.infoPageId).clone(true);
		$("#fbcont-int").html($infoHtml);	
    }
	
	this.renderCartFirstPage=function() {
		var contImgSize = this.config.contentsImgSize;
		
        var $myelement = $(".cart-container").clone(true);
        $('#aspnetForm').append(this.facebookhtmlcart);
	    $("#fbcont-int").append($myelement);
	    $("#fbcont-int").css("padding", "0");
	    $("#wrapper select,#wrapper input,#wrapper textarea").remove();
		$("#fbcont-int .cart-item-image a img").each(function() {
			if($(this).width() > contImgSize)
				$(this).jScale({w: contImgSize});
		});
		
		$("#fbcont-int td.cart-continue a#ctl00_pageContent_continueLink").replaceWith("<a href='/facebook-items.aspx/' id='ctl00_pageContent_continueLink'><img style='border-width: 0px;' alt='continue' src='/themes/migration-1/images/buttons/cart_btn_shop.gif'></a>");
		$("a#ctl00_pageContent_checkoutLink").attr("href", "/checkout.aspx");
		
		//$("#ctl00_pageContent_imbPayPalCheckout").replaceWith("<div id='fbpaypaltext'><a href='/cart.aspx' target='_blank'>View cart in separate window to check out with Paypal.</a></div>");
    }
    

    this.renderDefaultPage=function() {
        $('#aspnetForm').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() {
        // 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;
			case 7:
                this.renderCartFirstPage();
                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();	
		    }
	    });
		
		// clone the floating cart
		if($(".itemcnt").length > 0){
			$viewcartbuttons = $(".itemcnt").clone();
			$(".fbcart").html($viewcartbuttons);
			$viewcartbuttons = $(".itemtlt").clone();
			$(".fbcart").append($viewcartbuttons);
			$(".fbcart").append("<a href='"+this.domainurl+"checkout.aspx'>Checkout</a>");
		}
		
		if($(".cart-continue a").length > 0){
			$(".cart-continue a").attr("href",this.config.facebookpage);	
		}
		
		var contImgSize = this.config.contentsImgSize;
		var lgImgSize = this.config.largeImgSize;
		
		// resize all images by width in a contents table
		$(".product-thumb img").each(function() {
			if($(this).width() > contImgSize)
				$(this).jScale({w: contImgSize});
		});
		
		// resize all images that are too large for the iframe
		$("img").each(function() {
			if($(this).width() > lgImgSize)
				$(this).jScale({w: lgImgSize});
		});
    }

    $(function(){
	    if (isFacebook()){
		    
		    if (facebookStores!=null) {	        
		        facebookStores.init(); 		
				
				$("#ctl00_pageContent_imbPayPalCheckout").replaceWith("<div id='fb-ppgg-text'><a target='_blank' href='http://www.certifiedguitarplayer.com/cart.aspx'>View cart in separate window to check out with Paypal.</a></div>");
				$("div#ctl00_pageContent_checkoutWizard_seperator").remove();
				$("div#ctl00_pageContent_checkoutWizard_payPal").replaceWith("<div id='fb-ppgg-text'><a target='_blank' href='http://www.certifiedguitarplayer.com/cart.aspx'>View cart in separate window to check out with Paypal.</a></div>");
		    }
    	   	    		
		    
    		
		    /* ------------------------------------------------------------ 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 facebookStores = new FacebookStores("112214852229208","","http://www.certifiedguitarplayer.com/",{});

// add section header class
