//CostumeZone 2011 Header Script

// Secure or Insecure
var cz_baseurl
var cz_secure

if ("https:" == document.location.protocol) 
	{     
		cz_baseurl="https://costumezone.com";
		cz_secure="yes"
	} 
else 
	{     
		cz_baseurl="http://c1334242.cdn.cloudfiles.rackspacecloud.com";
		cz_secure="no"
	} 



// Holiday Information

var cz_holiday
var cz_holiday_date
		
//		//	Static Holidays
var cz_date_valentines="February 14, 2012"
var cz_date_stpatricks="March 17, 2012"
var cz_date_fourthofjuly="July 4, 2012"
var cz_date_halloween="October 31,2012"
var cz_date_christmas="December 25, 2012"

//		//	Moving Holidays
var cz_date_mardigras="February 21, 2012"
var cz_date_easter="April 8, 2012"
var cz_date_thanksgiving="November 22, 2012"

var cz_nearest_holiday=""
var cz_date_nearest_holiday=""

// What is the Closest Holiday
var currentTime = new Date()
var cz_month = currentTime.getMonth() + 1
var cz_day = currentTime.getDate()
var cz_year = currentTime.getFullYear()

if (cz_month<=1)
	{
	cz_nearest_holiday="Valentine's Day"
	cz_date_nearest_holiday=cz_date_valentines;
	}
else if (cz_month<=2 && cz_day <=14)
	{
	cz_nearest_holiday="Valentine's Day"
	cz_date_nearest_holiday=cz_date_valentines;
	}
else if (cz_month<=3 && cz_day<=17)
	{
	cz_nearest_holiday="St. Patrick's  Day"
	cz_date_nearest_holiday=cz_date_stpatricks;
	}
 else if (cz_month<=4 && cz_day<=24)
	{
	cz_nearest_holiday="Easter"
	cz_date_nearest_holiday=cz_date_easter;
	}
 else if (cz_month<=7 && cz_day<=4)
	{
	cz_nearest_holiday="Independence Day"
	cz_date_nearest_holiday=cz_date_fourthofjuly;
	}
 else if (cz_month<=10 && cz_day<=31)
	{
	cz_nearest_holiday="Halloween"
	cz_date_nearest_holiday=cz_date_halloween;
	}
 else if (cz_month<=11 && cz_day<=24)
	{
	cz_nearest_holiday="Thanksgiving"
	cz_date_nearest_holiday=cz_date_thanksgiving;
	}
 else if (cz_month<=12 && cz_day<=25)
	{
	cz_nearest_holiday="Christmas"
	cz_date_nearest_holiday=cz_date_christmas;
	}
 else
	cz_nearest_holiday="Halloween"
	cz_date_nearest_holiday=cz_date_halloween;


//Cookie Information

function CZ_Set_Cookie(name, value) 
{
	var today = new Date()
	var expires = new Date()
	expires.setTime(today.getTime() + 1000*60*60*24*30) // expires in a month
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +";path=/"
	}
function CZ_Get_Cookie(Name) 
{  
	var search = Name + "="
	if(document.cookie.length > 0) {
	offset = document.cookie.indexOf(search)
	if(offset != -1) {
	offset += search.length
	end = document.cookie.indexOf(";", offset)
	if(end == -1) end = document.cookie.length
	return unescape(document.cookie.substring(offset, end))}
	else return ""
			}
}

//Affiliate & Gender & Zone Information

function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
   }
}
return params;
}
params = getParams();
// -->

var cz_affiliate=("CZone")
//var cz_affiliate_string
var cz_affiliate_cookie

//cz_affiliate_string = unescape(params["affiliate"]);

if (cz_affiliate_string)
	{		cz_affiliate = cz_affiliate_string;		}

if (cz_affiliate_string !="Hz" && 
		cz_affiliate_string !="hz" && 
		cz_affiliate_string !="hu" && 
		cz_affiliate_string !="hg" && 
		cz_affiliate_string !="ht" && 
		cz_affiliate_string !="hd" &&
		cz_affiliate_string !="hcd" &&
		cz_affiliate_string !="DSC" &&
		cz_affiliate_string !="dsc" &&
		cz_affiliate_string !="cd" && 
		cz_affiliate_string !="cc" && 
		cz_affiliate_string !="hph" && 
		cz_affiliate_string !="sexy" && 
		cz_affiliate_string !="christmas" && 
		cz_affiliate_string !="mascot" && 
		cz_affiliate_string !="renaissance" && 
		cz_affiliate_string !="fourthofjuly" &&
		cz_affiliate_string !="easter" && 
		cz_affiliate_string !="stpatricks" && 
		cz_affiliate_string !="valentines" && 
		cz_affiliate_string !="thanksgiving" &&
		cz_affiliate_string !="mardigras" &&
		cz_affiliate_string !="paperatwork" && 
		cz_affiliate_string !="paw" && 

		cz_affiliate_string !="adults" &&
		cz_affiliate_string !="womens" &&
		cz_affiliate_string !="mens" &&
		cz_affiliate_string !="kids" &&
		cz_affiliate_string !="girls" &&
		cz_affiliate_string !="boys" &&
		cz_affiliate_string !="toddler" &&
		cz_affiliate_string !="infant" &&
		cz_affiliate_string !="plussize" &&
		cz_affiliate_string !="pet" )

	{
		cz_affiliate = "CZone";
	}

