// common_scripts.js

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function myModal(myWindow,winWidth,winHeight) {
  window.showModalDialog(myWindow, null, "dialogWidth:" + winWidth + " px;dialogHeight:" + winHeight + "px;center:1;scroll:1;help:0;status:0");
}

function myModal2(myWindow,winWidth,winHeight,winScroll) {
  window.showModalDialog(myWindow, null, "dialogWidth:" + winWidth + " px;dialogHeight:" + winHeight + "px;center:1;scroll:" + winScroll + ";help:0;status:0");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*  shiftHighlight Javascript for selection list "type ahead"
	Please keep the following lines visible, in recognition of my work...
	************************
	Author: Max Holman <max@blueroo.net>
	Date  : Sun, 21 Jan 2001
	************************
	This functions lets users type in letters to select an option in your SELECT form fields.
	Usually the browser only takes notice of single keystrokes and switches to the first Option that
	begins with that letter.
	This scripts buffers the users input and compares it against the OPTIONs in the SELECT field,
	choosing the closest match as you type
	Usage:	<SELECT onKeyPress = "return shiftHighlight(event.keyCode, this);">

	Platform: Only tested on IE5 (Win) - will not work on Netscape
*/
	var timerid     = null;
	var matchString = "";
	var mseconds    = 2000;	// Length of time before search string is reset
	function shiftHighlight(keyCode,targ)
	{
		keyVal      = String.fromCharCode(keyCode); // Convert ASCII Code to a string
		matchString = matchString + keyVal; // Add to previously typed characters
		elementCnt  = targ.length - 1;	// Calculate length of array -1

		for (i = elementCnt; i > 0; i--)
		{
			selectText = targ.options[i].text.toLowerCase(); // convert text in SELECT to lower case
			if (selectText.substr(0,matchString.length) == 	matchString.toLowerCase())
			{
				targ.options[i].selected = true; // Make the relevant OPTION selected
			}
		}
		clearTimeout(timerid); // Clear the timeout
		timerid = setTimeout('matchString = ""',mseconds); // Set a new timeout to reset the key press string
		return false; // to prevent IE from doing its own highlight switching
	}

<!--
// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) ||
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;
else
   return false;
}

function OriginalSearch(searchTerms) {

	//document.SearchBoxForm.UserEnteredSearchTerms.value = searchTerms;
	//Search();
	alert("using javascript for search sort original has been depracated");
}

function validateZipCode(zip) {
	var result = null;
	if(zip == null || zip.length == 0) {
		result = "Please enter a zip code";
	}
	if(zip.length < 5) {
		result = "Zip code must contain at least 5 numbers. Please enter a valid zip code.";
	}
	if(isNaN(parseInt(zip))) {
		result = "Please enter a 5 digit zip code with only numbers.";
	}
	return result;
}

function submitECard(submitView) {
	document.ecardForm.action = submitView;
	document.ecardForm.submit();
}

<!--
	/**
	 * Name: didFormChange v2
	 * Description:
	 *		checks for changes to the form
	 */
	function didFormChange(fields)
	{
		//var fields = formObject.elements;
		var changes = false;
		for (var k = 0; k < fields.length; k++ )
		{
			if (changes)
			{
				break;
			}
			switch (fields[k].type)
			{

				case "checkbox":
				case "radio":
					if (fields[k].defaultChecked != fields[k].checked)
					{
						changes = true;
						break;
					}
				case "select-one":
				case "select-multiple":

					var defVal = new Array();
					var newVal = new Array();
					for (var i=0; i < fields[k].length; i++)
					{
						if(fields[k].options[i].defaultSelected)
						{
							defVal.push(fields[k].options[i].value);
						}
						if (fields[k].options[i].selected)
						{
							newVal.push(fields[k].options[i].value)
						}
					}

					defVal.sort();
					newVal.sort();

					for (var t=0; t < newVal.length; t++)
					{
						for(var u=0; u< defVal; u++)
						{
							if (newVal[t] != defVal[u])
							{
								changes = true;
								break;
							}
						}
					}
					break;
				default:
					if (fields[k].defaultValue != fields[k].value)
					{
						changes = true;
						break;
					}
			}
		}

		return changes;
	}

