var popupsIncluded;
function moveFocus (xcord,ycord) {
this.moveTo(xcord,ycord);
this.focus();
}

function moveNoFocus (xcord,ycord) {
this.moveTo(xcord,ycord);
}

function wfPopupWindowFix(name,link,width,height) {
	var remote = null;
    remote = window.open(link,name,"width=" + width + ",height=" + height + ",screenX=100,screenY=200,top=50,left=80,resizable=yes,scrollbars=yes");
    if (remote != null) {
	  if (remote.opener == null) {
  	    remote.opener = self;
	  }
      remote.name = name;
      remote.focus();
    }
}

function wfPopupWindowPos(name,link,width,height,top,left) {
	var remote = null;
    remote = window.open(link,name,"width=" + width + ",height=" + height + ",screenX=" + left + ",screenY=" + top + ",top=" + top + ",left=" + left + ",resizable=yes,scrollbars=yes");
    if (remote != null) {
	  if (remote.opener == null) {
  	    remote.opener = self;
	  }
      remote.name = name;
      remote.focus();
    }
}

function wfPopupWindowPosStatus(name,link,width,height,top,left) {
	var remote = null;
    remote = window.open(link,name,"width=" + width + ",height=" + height + ",screenX=" + left + ",screenY=" + top + ",top=" + top + ",left=" + left + ",resizable=yes,scrollbars=yes,status=yes");
    if (remote != null) {
	  if (remote.opener == null) {
  	    remote.opener = self;
	  }
      remote.name = name;
      remote.focus();
    }
}

function wfGotoLocation(link) {
	window.location = link;
}

function wfPopupEmailFriend(link,brand,host) {
	popupWindowFix('email','/'+brand+'/emailFriend/emailFriend.jhtml' + '?pageUrl=http://'+host+link,450,550)
}

function wfPopupEmailFriend(link,brand,host,template) {
	popupWindowFix('email','/'+brand+'/emailFriend/emailFriend.jhtml' + '?emailTemplate='+template+'&pageUrl=http://'+host+link,400,490)
}

function popupWindowFix(name,link,width,height) {
    wfPopupWindowFix(name,link,width,height);
}

function popupWindowPos(name,link,width,height,top,left) {
  wfPopupWindowPos(name,link,width,height,top,left);
}

function gotoLocation(link) {
	for (i=0; i<window.document.forms.length; i++)
	{
		if (window.document.forms[i].name == "jumps" ? 1 : 0){window.document.forms[i].reset()};
	}
  	wfGotoLocation(link)
}

function popupEmailPage(link,pageUrl) {
  popupWindowFix('email',link + '?pageUrl='+escape(pageUrl),450,550)  
}

function popupEmailPage(link,pageUrl,additionalParams) {
  popupWindowFix('email',link + '?pageUrl='+escape(pageUrl)+'&'+ additionalParams,400,490)  
}

function popupEmailFriend(link,brand,host) {
  wfPopupEmailFriend(link,brand,host);
}

function popupEmailFriend(link,brand,host,template) {
  wfPopupEmailFriend(link,brand,host,template);
}

