//GLOBAL VARIABLES



var cards = new Array();



var apply_link = 'https://' + document.domain + '/cgi-bin/cards/cardapp/apply.cgi';



var apply_business_link = 'https://' + document.domain + '/cgi-bin/cards/busapp/apply.cgi';



var apply_creditline_link = 'https://' + document.domain + '/cgi-bin/cards/clsb/apply.cgi';



var compare_tool_link = 'http://' + document.domain + '/cards/tools/compare/index.html';



var select_tool_link = 'http://' + document.domain + '/cards/tools/select/index.html';







// Card object constructor



//Fields correspond to excel card data file



function Card(id, name, ranking, interest_rate, grace_period, annual_fee, annual_fee_65, add_card_fee, min_income, type_rewards, type_student, type_lowrate, type_nofee, type_business, feature_merchandise, feature_travel, feature_specialty, feature_usdollar, feature_insurance, benefit, feature1, feature2, special_offer, learn_more) {



	this.id=id;



	this.name=name;



	this.ranking=ranking;



	this.interest_rate=interest_rate;



	this.grace_period=grace_period;



	this.annual_fee=annual_fee;



	this.annual_fee_65=annual_fee_65;



	this.add_card_fee=add_card_fee;



	this.min_income=min_income;



	this.benefit=benefit;



	this.feature1=feature1;



	this.feature2=feature2;



	this.special_offer=special_offer;	



	this.feature_merchandise=feature_merchandise;



	this.feature_travel=feature_travel;



	this.feature_specialty=feature_specialty;



	this.feature_usdollar=feature_usdollar;



	this.feature_insurance=feature_insurance;



	this.learn_more=learn_more;



	this.type_rewards=type_rewards;



	this.type_student=type_student;



	this.type_lowrate=type_lowrate;



	this.type_nofee=type_nofee;



	this.type_business=type_business;



}







//Main function -- initialise cards, check query params, display cards