function doClock(){ // By Paul Davis - www.kaosweaver.com
  var t=new Date(),a=doClock.arguments,str="",i,a1,lang="1";
  var month=new Array('January','Jan', 'February','Feb', 'March','Mar', 'April','Apr', 'May','May', 'June','Jun', 'July','Jul', 'August','Aug', 'September','Sep', 'October','Oct', 'November','Nov', 'December','Dec');
  var tday= new Array('Sunday','Sun','Monday','Mon', 'Tuesday','Tue', 'Wednesday','Wed','Thursday','Thr','Friday','Fri','Saturday','Sat');
  for(i=0;i<a.length;i++) {a1=a[i].charAt(1);switch (a[i].charAt(0)) {
  case "M":if  ((Number(a1)==3) && ((t.getMonth()+1)<10)) str+="0";
  str+=(Number(a1)>1)?t.getMonth()+1:month[t.getMonth()*2+Number(a1)];break;
  case "D": if ((Number(a1)==1) && (t.getDate()<10)) str+="0";str+=t.getDate();break;
  case "Y": str+=(a1=='0')?t.getFullYear():t.getFullYear().toString().substring(2);break;
  case "W":str+=tday[t.getDay()*2+Number(a1)];break; default: str+=unescape(a[i]);}}return str;
}

// This function is dependent on the s_code_remote.js file in order to obtain
// the account and list of file extensions
function openMe(parent, url, name, features) { //v2.0
  re=/,/
  extList = s_linkDownloadFileTypes.split(re)
  for(i=0;i<extList.length;i++) {
    re.compile(extList[i]+"$")
    if (re.test(url)) {
      s_linkType="d"
      s_linkName=url
      s_lnk=s_co(parent)
      s_gs(s_account)
    }
  }
  window.open(url,name,features)
}

function popupParentGoToURL(url){
	window.opener.location.href = url;
}

function doSel(obj){
     for (i = 1; i < obj.length; i++)
        if (obj[i].selected == true)
           eval(obj[i].value);
}

function productDetailInfo() {
	var loc = window.location.toString();
	if (loc.lastIndexOf('EnlargeProductView') < 0 ) {
		var	productDetailInfo = "<a href=\"/webapp/wcs/stores/servlet/article|10001|10051|/GogruMogruSite/PartyExpress/PE_CONTACT_US\" style=\"color:#000000;font-size:13px;font-weight:bold;\" ><u>If interested in this item and want more information, contact us.</u></a> >";
		document.write(productDetailInfo);
	}
}

/***** Start of ActiveContent3.0 JavaScript ******
 *  PT_AC_ prefixing on variables and functions to minimize namespace conflicts
 *  Note that function PT_AC_Write auto-appends fmt=JsEnhanced
 */
// This is ActiveContent30.js
// Copyright (c) 2003 Prospero Technologies LLC
// Part of Prospero Active Content 3.0
// This file includes functions required for external manipulation
// of Active Content, e.g. voting in polls
var PTAC_PollWindowName = "pollwindow";
var PTAC_PollWindowParams = "resizable=yes,scrollbars=yes,height=524,width=524";

function PTAC_PollVote(pollGroup, pollActionURL)
{
	// first, find which radio button is selected
	var selectedVal = 0;
	var df = document.forms;
	for ( var g = 0; g < df.length; g++ ) {
		for ( var h = 0; h < df[g].elements.length; h++ ) {
			if ( df[g].elements[h].name == pollGroup ) {
				for (var ix = 0; ix < df[g].elements.length; ix++) {
					if (df[g].elements[ix].checked && (df[g].elements[ix].name == pollGroup))
						{
							selectedVal = df[g].elements[ix].value;
							break;
						}
					}
				}
			}
		}

	if (selectedVal == 0)
	{
		alert("Please make a choice.");
	}
	else
	{
		newwindow = window.open(pollActionURL + selectedVal, PTAC_PollWindowName, PTAC_PollWindowParams);
		newwindow.focus();
	}
	return false;
}

function PTAC_PollResults(pollActionURL)
{
	newwindow = window.open(pollActionURL, PTAC_PollWindowName, PTAC_PollWindowParams);
	newwindow.focus();
	return false;
}

function PTAC_SubmitTalkback()
{
	var domain = document.getElementById("PTAC_domain").value;
	var newUrl = "http://" + domain + "/dir-app/acx/ACPost.aspx?toUserId=0";
	newUrl += PTAC_AddUrlParam("webtag");
	newUrl += PTAC_AddUrlParam("folderId");
	newUrl += PTAC_AddUrlParam("tid");
	newUrl += PTAC_AddUrlParam("subject");
	newUrl += PTAC_AddUrlParam("contentId");
	newUrl += PTAC_AddUrlParam("returnUrl");
	newUrl += PTAC_AddUrlParam("contentUrl");
	newUrl += PTAC_AddUrlParam("signature");
	newUrl += PTAC_AddUrlParam("body");
	window.location = newUrl;
}

