﻿var RateWindow
function openRateRecipe(recipeId) {
	if (!RateWindow || RateWindow.closed) {
    	RateWindow = window.open("RecipeRate.aspx?rid=" + recipeId, 'Rate', 'width=425,height=445,scrollbars=0')
	} else {
		RateWindow.focus()
	}
}

/* global nav rollovers */
/* DELETE the nav rollovers below since this nav was replaced
var imgSuffix = ".gif";
var imgPrefix = "img/";
var imgStates = new Array("", "_on");
var imgNames = new Array(
  'nav_fiber_counter', 
  'nav_recipes',
  'nav_tips',
  'nav_honey_clusters',
  'nav_raisin_bran',
  'nav_mix_it_up',
  'nav_contact2'
);

var imgObjs = new Array();
var ii, jj, nn;

for(ii = 0; ii < imgNames.length; ii++)
  for(jj = 0; jj < imgStates.length; jj++){
    nn = imgNames[ii] + imgStates[jj];
    imgObjs[nn] = new Image();
    imgObjs[nn].src = imgPrefix + nn + imgSuffix;
  }

function swap(img, state){
  if(!document.images) return;
  document.images[img].src = imgObjs[state].src;
}

END DELETE nav
*/

/* popup window function */

var forcedRefresh = true;
var alreadyopen = new Array();
var newwin = new Array();

function displayFiberCounter() { 

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="735" height="478" id="fiber_one_counter" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="fiber_one_counter.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="fiber_one_counter.swf" quality="high" bgcolor="#ffffff" width="735" height="478" name="fiber_one_counter" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'); 

}



function openCenteredWindow(uri, name, features, width, height){

  var winl = parseInt((screen.width - width - 10) / 2),
      wint = parseInt((screen.height - height - 29) / 2);
  openWindow(uri, name, features + (features ? ',' : '') + 'height=' + height + ',width=' + width + ',top=' + wint + ',left=' + winl);
}

function openWindow(uri, name, features){

  if(!forcedRefresh && alreadyopen[name] && !newwin[name].closed){
    newwin[name].focus();
  }
  else{
    alreadyopen[name] = true;
    newwin[name] = window.open(uri, name, features);
    newwin[name].focus();
  }
}

/* popup window variants */
function openCompare() {
  openCenteredWindow('fiber_one_compar_loader.html','comparison','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes','740','300');


}
/* the openCompChart below is not used; it was moved to js/functions.js */
function openCompChart(){
	
  /*openCenteredWindow('comparison.html','comparison','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no','650','500');*/
  openWindow('comparison.html','comparisonChart','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no','600','500');
}
function openCounter(){
  openCenteredWindow('/Counter.aspx','counter','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no','750','495');
}
function openPeanutButter(){
  openCenteredWindow('/PeanutButter.aspx','peanutbutter','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no','700','530');
}
function closePopup(){
  self.close ();
}
function openTellFriend(section){

  openCenteredWindow('/Benefits/TellAFriend.aspx?section=' + section,'tellFriend','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no','650','400');
}
function openEmailRecipe(recipe){

  openCenteredWindow('/Recipes/RecipeEmail.aspx?rid=' + recipe,'emailRecipe','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no','650','400');
}

function openTellFriendCounter(){ openTellFriend(1); }
function openTellFriendRecipes(){ openTellFriend(2); }
function openTellFriendMix(){ openTellFriend(3); }


function DocumentWriter(strHTML) {
	document.write(strHTML);
}

function toggleDiv(id) {
    var el = document.getElementById(id);
    if (el.style.display != 'block') {
        el.style.display = 'block';
    }
    else {
        el.style.display = 'none';
    }
}

function loadFooter(strURL, strTitle, intWidth, intHeight) {
    var newWin;
    newWin = window.open(strURL, strTitle, "width=" + intWidth + ",height=" + intHeight + ",scrollbars=1,resizable=0");
}

function validateCheckBoxList(cbl) {
     var chkListModules = document.getElementById(cbl);
    var chkListinputs = chkListModules.getElementsByTagName("input");
     for (var i = 0; i < chkListinputs.length; i++) {
         if (chkListinputs[i].checked) {            
            return true;
        }
    }
    return false; 
}