if (cz_affiliate !="CZone")
	{	CZ_Set_Cookie("cz_affiliate",cz_affiliate);		}

if (cz_affiliate_string == "CZone" || cz_affiliate_string == "")
	{	CZ_Set_Cookie("cz_affiliate","CZone");			}

cz_affiliate_cookie = CZ_Get_Cookie("cz_affiliate");

if (cz_affiliate_cookie)
	{	cz_affiliate=cz_affiliate_cookie

	}


// Holiday Picker
if (cz_affiliate =="Hz" ||  
		cz_affiliate =="hz" ||
		cz_affiliate =="hu" || 
		cz_affiliate =="hg" || 
		cz_affiliate =="ht" || 
		cz_affiliate =="hd" ||
		cz_affiliate =="hcd" ||
		cz_affiliate =="hph")

		{
		cz_holiday="Halloween" 
		cz_holiday_date=cz_date_halloween;
		}

else if (cz_affiliate =="christmas")
		{
		cz_holiday= "Christmas" 
		cz_holiday_date=cz_date_christmas;
		}

else if (cz_affiliate =="easter")
		{
		cz_holiday= "Easter" 
		cz_holiday_date=cz_date_easter;
		}

else if (cz_affiliate =="stpatricks")
		{
		cz_holiday= "St. Patrick's Day" 
		cz_holiday_date=cz_date_stpatricks;
		}

else if (cz_affiliate =="valentines")
		{
		cz_holiday= "Valentine's Day" 
		cz_holiday_date=cz_date_valentines;
		}

else if (cz_affiliate =="thanksgiving")
		{
		cz_holiday= "Thanksgiving" 
		cz_holiday_date=cz_date_thanksgiving;
		}

else if (cz_affiliate =="fourthofjuly")
		{
		cz_holiday= "Independence Day" 
		cz_holiday_date=cz_date_fourthofjuly;
		}

else if (cz_affiliate =="mardigras")
		{
		cz_holiday= "Mardi Gras" 
		cz_holiday_date=cz_date_mardigras;
		}

else 
	{
	cz_holiday = cz_nearest_holiday
	cz_holiday_date = cz_date_nearest_holiday;
	}


// Mouseover Image Script
function init() {
  if (!document.getElementById) return
  var imgOriginSrc;
  var imgTemp = new Array();
  var imgarr = document.getElementsByTagName('img');
  for (var i = 0; i < imgarr.length; i++) {
    if (imgarr[i].getAttribute('hsrc')) {
        imgTemp[i] = new Image();
        imgTemp[i].src = imgarr[i].getAttribute('hsrc');
        imgarr[i].onmouseover = function() {
            imgOriginSrc = this.getAttribute('src');
            this.setAttribute('src',this.getAttribute('hsrc'))
        }
        imgarr[i].onmouseout = function() {
            this.setAttribute('src',imgOriginSrc)
        }
    }
  }
}
onload=init;

// Write Header
document.writeln(" <center> "); 
document.writeln(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"775\" bgcolor=\"white\"> "); 
document.writeln("  <tr> "); 
document.writeln("   <td rowspan=\"3\" valign=\"top\" width=95><a href=\"http://costumezone.com/default.asp?affiliate=" + cz_affiliate + "\" title=\"Home Page\"><img src=" + cz_baseurl + "/images/2011Header/"+ cz_affiliate + "-logo.gif \" width=\"95\" height=\"85\" border=\"0\"></a></td> "); 
document.writeln("   <td width=\"260\" height=55><a href=\"http://costumezone.com/default.asp?affiliate=" + cz_affiliate + "\" title=\"Home Page\"><img src=" + cz_baseurl + "/images/2011Header/"+ cz_affiliate + "-text.gif \" width=\"260\" height=\"55\" border=\"0\"></a></td> "); 
document.writeln("   <td width=\"240\" height=55>");

