// JavaScript Document

function couponEnd() {
	var time = new Date();		
	timezoneoffset = time.getTimezoneOffset();
	time.setTime(time.getTime() + timezoneoffset*60*1000); //GMT Time
	time.setTime(time.getTime() + -5*60*60*1000); //Eastern Time
	var match = false;
	//alert(time);
	
	//PRODUCTION DATE
	if (new Date('Sun May 31 23:59:59 EDT 2009') <= time) match=true;
	
	//TEST CONTEST BEGIN
	//if (new Date('Tue May 19 09:30:59 EDT 2009') <= time) match=true;
	
	return match;
}

 function resizeWin(newLoc, newWidth, newHeight) {
         newWin = open("",newLoc,"scrollbars=no,resizable=yes,status=no,height=" + newHeight + ",width=" + newWidth);
 }
 
 function showPopup(){

	var popUp = document.getElementById("leaving-content");
		popUp.style.visibility = "visible";
}

function hidePopup(){
   var popUp = document.getElementById("leaving-content");
   popUp.style.visibility = "hidden";
}
 
 //NAV ROLLOVERS
if (document.images) {
  
  n_cookies= new Image(); 
  n_cookies.src="images/nav/cookies_on.gif"; 
  
  n_history= new Image(); 
  n_history.src="images/nav/history_on.gif";
  
  n_share= new Image(); 
  n_share.src="images/nav/share_on.gif"; 
  
  n_events= new Image(); 
  n_events.src="images/nav/events_on.gif"; 
  
  n_offers = new Image(); 
  n_offers.src="images/nav/specialoffers_on.gif"; 
  
  n_fun= new Image(); 
  n_fun.src="images/nav/fun_on.gif"; 
  
  n_links= new Image(); 
  n_links.src="images/nav/links_on.gif"; 
  
  n_wheretobuy= new Image(); 
  n_wheretobuy.src="images/nav/wheretobuy_on.gif"; 
  
  n_login= new Image(); 
  n_login.src="images/nav/login_on.gif"; 
  
  n_register= new Image(); 
  n_register.src="images/nav/register_on.gif"; 
  
  subnav_previous= new Image(); 
  subnav_previous.src="images/subnav_previous_on.gif"; 
  
  subnav_index= new Image(); 
  subnav_index.src="images/subnav_index_on.gif"; 
  
  subnav_next= new Image(); 
  subnav_next.src="images/subnav_next_on.gif"; 
  
  subnav_scavengerhunt= new Image(); 
  subnav_scavengerhunt.src="images/subnav_scavengerhunt_on.gif"; 
  
  subnav_ecards= new Image(); 
  subnav_ecards.src="images/subnav_ecards_on.gif"; 
  
  subnav_facebook= new Image(); 
  subnav_facebook.src="images/subnav_facebook_on.gif"; 
  
  call_box_bottom= new Image(); 
  call_box_bottom.src="images/call-box-bottom_on.jpg"; 

}


function lightup(imgName) {
	if(document.images) {
		imgOn=eval(imgName + ".src");
		document[imgName].src= imgOn;
	}
 }

function turnoff(imgName) {
	if(document.images) {
		document[imgName].src = document[imgName].src.replace(/_on./g, ".");
	}
 }
 
 
 init = function() {
	setStyles();
}

// TEXT SIZER
// function that's called if pre-onload handlers are available
var preInitDone = false;
beforeOnloadInit = function() {
	preInitDone = true;
	init();	
};

// proprietary DOMContentLoaded Mozilla event handler
if (document.addEventListener) document.addEventListener("DOMContentLoaded", beforeOnloadInit, null);

// fall back to window.onload if needed
window.onload = function() { if (!preInitDone) init(); };

// load stylesheet for js-enabled browsers
if(document.getElementById && document.createTextNode) {
	document.writeln("<link href=\"/js_enabled.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />");
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

setStyles = function() {
  var cookie = readCookie("mothersStyles");
  var title = cookie ? cookie : "0";
	createCookie("mothersStyles", title, 365);
 	setActiveStyleSheet(title);
	ts(title,'bg-wrapper');
}

setActiveStyleSheet = function(title) {

  
}

createCookie = function(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

readCookie = function(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
--------------------------------------------------------------*/

//Specify affected tags. Add or remove from list:
var tgs = new Array('span');

//Specify spectrum of different font sizes:
var szs = new Array( '13px','16px','18px' );

ts = function( sz, trgt ) {
	if (!document.getElementById) return;
	var d = document,cEl = null,i,j,cTags;

	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
	cEl.style.fontSize = szs[ sz ];
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		
		for ( j = 0 ; j < cTags.length ; j++ ) {
				if (!(cTags[ j ].id == 'disclaimer')) {
				cTags[ j ].style.fontSize = szs[ sz ];
			}
				
			
		}
	}
		
	createCookie("mothersStyles",  sz , 365);
	setActiveStyleSheet( sz );
}

function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}


function isFlashTen(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	var ua = navigator.userAgent.toLowerCase();
	var isWin = (ua.indexOf('win') != -1);
	var isIE = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) );
	var isOpera = (ua.indexOf("opera") != -1);
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	if(parseInt(flashVer)>=10)
		return true;
	else
		return false;
}


