// JavaScript Document
var names = [];
var numbers = [];
var url = [];

names[0] = ["Rogers",
"Bell TV",                      
"Persona Communications",
"Cogeco",
"Amtelecom",                     
"Bluewater Cable",                    
"Cable Cable",                          
"Compton Communications",      
"Markdale Cable",                     
"Mountain Cablevision",             
"Shaw",
"Shaw Direct",
"Source Cable",                         
"Look TV",
"Astrocom",
"Brooke Telecom",
"Bruce Telecom",
"Execulink",
"Hay Communications",
"Huron Telecommunications",
"Kincardine Cable TV",
"Maitland Cable TV",
"Mitchell Seaforth",
"Mornington Communications",
"Nexicom",
"Nor-Del Cablevision",
"Quadro Communications",
"Radio-TV Dubreuilville",
"Tuckersmith Communications",
"VIC Communications",
"WTC Communications (North Leeds Cablecom)"
];

url[0] = ["http://www.gettmn.ca/",
"http://www.bell.ca/support/PrsCSrvTv_Express_Login.page?DirectAccess=programmingChange",
"http://www.persona.ca",
"http://www.cogeco.ca/en/premium_movie_channels_o.html", 
"http://www.amtelecom.ca/", 
"http://www.cabletv.on.ca/cable_digital_price.php",
"http://www.cablecable.net/television_ordernow.html", 
"http://www.compton.net/digitaltv/digitalpricing.html", 
"http://www.markdalecabletv.com/pages.php?section=cabletv.info",
"http://www.mountaincable.net/index.php?id=45,144,0,0,1,0", 
"http://www.shaw.ca", 
"http://www.shawdirect.ca",
"http://www.sourcecable.ca/page.php?PageID=38",
"http://www.look.ca/",
"http://www.astrocom-on.com",
"http://www.brooketel.ca/DigitalTelevision.html",
"http://www.brucetelecom.com",
"http://www.execulink.ca/residential/television/additional_channels.php",
"http://www.hay.net",
"http://www.hurontel.on.ca/",
"http://www.tnt21.com/index.php?option=com_content&task=view&id=15&Itemid=28",
"http://www.wcl.on.ca/maitland_tv.htm",
"http://www.ezlink.ca/",
"http://www.mornington.ca/",
"http://www.nexicom.net",
"http://www.nor-del.com/Nor-Del%20Digital%20Tv%20-%20TMN%20Movies.html",
"http://www.quadro.net/",
"",
"http://www.tcc.on.ca",
"http://www.vicip.ca/",
"http://www.wtccommunications.ca"
];

numbers[0] = ["1-888-ROGERS-1",
"1888 SKY DISH",
"1-866-PERSONA",
"1-866-427-7451",
"1-800-440-7472",
"1-800-331-7417",
"866-887-6434",
"905-985-8171",
"519-986-2262",
"1-800-616-0752",
"1-866-690-7429",
"1-866-782-7932",
"905-574-6464",
"1-800-356-5665",
"807-854-1569",
"519-844-2160",
"1-866-517-2000",
"1-877-EXECULINK",
"1-888-831-4333",
"1-877-395-3800",
"1-800-265-3064",
"1-888-477-2177",
"519-345-2341",
"1-800-250-8750",
"1-888-639-4266",
"519-879-6527",
"519-229-8933",
"705-884-2693",
"1-888-263-8225",
"1-866-600-3111",
"1-866-547-6939"
];

names[1] = ["Videotron",
"Bell TV",                      
"Cogeco", 
"VDN Cable",               
"Shaw Direct",                           
"Look TV",
"Cable Axion Digitel",
"Cablevision HSL SDM",
"Cablovision Warwick",
"CCAP",
"Co-operative Ste-Catherine Fossambault",
"Cablevision du Nord du Quebec",
"Dery Telecom",
"Ginwat Cable TV",
"Nunavik Communications",
"Shannon Vision",
"Transvision Cookshire",
"ValCartier Cable"
];