function stamper(){
	TDay = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
	TMonth = new Array('Jan.', 'Feb.', 'March', 'April', 'May', 'June', 'July', 'Aug.', 'Sept.', 'Oct.', 'Nov.', 'Dec.');
	TDate = new Date();
	CurDayOw = TDate.getDay();
	CurMonth = TDate.getMonth();
	CurDay= TDate.getDate();
	TheDate  = TDay[CurDayOw] + ', ';
	TheDate += TMonth[CurMonth] + ' ';
	TheDate += CurDay;
	document.write(TheDate);
}
function showAdCloseBox() {
	var ns4=document.layers;
	var ie4=document.all;
	var ns6=document.getElementById&&!document.all;	
	var adCloseDiv=ns6? document.getElementById("adCloseBoxDiv") : document.all.adCloseBoxDiv;	
	if (popupsIncluded) {
    	if (ie4||ns6){			
			adCloseDiv.style.visibility="visible";
		} else if (ns4) {
			document.adCloseDiv.visibility="show";
		}			
    }
}
function showAdCloseBottom() {
	var ns4=document.layers;
	var ie4=document.all;
	var ns6=document.getElementById&&!document.all;	
	var adBottomCloseDiv=ns6? document.getElementById("adCloseBottomDiv") : document.all.adCloseBottomDiv;	
	if (popupsIncluded) {
    	if (ie4||ns6){			
			adBottomCloseDiv.style.visibility="visible";
		} else if (ns4) {
			document.adBottomCloseDiv.visibility="show";
		}			
    }
}
function handleOnLoad() {
	if (popupsIncluded) showAdCloseBox();
	if (popupsIncluded) showAdCloseBottom();
}
function poloaded() {
    if (popupsIncluded) moveFocus(25,25);
    this.focus();
}

function popUpFullScreen(name,link) {
	var remote = null;
    remote = window.open(link,name,"locationbar=yes,menubar=yes,scrollbars=yes,statusbar=yes,toolbar=yes,width=600,height=400,left=0,top=0");
    if (remote != null) {
	  if (remote.opener == null) {
  	    remote.opener = self;
	  }
      remote.name = name;
      remote.focus();
    }
}

function openCoolSavingsPopup() {
    popUpFullScreen("coolsavingspopup","/common/partner/coolsavings/coolsavingsPopup.jhtml");
}

document.write('<SCRIPT LANGUAGE=JavaScript>var javascript_version = 1.0;</SCRIPT>');
document.write('<SCRIPT LANGUAGE=JavaScript1.1>javascript_version = 1.1;</SCRIPT>');
document.write('<style>.launcher {border:0; cursor: pointer; cursor: hand;}</style>');

var newwin;
function LaunchDirect(LaunchCode)
{
var winname;
var winurl;
var winfeatures;
winfeatures = "width=792, height=550, resizable=1, top=0, left=0"
winurl = "http://viewers.multicastmedia.com/viewer/SystemCheck.aspx?Param="+LaunchCode;
	newwin = window.open(winurl,winname,winfeatures);
	if(javascript_version > 1.0)
	{
 		setTimeout('newwin.focus();',250);
	}
}

//  ************** OLD FORM VALIDATION NOT SURE IT IS USED *************

function validate (formName) {
	var form;
	if(formName == "bhgsubscribe"){
	   form = window.document.bhgsubscribe;
	}
	else if( formName == "bhgsubscribepop"){
	    form = window.document.bhgsubscribepop;
	}
	var success = true;
	for(i=0; i < form.elements.length ;i++) {
		if (form.elements[i].type == "text")
		{
			if (form.elements[i].value == "") {
				success = false;
			}
		}
	}
	if (!success ) {
		alert("Please, make sure you fill all the fields in the form");
	}
	return success
}

//  ************** OLD EMAIL INFO *************

// The code from below is courtesy of http://developer.netscape.com.
// 18 Feb 97 created Eric Krock
// (c) 1997 Netscape Communications Corporation
var defaultEmptyOK = false
var whitespace = " \t\n\r";
function isEmail (s)
{   if (isEmpty(s))
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);

    // is s whitespace?
    if (isWhitespace(s)) return false;

    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}
// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

//*********************************************
//  prevents really really long email addresses
//*********************************************
function shortenString(max, text) {
    max--;
    text = "" + text;
    var temp = ""; var chcount = 0;
    for (var i = 0; i < text.length; i++){
    var ch = text.substring(i, i+1); // first character
    var ch2 = text.substring(i+1, i+2); // next character
    // if character is a hard return
    if (ch == '\n'){ temp += ch; chcount = 1; }
    else{
        // line has max chacters on this line
        if (chcount == max){ temp += '<br/>' + ch; chcount = 1; }
        else{ temp += ch; chcount++; }
    }
    }
    return (temp); // sends value of temp back
}