// 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:'&copy; 2012 Paramount-Supplements. All Rights Reserved.', // Copy Write Text
        badgesId : "", // If badges on mockup, can copy current dom element (ex: #badges)
        contentsIdentity : ".category-product", // 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 href="http://order.store.yahoo.net/yhst-53160377742214/cgi-bin/wg-order?yhst-53160377742214">View Shopping Cart</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", // paging table ID
        pagingTableImgTd : "#contents-image", // paging image cell container.
        pagingTableInfoTd : ".contentCell", // paging info cell container.
        
        headHTML : '<span>Secure Online Ordering</span>Order By Phone 888-674-8558',// used for Header HTML
		headHTML2 : '<a href="http://blog.paramount-supplements.com/" target="_blank"><img src="//lib.store.yahoo.net/lib/yhst-53160377742214/fb-rss-feed-icon.jpg" alt="Read our Feed" border="0" /></a><a href="http://twitter.com/#!/Psupplements" target="_blank"><img src="//lib.store.yahoo.net/lib/yhst-53160377742214/fb-twitter-icon.jpg" alt="Follow Us on Twitter" border="0" /></a><a href="http://www.youtube.com/user/psupplements" target="_blank"><img src="//lib.store.yahoo.net/lib/yhst-53160377742214/fb-youtube-icon.jpg" alt="Watch Us on YouTube" border="0" /></a>',// 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/yhst-53160377742214/fb-feat-cat-header.jpg" alt="Featured Facebook Categories" border="0" />', // categories header (home page).
        itemheader : '<img src="//lib.store.yahoo.net/lib/yhst-53160377742214/fb-feat-items-header.jpg" alt="Featured Facebook Items" border="0" />', // item header (home page).

    // define section properties
        sectionCaptionId : ".mss-caption", // .sectinfo on yahoo, .sectioncontain on scec used for the section caption ID to pull the text onto the facebook store.
        sectionPageHeadId : ".headline h1", // 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 : "#mss-item-elements", // PIT table clone, should be cloned before <form> element.
        imageAreaId : ".mss-item-image", // area you want to clone 
        mainImgId : "", // image Selector
        itemNameId : ".headline h1", // if name is part of the PIT, leave blank. Item Page name
        itemDescId : "#mss-item-caption", // 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.
		relatedId:".view-sample",
		xSellId:".x-sell",

        //info page properties
        infoPageId : ".mss-info-body", // 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() {

        //if (window.isFaceBookGlobalVar != undefined && window.isFaceBookGlobalVar != null)
            //return window.isFaceBookGlobalVar;
	
        return window.parent!==window.self && self.name.indexOf("app_runner_")==0 || typeof(fbtesting) !== "undefined";
    }
	
	window.isFaceBookGlobalVar=isFacebook();
	
	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' cellspacing='0' 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.cartId).length > 0){
	        p = 3;
		}
	    if($(this.config.infoPageId).length > 0) {
	        p = 4;
	    }
		
	    //if($(this.config.pagingTableId).length > 0)
	    //    this.pageType = 6;    
	    
		if($(this.config.productTableId).length > 0){
	        p = 2;
		}
		
		if($(this.config.contentsIdentity).length > 0) {
	        p = 5;
	    }
		
		if($(".mss-search-page-body").length > 0) {
			p = 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>'+
					'<div class="fbheadhtml2">' + this.config.headHTML2 + '</div>'+
					'<div class="cartlink">' + this.config.shoppingcartHtml + '</div>'+
					'<div id="fbheader-links">'+
						 '<ul>' +
							'<li><a href="'+this.domainurl+'/'+this.facebookpage+'">Home</a></li>'+
							'<li><a href="'+this.domainurl+'/info.html">About Us</a></li>'+
							'<li><a href="'+this.domainurl+'/freqasques.html">Shipping & Privacy</a></li>'+
							'<li><a href="'+this.domainurl+'/info.html">Contact Us</a></li>'+
							'<li><a href="'+this.domainurl+'" target="_blank">Visit Our Site</a></li>'+
						'</ul>'+
					'</div>'+
					'<div id="searcharea"><form method="POST" action="http://store.yahoo.com/cgi-bin/nsearch"><input name="vwcatalog" type="hidden" value="yhst-53160377742214"><input name="query" type="text" value="Search Products" size="" onfocus="if(this.value == this.defaultValue){this.value=\'\';}" class="searchIn" id="query" style="" onblur="if(this.value == \'\'){this.value= this.defaultValue;}"><input type="image" align="middle" id="searchsubmit" value="Go" src="/lib/yhst-53160377742214/fb-search-go.jpg" alt="Go" title="Go" class="btn"></form></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.domainurl+'/'+this.facebookpage+'">Home</a></li>'+
					'<li><a href="'+this.domainurl+'/info.html">About Us</a></li>'+
					'<li><a href="'+this.domainurl+'/freqasques.html">Shipping & Privacy</a></li>'+
					'<li><a href="'+this.domainurl+'/info.html">Contact Us</a></li>'+
					'<li><a href="'+this.domainurl+'" target="_blank">Visit Our Site</a></li>'+
				'</ul>'+
			'</div>'+
			'<div class="footer-info"><span>DISCLAIMER:</span> The information on this website reflects the opinion of our staff and manufacturers and should not be interpreted as medical advise. The descriptions and statements accompanying these products have not been evaluated by the FDA. These products are not intended to diagnose, treat, cure or prevent any disease. They are for use by healthy adults only. Consult your physician before begining any program. Keep all products out of the reach of children.</div>'+
			'<div class="fbcopyright">'+this.config.copyrightText+'<br /><a href="http://yahoo.solidcactus.com/facebook-store">Facebook Store</a> by <a href="http://www.solidcactus.com/">Solid Cactus</a></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>'+
		  '<form action="http://order.store.yahoo.net/yhst-53160377742214/cgi-bin/wg-order?yhst-53160377742214" method="post">'+
          '<div class="fbitemcontain">' +
              '<div class="fbtop"><table><tr></tr></table></div>' +
              '<div class="fbmid"><table><tr></tr></table></div>' +
          '</div></form>' +
		  
          '<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 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){ 
			$("#facebookcontent").html($(".products").html());
		}else {$(".fbprods").hide();}
		
	    if($(".categories").length > 0){ 
			$(".fbcategories").html($(".categories").html());
		}	else {$(".fbcats").hide();}
		
		
		
	    // 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);
		$('#fbcont-int').addClass("sectpage");
		
	    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)
			sectConts = $(this.config.contentsTableId).clone(true);	
			$("#facebookcontent").html(sectConts);
			/*$("#facebookcontent img").each(function(){
				$(this).jScale({w: '110px'});
			});
			
	    } else if($(this.config.pagingTableId).length > 0) {
		    this.writeContentsTable(this.config.pagingTableId,"#facebookcontent","fbsectiontable",true)
	    } else {
		    $(".fbprods").hide();
	    }	
		
		if($(this.config.pagingTableId).length > 0) {
		    $("#facebookcontent").html($(this.config.pagingTableId).html());
	    }
		
		*/
		
		if($("#contents-table").length > 0){
			var $sectconts = $("#contents-table").clone(true);
			$(".fbprods").html($sectconts);
		}
			
    }
    
    this.renderItemPage=function() {
        $('body').append(this.facebookitem);
		
		$('#fbcont-int').addClass("itempage");
    	
    	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);		
	    }
		
	    $('.fbtop table tr').prepend(prodImage);
		
	    var infoTable = $(this.config.productTableId).clone(true);
	    $('.fbmid table tr').append(infoTable);
		
	    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
			if(this.config.itemDescId.length > 0){
				$(".fbitemdesctxt").html($(this.config.itemDescId).html());		
			}
	    }
		
		if($(this.config.relatedId).length > 0){
			$(".fbrelated #fbrelatedcats").html($(this.config.relatedId).clone(true));
		}else{
			$(".fbrelated").remove();
		}
		
		if($(this.config.xSellId).length > 0){
			$(".fbcrossell #fbcsitems").html($(this.config.xSellId).clone(true));
		}else{
			$(".fbcrossell").remove();
		}
		
		$("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.renderSearchPage=function(){
		$('body').append(this.facebookhtmlcart);
		
		var $searchHtml = $(".mss-search-page-body").clone(true);
		$("#fbcont-int").html($searchHtml);	
	}

    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;
			case 6:
                this.renderSearchPage();
                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();

		    }

		    // 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("342589395759399","yhst-53160377742214","http://www.paramount-supplements.com","Paramount-Supplements",{mailinglisthtml : '<div class="mailinglist"><form name="ccoptin" action="http://visitor.r20.constantcontact.com/d.jsp" target="_blank" method="post"><font style="font-weight: normal; font-family:Arial; font-size:10px; color:#000000;">Sign Me Up!</font><input type="text" name="ea" size="14" value="" style="font-family: Arial; font-size:10px; border:1px solid #999999;">&nbsp;<input type="image" name="go" value="Join" class="submit" src="/lib/yhst-53160377742214/fb-mailing-go.jpg"><input type="hidden" name="llr" value="b5kdgpiab"><input type="hidden" name="m" value="1108611279809"><input type="hidden" name="p" value="oi"></form><div class="mailingtxt"><img src="//imgssl.constantcontact.com/ui/images1/safe_subscribe_logo.gif" border="0" width="168" height="14" alt=""><font style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#999999;"> For <a href="http://www.constantcontact.com/jmml/email-marketing.jsp" style="text-decoration:none;font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#999999;" target="_blank">Email Marketing</a> you can trust </font></div></div>'});

/*function isFaceBookGlobal() {
	
        return window.parent!==window.self && self.name.indexOf("app_runner_")==0 || typeof(fbtesting) !== "undefined";
    }

 if (isFaceBookGlobal()){
	 
	 $(".pr_snippet_category").remove();
 }*/