url[1] = ["https://www.videotron.com/services/secur/Abonnement.do?lang=ENGLISH",
"http://www.bell.ca/support/PrsCSrvTv_Express_Login.page?DirectAccess=programmingChange",
"http://www.cogeco.ca/en/premium_movie_channels_q.html", 
"http://www.vdn.ca", 
"http://www.shawdirect.ca",
"http://www.look.ca/",
"http://eclatezvousavecaxion.com",
"http://www.totalsat.qc.ca/trp/abonnement.html",
"http://www.cablovision.com/main.cfm?p=200&l=fr",
"http://www.ccapcable.com",
"http://www.coopcscf.com/canaux.htm",
"http://www.cablevision.qc.ca",
"http://www.derytele.com/television/index_num.php",
"",
"",
"http://www.cableshannon.com",
"",
""
];

numbers[1] = ["1-877-380-2511",
"1888 SKY DISH",
"1-866-384-4837",
"514-522-1590",
"1-866-782-7932",
"1-800-356-5665",
"1-866-55AXION",
"1-800-465-9215",
"819-358-5858",
"418-849-7125",
"418-875-1118",
"1-800-567-6353",
"866-544-3358",
"819-855-2191",
"819-964-2305",
"418-844-3849",
"1-877-946-7376",
"418-844-3666"
];

names[2] = ["Rogers",
"Bell TV",                      
"Aliant",
"Shaw Direct",                           
"EastLink"
];

url[2] = ["http://www.gettmn.ca/",
"http://www.bell.ca/support/PrsCSrvTv_Express_Login.page?DirectAccess=programmingChange",
"http://www.aliant.net",
"http://www.shawdirect.ca/",
"http://www.eastlink.ca/about/contact/index.asp"
];

numbers[2] = [" 1-888-ROGERS-1",
"1888 SKY DISH",
"1-866-246-9283",
"1-866-782-7932",
"1-888-345-1111"
];

names[3] = ["Bell TV",
"Eastlink",
"Shaw Direct",                           
"Aliant",                      
"Cross Country Cable TV",
"Seaside Communications"
];

url[3] = ["http://www.bell.ca/support/PrsCSrvTv_Express_Login.page?DirectAccess=programmingChange",
"http://www.eastlink.ca/about/contact/index.asp",
"http://www.shawdirect.ca/",
"http://www.aliant.net",
"http://www.xcountry.tv/cable_digital.html",
"http://www.seaside.ns.ca/dc_home.html"
];

numbers[3] = ["1888 SKY DISH",
"1-888-345-1111",
"1-866-782-7932",
"1-866-246-9283",
"902-678-2395",
"902-539-6250"
];

names[4] = ["Rogers",
"Bell TV",                      
"Aliant",
"Eastlink",
"Shaw Direct",                           
"Burgeo Broadcasting",
"CRRS TV"
];

url[4] = ["http://www.gettmn.ca/",
"http://www.bell.ca/support/PrsCSrvTv_Express_Login.page?DirectAccess=programmingChange",
"http://www.aliant.net",
"http://www.eastlink.ca/about/contact/index.asp",
"http://www.shawdirect.ca/",
"http://www.bbsict.ca/bbs/contact.html",
"www.crrstv.net"
];

numbers[4] = ["1-888-ROGERS-1",
"1888 SKY DISH",
"1-866-425-4268",	  
"1-888-345-1111",
"1-866-782-7932",
"709-886-2935",
"709-944-7676"
];

names[5] = ["Bell TV",                      
"Eastlink",
"Shaw Direct"                           
];

url[5] = ["http://www.bell.ca/support/PrsCSrvTv_Express_Login.page?DirectAccess=programmingChange",
"http://www.eastlink.ca/about/contact/index.asp",
"http://www.shawdirect.ca/"
];

numbers[5] = ["1888 SKY DISH",
"1-888-345-1111",
"1-866-782-7932"
];