function PTAC_AddUrlParam(elmId)
{
	var ctl = document.getElementById("PTAC_" + elmId);
	if (ctl)
		return "&" + elmId + "=" + ctl.value;
	else
		return "";
}
//******** End of ActiveContent3.0 JavaScript ****

/***** Start of Active Content JavaScript (V 3.0) For JsEnhanced ******
 *  PT_AC_ prefixing on variables and functions to minimize namespace conflicts
 *  Note that function PT_AC_Write auto-appends fmt=JsEnhanced
 */
// the following variable can be set to control the AC behavior for older or rarer browsers
var PT_AC_OldBrowserSupport = 1;	// For browsers that don't support innerHTML
							// 0=only show defaultHTML, 1=Show AC except during maintenance windows
							// 2=always show AC

// the remaining code should be left as-is
var PT_AC_SupportLevel = -1;	// -1 none (default), 0 document.write, 1 innerHTML, 2 getElementById.innerHtml
var PT_AC_SrcArray = new Array();
var PT_AC_Total = 0;

if (document.getElementsByTagName) {
	if (document.getElementsByTagName("HEAD")[0].innerHTML) {
		if (document.getElementById)
			PT_AC_SupportLevel = 2;
		else
			PT_AC_SupportLevel = 1;
	}
}
else if (document.all) {
	if (document.all[0].innerHTML) {
		if (document.getElementById)
			PT_AC_SupportLevel = 2;
		else
			PT_AC_SupportLevel = 1;
	}
}

function PT_AC_CheckMaintWindow() {
	PT_AC_SupportLevel = 0;
	if (PT_AC_OldBrowserSupport == 1) {
		var PT_AC_Now = new Date();
		PT_AC_Now.setHours(PT_AC_Now.getHours() + (PT_AC_Now.getTimezoneOffset()/60) - 5);
		var PT_AC_Day = PT_AC_Now.getDay();
		var PT_AC_Month = PT_AC_Now.getMonth();
		var PT_AC_Date = PT_AC_Now.getDate();
		if (PT_AC_Day == 3 || PT_AC_Day == 6) {
			if ((PT_AC_Month > 4 || (PT_AC_Month == 4 && ((PT_AC_Day == 3 && PT_AC_Date > 3) || (PT_AC_Day == 6 && PT_AC_Date > 6)))) &&
				(PT_AC_Month < 10 || (PT_AC_Month == 10 && ((PT_AC_Day == 3 && PT_AC_Date < 28) || (PT_AC_Day == 6 && PT_AC_Date < 31)))))
				PT_AC_Now.setHours(PT_AC_Now.getHours() + 1);
			if (PT_AC_Now.getHours() >= 5 && PT_AC_Now.getHours() <= 6)
				PT_AC_SupportLevel = -1;
		}
	}
}

function PT_AC_Write(PT_AC_Src, PT_AC_DefaultHTML) {
	PT_AC_Total++;
	PT_AC_SrcArray[PT_AC_Total] = PT_AC_Src + '&fmt=JsEnhanced&DivId=' + PT_AC_Total;
	if (PT_AC_SupportLevel > 0)
		document.write ('<div id="PT_AC_DivId'+PT_AC_Total+'">'+PT_AC_DefaultHTML+'<\/div>');
	else if (PT_AC_SupportLevel == 0)
		document.write ('<script src="' + PT_AC_SrcArray[PT_AC_Total] + '"><\/script>');
	else
		document.write (PT_AC_DefaultHTML);
}

function PT_AC_Rewrite(PT_AC_DivId, PT_AC_NewHTML) {
	if (PT_AC_SupportLevel == 2)
		document.getElementById(PT_AC_DivId).innerHTML=PT_AC_NewHTML + "\n";
	else if (PT_AC_SupportLevel == 1)
		eval ('document.all.' + PT_AC_DivId + '.innerHTML =PT_AC_NewHTML + "\n";');
	else
		document.write (PT_AC_NewHTML);
}

function PT_AC_Iterate() {
	if (PT_AC_SupportLevel > 0 && PT_AC_Total > 0) {
		var PT_AC_Ctr;
		for (PT_AC_Ctr = 1; PT_AC_Ctr <= PT_AC_Total; PT_AC_Ctr++) {
			document.write ('<script src="' + PT_AC_SrcArray[PT_AC_Ctr] + '"><\/script>');
		}
	}
}