document.writeln(" 		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"240\"> "); 
document.writeln(" 			<tr> "); 
document.writeln(" 				<td colspan=\"3\"><img src=" +cz_baseurl + "/images/2011Header/spacer.gif \" border=\"0\" width=\"240\" height=\"25\"></td> "); 
document.writeln(" 			</tr> "); 
document.writeln(" 			<tr> "); 
document.writeln(" 				<td width=\"5\"></td> "); 
document.writeln(" 				<td> "); 

// Interrupt Header

// Countdown Clock
function cdtime(container, targetdate){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.currentTime=new Date()
this.targetdate=new Date(targetdate)
this.timesup=false
this.todayisholiday=false
this.updateTime()
}
cdtime.prototype.updateTime=function(){
var thisobj=this
this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}
cdtime.prototype.displaycountdown=function(baseunit, functionref){
this.baseunit=baseunit
this.formatresults=functionref
this.showresults()
}
cdtime.prototype.showresults=function(){
var thisobj=this
 
var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds

if (timediff<0){ //if time is up
this.timesup=true
this.container.innerHTML=this.formatresults()
return
}
var oneMinute=60 //minute unit in seconds
var oneHour=60*60 //hour unit in seconds
var oneDay=60*60*24 //day unit in seconds
var dayfield=Math.floor(timediff/oneDay)
var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
hourfield=dayfield*24+hourfield
dayfield="n/a"
}
else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
minutefield=dayfield*24*60+hourfield*60+minutefield
dayfield=hourfield="n/a"
}
else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
var secondfield=timediff
dayfield=hourfield=minutefield="n/a"
}
this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
}
function formatresults(){
if (this.timesup==false){ //if target date/time not yet met
var displaystring="<span class='lcdstyle'>Days Until "+cz_holiday+"<br>"+arguments[0]+" <sup>days</sup> "+arguments[1]+" <sup>hours</sup> "+arguments[2]+" <sup>mins</sup></span> "
}
else
	{ //else if target date/time met

	var displaystring="<span class='lcdstyle'>Happy "+cz_holiday+"</span> "
	//var displaystring="<span class='lcdstyle'>It is " //Don't display any text
}
return displaystring
}

document.write("<DIV id=countdowncontainer><\/DIV>");
var futuredate=new cdtime("countdowncontainer", cz_holiday_date)
futuredate.displaycountdown("days", formatresults)

//End Coundown Clock

// Continue Header
document.writeln(" 				<td><img src=\"https://costumezone.com/images/2011Header/spacer.gif\" border=\"0\" height=\"30\"></td> "); 

document.writeln(" 			</tr> "); 
document.writeln(" 		</table> "); 
document.writeln("</td> "); 
document.writeln("   <td height=55> "); 
document.writeln("     <a href=\"http://costumezone.com/viewcart.asp\" title=\"Shopping Cart\"><img src=" + cz_baseurl + "/images/2011Header/mycart-off.gif \" hsrc=" + cz_baseurl + "/images/2011Header/mycart-on.gif \" width=\"83\" height=\"16\" border=\"0\"></a> <a href=\"http://costumezone.com/status-order.asp\" title=\"My Account\"><img src=" + cz_baseurl + "/images/2011Header/myaccount-off.gif \" hsrc=" + cz_baseurl + "/images/2011Header/myaccount-on.gif \" width=\"83\" height=\"16\" border=\"0\"></a><img src=" + cz_baseurl + "/images/2011Header/spacer.gif \" border=\"0\" width=\"15\"><br> "); 
document.writeln("    <div class=\"addthis_toolbox addthis_default_style\" style=\"width:190px; height:32px; margin:0 auto\"> "); 
document.writeln("     <a href=\"http://costumezone.com/contact-info.asp\" title=\"CostumeZone.com Customer Care\"><img  src=" + cz_baseurl + "/images/2011Header/customercare-off.gif \" hsrc=" + cz_baseurl + "/images/2011Header/customercare-on.gif \" width=\"83\" height=\"16\" border=\"0\"></a> <a href=\"http://www.addthis.com/bookmark.php?v=250&amp;username=costumezone\" class=\"addthis_button\"><img alt=\"Bookmark and Share\" src=" + cz_baseurl + "/images/2011Header/share-off.gif \" width=\"83\" height=\"16\" border=0></a><img src=" + cz_baseurl + "/images/2011Header/spacer.gif \" border=\"0\" width=\"15\"><A class=addthis_button_facebook></A><A class=addthis_button_twitter></A><A class=addthis_button_googlebuzz></A><A class=addthis_button_myspace></A><A class=addthis_button_email></A><A class=addthis_button_print></A><A class=addthis_button_pdfmyurl></A><A class=addthis_button_favorites></A><A class=addthis_button_rss></A></DIV> "); 
document.writeln("   </td> "); 
document.writeln("  </tr> "); 
document.writeln("  <tr> "); 
document.writeln("   <td valign=\"top\" width=\"260\"> "); 
document.writeln("    <table border=\"0\" cellspacing=\"0\" width=\"260\"> "); 
document.writeln("     <tr height=\"23\"> "); 
document.writeln("      <td width=\"60\" height=\"23\" valign=\"top\"><a href=\"http://search.costumezone.com/gsearch.aspx\"><img title=\"CostumeZone.com Search\" border=\"0\" width=\"60\" src=" + cz_baseurl + "/images/2011Header/cz_gsearch_spacer.gif \"></a></td> "); 
document.writeln("      <td valign=\"top\" height=\"23\" width=2 valign=\"top\"> "); 
document.writeln("       <form id=\"frmSearch\" method=\"get\" name=\"frmSearch\" action=\"http://search.costumezone.com/gsearch.aspx\"> "); 
document.writeln("       </td> "); 
document.writeln("      <td width=\"200\" height=\"23\" valign=\"top\"> "); 
document.writeln(" <INPUT type=hidden value= " + cz_affiliate + " name=affiliate> ");
document.writeln("            <input style=\"WIDTH: 120px; HEIGHT: 18px; FONT-SIZE: 8pt\" class=\"inputtext\" value=\"whatdoyouwannabe?\" size=\"22\" name=\"searchfor\" type=\"text\" onfocus=\"if(this.value=='whatdoyouwannabe?') this.value='';\"> <input style=\"WIDTH: 55px; HEIGHT: 18px; FONT-SIZE: 7pt\" id=\"1\" class=\"inputtext\" value=\"Search!\" type=\"submit\" name=\"1\"></td> "); 
document.writeln("      </form> "); 
document.writeln("      </tr> "); 
document.writeln("    </table> "); 
document.writeln("   </td> "); 
document.writeln("   <td colspan=\"2\" valign=\"top\"> "); 