function initializeCards() {



	//Initialise cards



	cards.push(new Card("avion_inf", "Visa Infinite Avion", "1", "19.50%", "17", "$120", "", "$50", "$60,000", "Y", "N", "N", "N", "N", "Y", "Y", "N", "N", "Y", "Premium travel rewards & benefits", "No blackout periods or seat restrictions", "Earn 1 RBC Rewards point for each $1 spent", "15,000 welcome points upon enrollment<sup><a href='/cards/_assets-custom/includes/pop-up/terms-and-condition/avion_inf.html' title='Disclaimer (opens new window)' target='_blank' onclick='return popupHelp(this.href)'>&dagger;</a></sup>", "/cards/rewards-cards/avion-infinite.html"));



	cards.push(new Card("avion_p", "Visa Platinum Avion", "2", "19.50%", "17", "$120", "", "$50", "$35,000", "Y", "N", "N", "N", "N", "Y", "Y", "N", "N", "Y", "Redeem points for flights on any airline", "No blackout periods or seat restrictions", "Earn 1 RBC Rewards point for each $1 spent", "15,000 welcome points upon enrollment<sup><a href='/cards/_assets-custom/includes/pop-up/terms-and-condition/avion_p.html' title='Disclaimer (opens new window)' target='_blank' onclick='return popupHelp(this.href)'>&dagger;</a></sup>", "/cards/rewards-cards/avion-platinum.html"));



	cards.push(new Card("gold_p", "Visa Gold Preferred", "3", "19.50%", "21", "$110", "$70", "$40", "$35,000", "Y", "N", "N", "N", "N", "Y", "Y", "N", "N", "Y", "Comprehensive insurance coverage", "Earn 1 RBC Rewards point for each $1 spent", "Redeem points for travel, merchandise & more", "2,500 bonus points upon enrolment<sup>&dagger;</sup>", "/cards/rewards-cards/gold-preferred.html"));



	cards.push(new Card("classic2", "Visa Classic II", "5", "19.50%", "21", "$35", "", "Free", "$15,000", "Y", "N", "N", "N", "N", "Y", "Y", "N", "N", "N", "The perfect shopping companion card", "Collect rewards points with every purchase", "Earn 1 RBC Rewards point for each $1 spent", "", "/cards/rewards-cards/classic-2.html"));



	cards.push(new Card("classic2_student", "Visa Classic II Student", "16", "19.50%", "21", "$15", "", "Free", "n/a", "Y", "Y", "N", "N", "N", "Y", "Y", "N", "N", "N", "The perfect student credit card", "Collect rewards points with every purchase", "Earn 1 RBC Rewards point for each $1 spent", "", "/cards/student-cards/classic-2-student.html"));



	cards.push(new Card("rewards_gold", "RBC Rewards Visa Gold", "6", "19.50%", "21", "$0", "", "Free", "$35,000", "Y", "N", "N", "Y", "N", "Y", "Y", "N", "N", "Y", "A premium no annual fee credit card", "Earn 1 RBC Rewards point for each $2 spent", "Redeem points for travel, merchandise, gift certicates/cards & more", "", "/cards/rewards-cards/rewards-gold.html"));



	cards.push(new Card("rewards_classic", "RBC Rewards Visa Classic", "7", "19.50%", "21", "$0", "", "Free", "$15,000", "Y", "N", "N", "Y", "N", "Y", "Y", "N", "N", "N", "A no annual fee credit card with rewards", "Earn 1 RBC Rewards point for each $2 spent", "Redeem points for travel, merchandise, gift certicates/cards & more", "", "/cards/rewards-cards/rewards-classic.html"));



	cards.push(new Card("gold_us", "U.S. Dollar Visa Gold", "14", "19.50%", "21", "$65 USD", "", "$30 USD", "$35,000", "Y", "N", "N", "N", "N", "Y", "Y", "N", "Y", "Y", "The perfect option for U.S. travellers", "Make transactions in U.S. funds", "Earn 1 RBC Rewards point for each $1 U.S. spent", "", "/cards/rewards-cards/us-gold.html"));



	//cards.push(new Card("mikeweir", "RBC Mike Weir Visa", "11", "19.50%", "21", "$35", "", "Free", "$15,000", "Y", "N", "N", "N", "N", "Y", "Y", "N", "N", "Y", "Enjoy exclusive golf related rewards", "Bonus points with each Mike Weir PGA victory", "Special golf related insurances", "", "/cards/rewards-cards/mike-weir.html"));



	cards.push(new Card("ba_platinum", "British Airways Visa Platinum", "4", "20.50%", "17", "$165", "", "$75", "$35,000", "Y", "N", "N", "N", "N", "N", "Y", "Y", "N", "Y", "31-day Out of Province/Country Emergency Medical Insurance", "One BA Mile for every dollar you spend on the card<sup>&Dagger;</sup>", "Double BA Miles for every dollar you spend on British Airways flights purchased with the card.<sup>&sect;</sup>", "10,000 bonus BA Miles upon enrollment<sup>&dagger;</sup>", "/cards/travel-cards/british-airways-platinum.html"));



	cards.push(new Card("cp_platinum", "Cathay Pacific Visa Platinum", "10", "20.50%", "17", "$150", "", "$75", "$35,000", "Y", "N", "N", "N", "N", "Y", "Y", "Y", "N", "Y", "Earn Asia miles towards flights and more", "Earn Asia Miles for dollars spent on the card", "Complimentary enrolment in The Marco Polo Club", "5,000 bonus Asia Miles upon enrolment<sup>&dagger;</sup>", "/cards/travel-cards/cathay-pacific-platinum.html"));



	cards.push(new Card("esso", "Esso Visa Card", "9", "19.50%", "21", "$0", "", "Free", "$15,000", "Y", "N", "N", "Y", "N", "Y", "N", "Y", "N", "N", "Earn points towards free gas at Esso stations", "No annual fee credit card", "Redeem points for car washes, gas and more", "", "/cards/no-annual-fee-cards/esso.html"));



	cards.push(new Card("starbucks", "Starbucks Duetto Visa Card", "8", "19.50%", "21", "$0", "", "Free", "$15,000", "Y", "N", "N", "Y", "N", "Y", "N", "Y", "N", "N", "Receive $25 to spend at Starbucks after your first Visa purchase<sup>(+)</sup>", "Earn up to 3% of Visa spend on their Starbucks Card Account", "The flexibility and security of a Visa Credit Card, plus the speed and convenience of a reloadable Starbucks Card", "", "/cards/no-annual-fee-cards/starbucks.html"));



	cards.push(new Card("platinum", "Visa Platinum", "12", "19.50%", "17", "$0", "", "Free", "$35,000", "N", "N", "N", "Y", "N", "N", "N", "N", "N", "Y", "No annual fee platinum credit card", "Essential travel and purchase insurance", "Credit limit of up to $50,000", "", "/cards/no-annual-fee-cards/platinum-no-fee.html"));



	cards.push(new Card("classic", "Visa Classic", "13", "19.50%", "21", "$0", "", "Free", "$15,000", "N", "N", "N", "Y", "N", "N", "N", "N", "N", "N", "Basic, everyday Visa card", "No annual fee credit card", "Free additional card", "", "/cards/no-annual-fee-cards/classic.html"));



	cards.push(new Card("classic_lr", "Visa Classic Low Rate Option", "15", "11.90%", "21", "$20", "", "Free", "$15,000", "N", "N", "Y", "N", "N", "N", "N", "N", "N", "N", "Value, convenience, and a low interest rate", "Save when you carry a balance on your card", "Free additional card", "", "/cards/low-interest-rate-cards/classic-low-rate.html"));



	cards.push(new Card("classic_student", "Visa Classic Student", "17", "19.50%", "21", "$0", "", "Free", "n/a", "N", "Y", "N", "Y", "N", "N", "N", "N", "N", "N", "Basic, everyday student Visa card", "Access to credit with no annual fee", "Free additional card", "", "/cards/student-cards/classic-student.html"));



	cards.push(new Card("business", "Visa Business", "19", "19.50%", "21", "$12", "", "", "n/a", "N", "N", "N", "N", "Y", "N", "N", "N", "N", "N", "Flexible and affordable business card", "Low annual fee", "Additional security and protection", "", "/cards/business/visa_business.html"));



	cards.push(new Card("bus_avion", "Visa Business Avion", "18", "19.50%", "17", "$120", "", "$50", "n/a", "Y", "N", "N", "N", "Y", "Y", "Y", "N", "N", "Y", "Separate business and personal expenses", "Manage employee spending", "Earn 1 RBC Rewards point for each $1 spent", "15,000 welcome points upon enrollment<sup><a href='/cards/_assets-custom/includes/pop-up/terms-and-condition/bus_avion.html' title='Disclaimer (opens new window)' target='_blank' onclick='return popupHelp(this.href)'>&dagger;</a></sup>", "/cards/business/visa_business_avion.html"));



	cards.push(new Card("creditline", "CreditLine for Small Business", "20", "Prime + premium", "0", "$0", "", "Free", "n/a", "Y", "N", "Y", "Y", "Y", "Y", "Y", "N", "N", "N", "Line of credit with the convenience of a credit card", "Low rate, no annual fee", "Earn RBC Rewards points", "", "/cards/business/creditline.html"));



}







//Takes out "$", ",", "N/A", "n/a" from string to make it a valid number



function convertToNumber(str){



	var number = 0;



	number = str.replace(/\$/, "");



	number = number.replace(/,/, "");



	number = number.replace(/N\/A/, "");



	number = number.replace(/n\/a/, "");



	number = number.replace(" ", "");
		


	if (number == '') number = 0.00;



	



	return Number(number);



}







//Retrieves card object with specific id



function getCardObjectById(cid) {



	var temp;



	for (var x=0; x< cards.length; x++) {



		temp = cards[x].id;



		if (cid == temp) return cards[x];



	}



	



	return null;



}







//Retrieves specified parameter from URL string



function getURLParam(strParamName) {	



	// GetURL Params value from querystring



	var qs = location.search.split('?');



	if (qs.length > 1) {



	var pairs = qs[1].split("&");



		for (var i=0; i<pairs.length; i++) {



			var namevalue = pairs[i].split("=", 2);



			var name = unescape(namevalue[0]);



			var value = unescape(namevalue[1]);



			if (name.toUpperCase() == strParamName.toUpperCase()) {



				return value;



				//break;



			}



		}



	}



	return null;



}