// This is the phrase that all rewrite pages begin with, ex. "CheckOutBilling.aspx"
var rewritePagePrefix = "Checkout";
// What protocol to use if the rewritePagePrefix is found preceding the page
var rewriteProtocol = "https:";
// What protocol to use if the rewritePagePrefix is NOT found preceding the page
var standardProtocol = "http:";
// This is the page extension, ex. .aspx, .php, .jsp
var pageExtension = '.aspx';
// Domain that the certificate is valid for
var sslDomain = 'www.cowboycool.com';

var protocol = location.protocol;
var path = sslDomain + location.pathname + location.search;
var pageWithQuery = path.substring(path.lastIndexOf('/') + 1,path.length);
//var pageWithQuery = location.href.split('/')[location.href.split('/').length - 1];
var page = pageWithQuery.substring(0,pageWithQuery.indexOf(pageExtension) + pageExtension.length);

if(page.indexOf(rewritePagePrefix) != -1 && protocol != rewriteProtocol){
	//alert(rewriteProtocol + "://" + path);
	location.replace(rewriteProtocol + "//" + path);
}
else if(page.indexOf(rewritePagePrefix) == -1 && protocol == rewriteProtocol){
	//alert(standardProtocol + "://" + path);
	location.replace(standardProtocol + "//" + path);
}