document.writeln("    <table width=\"430\" cellspacing=\"0\" border=\"0\"> "); 
document.writeln("     <tr height=\"23\"> "); 
document.writeln("      <td width=\"130\" height=\"23\" valign=\"top\"> <div><a href=\"http://costumezone.com/costumezone_new_costumes_new_halloween_costumes.asp\"><img border=\"0\" src=" + cz_baseurl + "/images/2011Header/2011header_new-off.gif \" width=\"130\" height=\"20\" hsrc="+cz_baseurl+"/images/2011Header/2011header_new-on.gif ></a></div></td> "); 
document.writeln("      <td width=\"130\" height=\"23\" valign=\"top\"> <div><a href=\"http://costumezone.com/clearance_discontinued_halloween_costumes.asp\"><img border=\"0\"  src=" + cz_baseurl + "/images/2011Header/2011header_clearance-off.gif \" width=\"130\" height=\"20\" hsrc=" + cz_baseurl + "/images/2011Header/2011header_clearance-on.gif ></a></div></td> "); 
document.writeln("      <td width=\"100\" height=\"23\" valign=\"top\"> <div><a href=\"http://costumezone.com/costumezone_ebay_store.asp\"><img border=\"0\" src=" + cz_baseurl + "/images/2011Header/2011header_ebay-off.gif \" width=\"100\" height=\"20\" hsrc=" + cz_baseurl + "/images/2011Header/2011header_ebay-on.gif ></a></div></td> "); 
document.writeln("      <td width=\"70\" height=\"23\" valign=\"top\"> ");

if ("https:" == document.location.protocol) 
	{     
	document.writeln(" <a href=\"http://costumezone.com/costumezone_share_facebook.asp\"><img src=" + cz_baseurl + "/images/2011Header/facebook_like_button-off.gif \" border=\"0\" width=\"57\" height=\"20\" ></a> "); 
	} 
else 
	{     
	document.writeln(" <div class=\"addthis_toolbox addthis_default_style \"> "); 
	document.writeln(" <a class=\"addthis_button_facebook_like\" fb:like:layout=\"button_count\"></a></div> "); 
	} 

document.writeln("      </td> "); 
document.writeln("     </tr> "); 
document.writeln("    </table> "); 
document.writeln("   </td> "); 
document.writeln("  </tr> "); 
document.writeln(" </table> ");
document.writeln(" </center> "); 

// Add This Javascript
	document.writeln("<script type='text/javascript' src='https://s7.addthis.com/js/250/addthis_widget.js#username=costumezone'></script>");
	var addthis_config = {"data_track_clickback":true};

// Main PopUp Menu
	var cz_menulocation
	cz_menulocation=cz_baseurl;
	cz_menulocation=cz_menulocation+"/images/2011Header/popup_top/lp5.js";
	document.writeln("<SCRIPT language=JavaScript1.2  src=" + cz_menulocation + " ></script>")