function getDirectTopEspot() {

	//var loc = window.location.toString();
	//if (loc.lastIndexOf('EnlargeProductView') < 0 ) {
		//var	productDetailInfo = "";

		//var productDetailInfo = "<a href=\"/webapp/wcs/stores/servlet/category3|10001|10051|128552|-2;88564;128552|products|Flowers Free Shipping\"><img src=\"/wcsstore/GogruMogruStore/images/Content/shop_bnr_espot.gif\" width=\"773\" height=\"40\" border=\"0\"></a>";

		//var	productDetailInfo = "<a href=\"/webapp/wcs/stores/servlet/article|10001|10051|/GogruMogruSite/PartyExpress/PE_CONTACT_US\" style=\"color:#000000;font-size:13px;font-weight:bold;\" ><u>If interested in this item and want more information, contact us.</u></a> >";

		//var	productDetailInfo = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"550\" height=\"320\">";
		//	productDetailInfo += "  <param name=\"movie\" value=\"partyExpress.swf\">";
		//	productDetailInfo += "  <param name=\"quality\" value=\"high\">";
		//	productDetailInfo += "  <embed src=\"partyExpress.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"550\" height=\"320\"></embed>";
		//	productDetailInfo += "</object>";

		//document.write(productDetailInfo);

	//}
}

function getDirectLeafEspot() {

	//var loc = window.location.toString();
	//if (loc.lastIndexOf('EnlargeProductView') < 0 ) {
		//var	productDetailInfo = "<a href=\"/webapp/wcs/stores/servlet/category3|10001|10051|115052|-2;88564;115052|products|After%20Christmas%20Sale\"><img src=\"/wcsstore/GogruMogruStore/images/Content/shop_bnr_general.gif\" width=\"550\" height=\"130\" border=\"0\"></a>";

		//var	productDetailInfo = "<a href=\"/webapp/wcs/stores/servlet/article|10001|10051|/GogruMogruSite/PartyExpress/PE_CONTACT_US\" style=\"color:#000000;font-size:13px;font-weight:bold;\" ><u>If interested in this item and want more information, contact us.</u></a> >";

		//var	productDetailInfo = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"550\" height=\"320\">";
		//	productDetailInfo += "  <param name=\"movie\" value=\"partyExpress.swf\">";
		//	productDetailInfo += "  <param name=\"quality\" value=\"high\">";
		//	productDetailInfo += "  <embed src=\"partyExpress.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"550\" height=\"320\"></embed>";
		//	productDetailInfo += "</object>";

		//document.write(productDetailInfo);

	//}
}

if (PT_AC_SupportLevel == -1 && PT_AC_OldBrowserSupport > 0)
		PT_AC_CheckMaintWindow();

//******** End of Active Content JavaScript (V 3.0) For JsEnhanced ******


/*
 * Utility functions
 */
var Util = function() {

  //public methods
  return {
    getCookieValue : function( cookie_name )
    {
 	  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
      if ( results ) { results = unescape ( results[1] ) ; }
      else { results = null; }

    if (results == null)
    {
      return results;
    }
	// URL decode the message
	// Replace + with ' '
	// Replace %xx with equivalent character
	// Put [ERROR] in output if %xx is invalid.
	var HEXCHARS = "0123456789ABCDEFabcdef";
	var encoded = results;
	var plaintext = "";
	var i = 0;
	while (i < encoded.length)
	{
		var ch = encoded.charAt(i);
		if (ch == "+")
		{
			plaintext += " ";
			i++;
		}
		else if (ch == "%")
		{
			if (i < (encoded.length-2)
				&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
				&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 )
			{
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			}
		}
		else
		{
			plaintext += ch;
			i++;
		}
	} // while
	results = plaintext;

      return results;
    },
    /*
     *  Returns false if user is logged on.
     */
    isGuest : function()
    {
      var c = Util.getCookieValue('cacheCookie');
      if (c != null)
      {
        if (c == 1)
        {
          return false;
        }
      }
      return true;
    },
    /*
     *  Adds the given function to the page's onLoad event.
     */
    addLoadListener : function (fn)
    {
      if (typeof window.addEventListener != 'undefined')
      {
        window.addEventListener('load', fn, false);
      }
      else if (typeof document.addEventListener != 'undefined')
      {
        document.addEventListener('load', fn, false);
      }
      else if (typeof window.attachEvent != 'undefined')
      {
        window.attachEvent('onload', fn);
      }
      else
      {
        var oldfn = window.onload;
        if (typeof window.onload != 'function')
        {
          window.onload = fn;
        }
        else
        {
          window.onload = function()
          {
            oldfn();
            fn();
          };
        }
      }
    },
    getParameter : function( name )
    {
      var regexS = "[\\?&]"+name+"=([^&#]*)";
      var regex = new RegExp( regexS );
      var tmpURL = window.location.href;
      var results = regex.exec( tmpURL );
      if( results == null )
      {
        return "";
      }
      else
      {
        return unescape(results[1]);
      }
    }
  };
}();




