function launchSubscription() {
	window.open("/subscribe", "subscriptionProcess", "resizable=1,scrollbars=1,menubar=1,toolbar=1,width=800,height=600");
//	window.open("https://mytv.primetime2go.com/mytvbil/termsConditions.page", "subscriptionProcess", "resizable=1,scrollbars=1,menubar=1,toolbar=1,width=800,height=600");
}

// URLDecodes, just like PHP
// found at http://phpjs.org/functions/urldecode:572
function urldecode (str) {
    
    var hash_map = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
    
    var replacer = function (search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The hash_map is identical to the one in urlencode.
    hash_map["'"]   = '%27';
    hash_map['(']   = '%28';
    hash_map[')']   = '%29';
    hash_map['*']   = '%2A';
    hash_map['~']   = '%7E';
    hash_map['!']   = '%21';
    hash_map['%20'] = '+';
    hash_map['\u00DC'] = '%DC';
    hash_map['\u00FC'] = '%FC';
    hash_map['\u00C4'] = '%D4';
    hash_map['\u00E4'] = '%E4';
    hash_map['\u00D6'] = '%D6';
    hash_map['\u00F6'] = '%F6';
    hash_map['\u00DF'] = '%DF';
    hash_map['\u20AC'] = '%80';
    hash_map['\u0081'] = '%81';
    hash_map['\u201A'] = '%82';
    hash_map['\u0192'] = '%83';
    hash_map['\u201E'] = '%84';
    hash_map['\u2026'] = '%85';
    hash_map['\u2020'] = '%86';
    hash_map['\u2021'] = '%87';
    hash_map['\u02C6'] = '%88';
    hash_map['\u2030'] = '%89';
    hash_map['\u0160'] = '%8A';
    hash_map['\u2039'] = '%8B';
    hash_map['\u0152'] = '%8C';
    hash_map['\u008D'] = '%8D';
    hash_map['\u017D'] = '%8E';
    hash_map['\u008F'] = '%8F';
    hash_map['\u0090'] = '%90';
    hash_map['\u2018'] = '%91';
    hash_map['\u2019'] = '%92';
    hash_map['\u201C'] = '%93';
    hash_map['\u201D'] = '%94';
    hash_map['\u2022'] = '%95';
    hash_map['\u2013'] = '%96';
    hash_map['\u2014'] = '%97';
    hash_map['\u02DC'] = '%98';
    hash_map['\u2122'] = '%99';
    hash_map['\u0161'] = '%9A';
    hash_map['\u203A'] = '%9B';
    hash_map['\u0153'] = '%9C';
    hash_map['\u009D'] = '%9D';
    hash_map['\u017E'] = '%9E';
    hash_map['\u0178'] = '%9F';
    hash_map['\u00C6'] = '%C3%86';
    hash_map['\u00D8'] = '%C3%98';
    hash_map['\u00C5'] = '%C3%85';
 
    for (unicodeStr in hash_map) {
        hexEscStr = hash_map[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}

// Read the contents of a cookie
function readCookie(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 urldecode(c.substring(nameEQ.length,c.length));
	}
	return null;
}


// This function is called when the PrimeTime2Go Subscription Signup page is loaded.
// It is what we use to control marketing copy on that page.
function subscription_form_setup(device, carrier, manufacturer) {
   setup_PIN_help(manufacturer);
   setup_page_text();
}


function setup_PIN_help(manufacturer) {
   var helpText = "";
   if (manufacturer == "RIM"){
      helpText = "<img src=\"http://www.primetime2go.com/images/devices/blackberry_pin_help.png\" />";
   }else if (manufacturer == "Motorola"){
      helpText = "<img src=\"http://www.primetime2go.com/images/devices/android_pin_help.png\" />";
   }else{
      helpText = "";
   }
   $("#PINHELP").html(helpText);
}

function setup_page_text() {
   $("#aboveform").html("PrimeTime2Go is available for a recurring price of <strong>$9.99 USD per month</strong>.<br/><br/>");
   $("#belowform").html("<br/>You must have a MicroSD card to store shows (512MB or higher is recommended).<br/><br/>You must have access to a WiFi connection to download shows. Once shows are downloaded a Wifi connection is not required.<br/><br/>Please ensure you have read and understand our <a target='_new' href=\'http://www.primetime2go.com/support-refunds\'>Refund Policy</a>");
}

