var url_base = "https://secure.usnews.com/premium/";
var downpage = "https://secure.usnews.com/cart_unavailable.htm";

function getRef() {
	var ref = document.referrer;

	return ref;
}

function pay() {
	var path            = "pay1.jsp";
	var query           = "?o=1&referer=";
	var intropage	    = "http://www.usnews.com/usnews/edu/grad/rankings/about/welcome.htm";
	var introquery	    = "%3Fr%3D" + location.href;
	var window_url      = url_base + path + query + intropage + introquery;
	var window_name     = "Authorize";
	var window_features = "resizable=yes,"  +
	                      "scrollbars=yes," +
			      "status=yes,"	+
	                      "width=600,"      +
	                      "height=600"      ;

	window.open(window_url, window_name, window_features);
//	window.open(downpage, window_name, window_features);
		
}

function useredit() {
	var path            = "user1.jsp";
	var window_url      = url_base + path;
	var window_name     = "Authorize";
	var window_features = "resizable=yes,"  +
	                      "scrollbars=yes," +
			      "status=yes,"	+
	                      "width=600,"      +
	                      "height=600"      ;

	window.open(window_url, window_name, window_features);
//	window.open(downpage, window_name, window_features);
}

function verify() {
	var certification_image = new Image();
	certification_image.onerror = deny_user;
	var path  = "servlet/paythrough.servlet.CertificationServlet";
        var now = new Date();
        var query = "?image&" + now.getTime() + ";" + location.href;
	certification_image.src = url_base + path + query;
}

function deny_user() {
	var path   = "authorize.jsp";
	var query  = "?referer=";
	var query2 = "&redirect=" + location.href;

	location.href = url_base + path + query + getRef() + query2;
}

//yjones added
function login(resource) {
        var path            = "login";
	var p = location.pathname;
	if (p.indexOf("logout") != -1) {
		//p = resource.substring(resource.indexOf("?") + 3);
		p = "/usnews/edu/grad/rankings/rankindex.htm";
	}
	var query	    = "?p=" + p;
        var window_url      = url_base + path + query;
        var window_name     = "Authorize";
        var window_features = "resizable=yes,"  +
                              "scrollbars=yes," +
			      "status=yes,"	+
                              "width=620,"      +
                              "height=600"      ;

        window.open(window_url, window_name, window_features);
//	window.open(downpage, window_name, window_features);
}
