/* VROPLUS scripts - used by VroPlus pages on usa.visa.com */

/* Offer detail popup: provides a pre-formatted popup window */
function ShowDetails(offer_id) {
   var string = offer_id;
   window.open(string, 'window1', "width=455,height=500,resizable,scrollbars");
}

/* Member offer detail display: parses provided value, creates a custom url, and opens a new window to that url */
function popupList(formname,fieldname,pageFolder) {
	var theValue = eval("document.forms." + formname + "." + fieldname + "[document.forms." + formname + "." + fieldname + ".selectedIndex].value");

	if(theValue != "")
	{
		var theLocation = theValue + "/vro_details.jsp?pageFolder=" + pageFolder;
		//alert(theLocation);
		ShowDetails(theLocation);
	}
}

/* Usa offer detail display: parses provided value, creates a custom url, and redirects to that url */
function viewList(formname,fieldname) {
	var theValue = eval("document.forms." + formname + "." + fieldname + "[document.forms." + formname + "." + fieldname + ".selectedIndex].value");
	var theOffset = eval("document.forms." + formname + "." + fieldname + ".selectedIndex");
	if(theValue != "")
	{
		var place = theValue.indexOf(",");
		var num = theValue.substring("0", place);
		var itemName = theValue.substring(place+1);
		
		while(itemName.indexOf(" ") != -1)
		{
			var pos = itemName.indexOf(" ");
			itemName = itemName.substring("0",pos) + itemName.substring(pos+1);
		}
		//alert("redirect url: " + itemName + "/vro_details.jsp?id=" + num);
		location.href = "../" + itemName + "/vro_details.jsp?vp2_id=" + num + "&vp2_fieldName=" + fieldname + "&formname=" + formname + "&offset=" + theOffset + "&";
	}
}

/* Usa second level display: parses provided value, creates a custom url, and redirects to that url */
function showUsaDetail(formname,fieldname) {
	var theValue = eval("document.forms." + formname + "." + fieldname + "[document.forms." + formname + "." + fieldname + ".selectedIndex].value");
	if(theValue != "")
	{
		var place = theValue.indexOf(",");
		var num = theValue.substring("0", place);
		var itemName = theValue.substring(place+1);
		while(itemName.indexOf(" ") != -1)
		{
			var pos = itemName.indexOf(" ");
			itemName = itemName.substring("0",pos) + itemName.substring(pos+1);
		}
		location.href = itemName + "/vro_details.jsp?vp2_id=" + num + "&vp2_fieldName=" + fieldname + "&formname=" + formname;
	}
}