names[6] = ["Bell TV",     
"Shaw Direct",
"Telus",      
"MTS",  
"SaskTel", 
"Access Communications", 
"Delta Cable Communications Ltd.",   
"Westman Communications Group", 
"Cable TV of Camrose",
"Campbell River TV Association",
"Image Wireless Communications Inc",
"Mascon Communications Corp",
"Northern Television Systems",
"Persona Communications Inc",
"Revelstoke Cable TV Ltd",
"Sun Country Cablevision Ltd"
];

url[6]=["http://www.bell.ca/support/PrsCSrvTv_Express_Login.page?DirectAccess=programmingChange",
"https://secure.starchoice.com/english/customercare/selfserve/login.asp?nextpage=/english/customercare/selfserve/mainmenu.asp&error=coinvalid",
"http://www.mytelus.com/tv/overview/howto_order.vm",
"http://www.mts.mb.ca/mtstv/",
"http://www.sasktel.com/",
"http://www.accesscomm.ca/",
"http://www.deltacable.com/",
"http://www.westmancom.com/",
"http://www.cable-lynx.net/",
"http://www.crtv.net/",
"http://www.imagecable.com/",
"http://www.mascon.bc.ca/",
"http://www.whtvcable.com/",
"http://www.personainc.ca/",
"http://www.rctvonline.net/",
"http://www.sunwave.net/"
];

numbers[6] = ["1-888-SKY-DISH",
"1-888-STAR 419",
"310-MYTV",
"204-941-4545",
"1-800-SASKTEL",
"1-866-363-2225",
"1-604-946-7676",
"1-800-665-3337",
"780-672-8839",
"250-923-8899",
"1-888-462-4388",
"250-832-6000",
"867-393-2225",
"1-866-737-7662",
"250-837-5246",
"250-832-9711"
];

	// load the province providers
	ontario = getProviders('ON');//[names[0],numbers[0],url[0]];
	quebec =  getProviders('QC');//[names[1],numbers[1],url[1]];
	nb = getProviders('NB');//[names[2],numbers[2],url[2]];
	ns = getProviders('NS');//[names[3],numbers[3],url[3]];
	nf = getProviders('NL');//[names[4],numbers[4],url[4]];
	pei = getProviders('PE');//[names[5],numbers[5],url[5]];
	//western = [names[6],numbers[6],url[6]];

	providers = [ontario,quebec,nb,ns,nf,pei];//,western];
	currentProv = 0;
	
	function getProviders(province) {
		var affiliate = new Array();
		
		$.ajax({
			url: "/scripts/getAffiliates.php?prov="+province,
			async: false,
			dataType: 'json',
			success: function(data){
				affiliate[0] = data.name;
				affiliate[1] = data.phone;
				affiliate[2] = data.url;
			}
		});
		
		return affiliate;
	}
	
	function buildProviders(province) {

		if(province == '') document.getElementById('provider').disabled = true;
		
		list = "";
		//document.service.providersList.options.length = 0;
		document.getElementById('provider').innerHTML = '';
		myEle = document.createElement("option") ;
		var txt = document.createTextNode("-Choose Provider-");
		myEle.appendChild(txt);
		document.getElementById('provider').appendChild(myEle);
			
		if (province >= 0) {
			for (i=0;i<providers[province][0].length;i++) {
				myEle = document.createElement("option") ;
				myEle.setAttribute("value",i);
				var txt = document.createTextNode(providers[province][0][i]);
				myEle.appendChild(txt);
				document.getElementById('provider').appendChild(myEle);
			}
			currentProv = province;
			document.getElementById('provider').disabled = false;
		}
		$("phone").innerHTML = "";
	}
	
	function getPhoneNo(provider) {
		//providers[currentProv][0][provider]
		if (provider > -1) {
		  $("phone").innerHTML = "<u><a target='_blank' href='"+providers[currentProv][2][provider]+"'>Visit Website</a></u><br>"+providers[currentProv][1][provider];
		} else {
			$("phone").innerHTML = "";
		}
	}