
//-------------------------------------------------------------------
function setAVPCookie(name, value, domain) {
	//alert("name : " + name + " : value : " + value + " : domain : " + domain);
	cur_time= new Date();
	exp = cur_time.getTime() + (3600 * 1000 * 24); // live for a day
	cur_time.setTime(exp);
	document.cookie= name + "=" + escape(value) + "; expires=" + cur_time.toGMTString() + "; path=/;" + ((domain) ? "; domain=" + domain : "");
}
//-------------------------------------------------------------------
function expireAVPCookie(name) {
	// cookie for interstitial
	cur_time= new Date();
	exp = cur_time.getTime() - (3600 * 1000 * 48); // expire
	cur_time.setTime(exp);
	document.cookie= name + "=0;";
	//expires=" + cur_time.toGMTString();
	//alert("expiring : " + name + " : " + cur_time.toGMTString());
}
//-------------------------------------------------------------------
function AVPshowBanner(layer_name) {
	document.getElementById(layer_name).style.visibility = "visible";
}
//-------------------------------------------------------------------
function AVPShowHideLayer(layer_name, visibility) {
	//alert(layer_name + " : " + visibility);
	if(document.getElementById(layer_name)){
		if (visibility == 0) {
			if (document.getElementById(layer_name).style.visibility == "visible") {
				document.getElementById(layer_name).style.visibility = "hidden";
			}
		} else {
			if (document.getElementById(layer_name).style.visibility == "hidden") {
				document.getElementById(layer_name).style.visibility = "visible";
			}
		}
	}
}
//-------------------------------------------------------------------
function reloadBannerFrames(channel_keywords) {
	parent.sm_companion.location="sm_companion_frame.php?keyword=" + channel_keywords;
	parent.lg_companion.location="lg_companion_frame.php?keyword=" + channel_keywords;
}
//--------------------------------------------------------------------
function getVideo() {
	// set interstitial cookie
	// ** cookie_domain var available from embedding page
	setAVPCookie("ITSTT", "1", cookie_domain);
	window.location = 'player_frame.php';
}
//--------------------------------------------------------------------
function noInterstitial(cookie_domain) {
	//alert("noInterstitial : " + cookie_domain);
	setAVPCookie("CID", "0:0", cookie_domain);
	setAVPCookie("ITSTT", -1, cookie_domain);
	window.location = 'player_frame.php';
}
//--------------------------------------------------------------------
function loadAVPreference() {
	var prefUrl = "player_frame.php?pref=1";

	if (window.player_frame) {
		window.player_frame.location.href = prefUrl;
	} else {
		location.href = prefUrl;
	}
}
//--------------------------------------------------------------------
function popSignup(url, width, height) {
	win_attr = "width=" + width + ",height=" + height + ",resizable=no,scrollbars=no";
	//alert(url + " : " + width + " : " + height + " : " + win_attr);
	//reg_win = window.open(url, "signup_win", win_attr);
	reg_win = window.open(url);
	reg_win.focus();
}
//--------------------------------------------------------------------
function tryStopAVP() {
	if (player_frame.document.getElementById("idj_player")) {
		player_frame.stopAVP();
	}
}







//-------------------------------------------------------------------------
// DATE SELECT LIST NEEDS TO RELOAD NUM OF DAYS ACCORDING TO MONTH AND YEAR
//-------------------------------------------------------------------------
function UT_reload_days(which_month_droplist, which_day_droplist, which_year_droplist) {

 cur_day_selected=which_day_droplist.selectedIndex;
 num_days=UT_getDaysInMonth(which_year_droplist.options[which_year_droplist.selectedIndex].value, which_month_droplist.options[which_month_droplist.selectedIndex].value-1);
 //alert("num_days : " + num_days)
 UT_relist_day(which_day_droplist, num_days);
 if(cur_day_selected > num_days - 1) {
  which_day_droplist.selectedIndex=num_days;
 } else {
  which_day_droplist.selectedIndex=cur_day_selected;
 }
}
//-------------------------------------------------------------------------
// REBUILDS DAYS AVAILABLE (called by UT_reload_days())
//-------------------------------------------------------------------------
function UT_relist_day(which_day_droplist, num_days) {
 which_day_droplist.options.length=0
 which_day_droplist[0] = new Option("Day", "");
 for(i=1;i<num_days + 1;i++) {
  which_day_droplist[i] = new Option(i,i);
 }
}

//-------------------------------------------------------------------------
// RETURNS NUMBER OF DAYS ON YEAR AND MONTH (INCLUDES LEAP YEAR) : called by UT_reload_days()
//-------------------------------------------------------------------------
function UT_getDaysInMonth( aYear, aMonth ) {
 //alert(aMonth + " : Year - > " + aYear)
    vMonthLookup = new Array(31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    if (aMonth != 1) {
        // -- Month isn't February so just look up the day total.
        return vMonthLookup[aMonth];
    }
    // -- Month is February so determine if it is a leap year.
    if (aYear%4 == 0) {
        if ((aYear%400 != 0) && (aYear%100 == 0)) {
            return 28;
        }
        return 29;
    } else {
  return 28;
 }
}


function redirect(post_play_page){
	if(post_play_page != undefined && post_play_page != ""){
		window.location = post_play_page;
	}
}
