window.onunload = metrics_end;

// Metrics tracking for pathing, dwell time and drop off
//failing in IE, we need to pause execution before end
function metrics_end() {
	if(document.images['metrics']) {
		var endMetrics = new Image();
		endMetrics.src = document.images['metrics'].src.replace(/(page_id=)([^&]*)/, '$1$2&action=end');  ;
	}
	metrics_end_delay(endMetrics);
}
function metrics_end_delay(endMetrics) {
	return endMetrics.src;
}
// Rules Pop-Up
function rules() {
	window.open("index.tbapp?page=rules","rules","menu=no,toolbar=no,width=450,height=400,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

// Instant Win Rules Pop-Up
function rules_iw(siteurl) {
	    window.open(siteurl + "index.tbapp?page=rules","rules","menu=no,toolbar=no,width=450,height=400,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

// FAQ Pop-Up
function faq(email) {
  self.name = "Parent_Window";
  
  var faq_window = "scrollbars,resizable,width=450,height=400,left=100,top=100";
  OpenWindow = window.open("index.tbapp?page=contact_form&email="+email+"&lid=general/faq_pop", "faq", faq_window);
}

// Contact Us Pop-Up
function contactus(email) {
  window.open("index.tbapp?page=contact_form&nav=form&email="+email+"&lid=top+nav_how+it+works_FAQ","faq","menu=no,toolbar=no,width=450,height=400,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=48,left=48");
}

//Forgot password
function forgot() {
  window.opener.location="https://register.go.com/bvhe/disneymovierewards/sendPassword";
  window.close(); 
}	

// Image Security Information Pop-Up
function img_security() {
	window.open("index.tbapp?page=img_security_info","imgsec","menu=no,toolbar=no,width=450,height=340,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=132,left=196");
}

function img_security_theatrical() {
	window.open("index.tbapp?page=img_security_theatrical","imgsec","menu=no,toolbar=no,width=450,height=230,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=132,left=196");
}

function img_security_codes() {
	window.open("index.tbapp?page=img_security_codes","imgsec","menu=no,toolbar=no,width=450,height=290,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=132,left=196");
}

function changeImage(source,graphic) {
	    source.src = "images/global/"+graphic;
}

// Generic Pop-Up
// ex: <a href="javascript:openThis('http://www.eprize.com');">Click here</a>
function openThis(URL) {
  window.open(URL);
}

// Cancel Order
function cancelOrder() {
	    document.cancel_order_form.submit();
}

// Why do we ask for this information pop-up
function whyWeAsk() {
	    window.open("index.tbapp?page=_why_we_ask","popup","menu=no,toolbar=no,width=400,height=250,scrollbars=1,resizable=yes,directories=no,location=no,screenX=0,screenY=0,top=0,left=0");
}

function shipShow(objTarget) {

	if (document.all) {
	    targetBlock1 = document.all("profileAddress");
	    targetBlock2 = document.all("differentAddress");
	    targetCheckbox = document.all("update_address");
	} else {
	    targetBlock1 = document.getElementById("profileAddress");
	    targetBlock2 = document.getElementById("differentAddress");
	    targetCheckbox = document.getElementById("update_address");
	}

	if (objTarget.id == "differentRadio" && objTarget.checked) {
        targetBlock1.style.display = "none";
        targetBlock2.style.display = "block";
						    }

	if (objTarget.id == "profileRadio" && objTarget.checked) {
        targetBlock2.style.display = "none";
        targetBlock1.style.display = "block";
        targetCheckbox.checked = false;
    }

}

if (document.images)
	{
		// back btn
		backBtnon = new Image(96,19);
		backBtnon.src="images/global/btn_back_home_on.gif";
		backBtnoff = new Image(96,19);
		backBtnoff.src="images/global/btn_back_home.gif";
		
		// main navs
		pic1on= new Image(140,25);
		pic1on.src="images/global/btn_earn_points_on.gif";  
		pic2on= new Image(120,25);
		pic2on.src="images/global/btn_my_account_on.gif";
		pic3on= new Image(142,25);
		pic3on.src="images/global/btn_member_benefits_old_on.gif"; 
		pic4on= new Image(152,25);
		pic4on.src="images/global/btn_eligible_movies_on.gif"; 
		pic5on= new Image(150,25);
		pic5on.src="images/global/btn_view_rewards_on.gif"; 
		pic6on= new Image(120,25);
		pic6on.src="images/global/btn_join_now_on.gif";
		
		pic1off= new Image(140,25);
		pic1off.src="images/global/btn_earn_points.gif";
		pic2off= new Image(120,25);
		pic2off.src="images/global/btn_my_account.gif";
		pic3off= new Image(142,25);
		pic3off.src="images/global/btn_member_benefits_old.gif"; 
		pic4off= new Image(152,25);
		pic4off.src="images/global/btn_eligible_movies.gif"; 
		pic5off= new Image(150,25);
		pic5off.src="images/global/btn_view_rewards.gif"; 
		pic6off= new Image(120,25);
		pic6off.src="images/global/btn_join_now.gif";
		
		// seat navs
		seat1on = new Image();
		seat1on.src = "images/global/btn_feature_promo2_on.gif";
		seat2on = new Image();
		seat2on.src = "images/global/btn_member_benefits2_on.gif";
		seat3on = new Image();
		seat3on.src = "images/global/btn_earn_bonus_points2_on.gif";
		seat4on = new Image();
		seat4on.src = "images/global/btn_refer_a_friend2_on.gif";
		seat5on = new Image();
		seat5on.src = "images/global/btn_faq_on.gif";
		seat6off = new Image();
		seat6off.src = "images/global/btn_contactus_on.gif";
		
		seat1off = new Image();
		seat1off.src = "images/global/btn_feature_promo2.gif";
		seat2off = new Image();
		seat2off.src = "images/global/btn_member_benefits2.gif";
		seat3off = new Image();
		seat3off.src = "images/global/btn_earn_bonus_points2.gif";
		seat4off = new Image();
		seat4off.src = "images/global/btn_refer_a_friend2.gif";
		seat5off = new Image();
		seat5off.src = "images/global/btn_faq.gif";
		seat6off = new Image();
		seat6off.src = "images/global/btn_contactus.gif";
	}
	
	// handle btn over state
	function lightup(imgName)
	{
		if (document.images)
		{
			imgOn=eval(imgName + "on.src");
			document[imgName].src= imgOn;
		}
	}
	
	// handle btn out state
	function turnoff(imgName)
	{
		if (document.images)
		{
			imgOff=eval(imgName + "off.src");
			document[imgName].src= imgOff;
		}
	}
	
function dosubmit() {
    if (document.all) {
        buttonID = document.all["orderbutton"];
        button2ID = document.all["processbutton"];
    } else {
        buttonID = document.getElementById("orderbutton");
        button2ID = document.getElementById("processbutton");
    }
    buttonID.style.display = "none";
    button2ID.style.display = "block";
}

function delayCloseDiv(dropDownName) {
	setTimeout("closeDiv('" + dropDownName + "')",100);
}

function closeDiv(dropDownName) {
	var divName = dropDownName + '_div';
	var dropDownDiv = document.getElementById(divName);
	dropDownDiv.style.visibility = "hidden";
}

function openDiv(dropDownName) {
	var divName = dropDownName + '_div';
	var dropDownDiv = document.getElementById(divName);
	dropDownDiv.style.visibility = "visible";
	dropDownDiv.focus();
}

function operateDropDown(dropDownName) {
	var divName = dropDownName + '_div';
	var dropDownDiv = document.getElementById(divName);
	if (dropDownDiv.style.visibility != "visible") {
		openDiv(dropDownName);
	} else {
		closeDiv(dropDownName);
	}
}

function populateFormValue(elementName, formValue, displayValue) {
	var hiddenField = document.getElementById(elementName);
	var textDiv = document.getElementById(elementName + "_text");
	hiddenField.value = formValue;
	textDiv.innerHTML = displayValue;
	closeDiv(elementName);
}

function icon() {
	window.open("index.tbapp?page=buddy_icon_popup","icon","menu=no,toolbar=no,width=370,height=500,scrollbars=0,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function openWindow(url, winName, width, height) {
	leftVal = (screen.width - width) / 2;
	topVal = (screen.height - height) / 2;

	newWindow = window.open(url, winName, 'width=' + width + ',height=' + height + ',left='+leftVal+',top='+topVal);
}

function openWindow2(link) {
  window.open(link, '_blank', 'width=800,height=600,toolbar=yes,status=yes,location=yes,menubar=yes,directories=yes,resizable=yes,scrollbars=yes');
}

function wallpaper(url, winName){
	window.open(url,winName,"menu=no,toolbar=no,width=800,height=600,scrollbars=1,resizable=1,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function cinderella3() {
	openWindow('http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e31520&bitrateid=16&vendorid=3&affiliateId=-1','low','200','150');
};

function cinderella4() {
	openWindow('http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e31520&bitrateid=17&vendorid=3&affiliateId=-1','high','320','240');
};		




function cliplow(vid_id) {
	openWindow('./index.tbapp?page=video_popup&vid_res=low&vid_id=' + vid_id + '','low','530','400');
};

function cliphigh(vid_id) {
	openWindow('./index.tbapp?page=video_popup&vid_res=high&vid_id=' + vid_id + '','high','800','500');
};	





function clip_interview() {
	openWindow('?page=interview_popup','high','700','600');
};

function interview(url, winName){
	window.open(url,winName,"menu=no,toolbar=no,width=800,height=600,scrollbars=1,resizable=1,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}



// Rules Pop-Up
function special_offer() {
	window.open("index.tbapp?page=special_offer_popup","special_offer_popup","menu=no,toolbar=no,width=508,height=291,scrollbars=0,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

// Rules Pop-Up
function special_offer2() {
	window.open("http://transfer.go.com/cgi/transfer.dll?name=327544&SOURCE=327544&srvc=store&goto=http%3A%2F%2Fhome.disney.go.com%2Fshopping%2F&CMP=OTL-TWDC&att=dsnymvrwrdsHP","_blank","width=1040,height=600,toolbar=yes,status=yes,location=yes,menubar=yes,directories=yes,resizable=yes,scrollbars=yes");
}

//css transparent png hack for IE6

function transparent(id, source) {

  // is the browser competent with the DOM?

  if(document.getElementById) 
  {

    // is the browser capable of managing runtimeStyle?

    // (this would mean, basically, "hey, I'm IE")    
	if(document.getElementById(id).runtimeStyle) {      
	// delete current background

      document.getElementById(id).style.backgroundImage = 'none';

      // apply PNG background with alpha transparency filtering

      document.getElementById(id).style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + source + "',sizingMethod='scale')";

    }  
	}

}


function rules_walledvd() {
	    window.open("index.tbapp?page=rules_walledvd","rules_walledvd","menu=no,toolbar=no,width=450,height=400,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function freeEntry_walledvd() {
	    window.open("index.tbapp?page=rules_walledvd#free_entry","rules_walledvd","menu=no,toolbar=no,width=450,height=400,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}


// High School Musical Sweeps Rules Pop-Up
function rules_hsm() {
	    window.open("index.tbapp?page=rules_hsm","rules_hsm","menu=no,toolbar=no,width=450,height=400,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function rules_dalm() {
	    window.open("index.tbapp?page=rules_dalm","rules_hsm","menu=no,toolbar=no,width=450,height=400,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function mcr_popup() {
		window.open("index.tbapp?page=mcr_popup","mcr_popup",
"menu=no,toolbar=no,width=548,height=331,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function doi_popup() {
		window.open("index.tbapp?page=doi_popup","doi_popup",
"menu=no,toolbar=no,width=548,height=331,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function gift_popup() {
		window.open("index.tbapp?page=gift_popup","gift_popup",
"menu=no,toolbar=no,width=548,height=331,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function ddge_popup() {
		window.open("http://disneydvdgiftexpress.go.com/welcome.html?sc=301064&lid=click","ddge_popup",
"menu=no,toolbar=no,width=970,height=600,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=108,left=144");
}

function shopping_popup() {
		window.open("index.tbapp?page=shopping_popup","shopping_popup",
"menu=no,toolbar=no,width=548,height=331,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function ff_popup() {
		window.open("index.tbapp?page=ff_popup","ff_popup",
"menu=no,toolbar=no,width=1044,height=788,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

//HIT BOX LINK
function hb_popup(url) {
		window.open(url);
}

function jbook_screentest() {
	window.open("index.tbapp?page=jbook_screentest","jbook_screentest", "menu=no,toolbar=no,width=820,height=620,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function screentest_disney_summer_widget() {
	window.open("index.tbapp?page=screentest_disney_summer_widget","screentest_disney_summer_widget", "menu=no,toolbar=no,width=620,height=820,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function screentest_olympic_widget() {
	window.open("index.tbapp?page=screentest_olympic_widget","screentest_olympic_widget", "menu=no,toolbar=no,width=640,height=840,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function screentest_dog() {
	window.open("index.tbapp?page=screentest_dog","screentest_dog", "menu=no,toolbar=no,width=820,height=630,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function screentest_halloween08() {
	window.open("index.tbapp?page=screentest_halloween08","screentest_halloween08", "menu=no,toolbar=no,width=820,height=630,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}

function screentest_channel_rock() {
	window.open("index.tbapp?page=screentest_channel_rock","screentest_channel_rock8", "menu=no,toolbar=no,width=840,height=640,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=88,left=124");
}
