// This script is required for the following page: Business Solutions 91375.
// To change an image, simply replace the old image link with the new.



function passImage(populate) {

// General rules: If there is no second dropdown box, then the altTxt should be commented out and the linkTo url added.
// eg: Agribusiness, Food, Mining

	var imgLoad = "";
	var altTxt = "";
	var linkTo = "";
	switch (populate) {
	case "Agribusiness":
		// with the exception of Agribusiness, all other links are images.
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/1/";
		break;
	case "Education":
		imgLoad = "industryhp_education.jpg";
		altTxt = "Education banner";
		break;
	case "Religious":
		// with the exception of Agribusiness, all other links are images.
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/19/";
		break;
	case "Food":
		imgLoad = "industryhp_ffb.jpg";
//		altTxt = "Food banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/3/";
		break;
	case "Government":
		imgLoad = "industryhp_governement.jpg";
		altTxt = "Government banner";
		break;
	case "Health":
		imgLoad = "industryhp_health.jpg";
		altTxt = "Health banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/5/1/";
		break;
	case "Franchising":
		imgLoad = "industryhp_franchising.jpg";
		altTxt = "Franchising banner";
		break;
	case "Planning":
//		imgLoad = "industryhp_finplanning.jpg";
//		altTxt = "Planning banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/7/1/"; 
		break;
	case "Mining":
//		imgLoad = "industryhp_mining.jpg";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/8/";
		// altTxt = "Mining banner";
		break;
	case "Manufacturing":
//		imgLoad = "industryhp_manufacturing.jpg";
//		altTxt = "Manufacturing banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/9/";
		break;
	case "Construction":
//		imgLoad = "industryhp_construction.jpg";
//		altTxt = "Construction banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/10/";
		break;
	case "Wholesale":
//		imgLoad = "industryhp_wholesale.jpg";
//		altTxt = "Wholesale banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/11/";
		break;
	case "Retail":
//		imgLoad = "industryhp_retail.jpg";
//		altTxt = "Retail banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/12/";
		break;
	case "Hospitality":
//		imgLoad = "industryhp_hospitality.jpg";
//		altTxt = "Hospitality banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/13/";
		break;
	case "Transport":
//		imgLoad = "industryhp_transport.jpg";
//		altTxt = "Transport banner";
		linkTo = "/wps/wcm/myconnect/nab/nab/home/Business_Solutions/8/14/";
		break;
	case "Communication":
		imgLoad = "industryhp_communication.jpg";
		altTxt = "Communication banner";
		break;
	case "Property":
//		imgLoad = "industryhp_property.jpg";
//		altTxt = "Property banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/16/";
		break;
	case "Business":
//		imgLoad = "industryhp_business.jpg";
//		altTxt = "Business banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/17/";
		break;
	case "Personal":
//		imgLoad = "industryhp_personal.jpg";
//		altTxt = "Personal banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/18/";
		break;
	case "Insolvency":
//		imgLoad = "industryhp_personal.jpg";
//		altTxt = "Personal banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/NAB+Insolvency+Service/1";
		break;
	case "Management Rights":
//		imgLoad = "industryhp_personal.jpg";
//		altTxt = "Personal banner";
		linkTo = "/wps/wcm/connect/nab/nab/home/Business_Solutions/8/681/1";
		break;		
	}

	return [imgLoad, altTxt, linkTo];


}

function chkVarPass() {
	var strURL = document.URL;
	var industryID = "";

	var urlPARAM = strURL.split("is=");
	if (urlPARAM[1] != null) {
		industryID = urlPARAM[1].split("&");
	}

	return industryID;
}

function detectParam(form) {
	var inID = chkVarPass();
	inID = inID.toString();
	init();
	var id = showLastLogin2();
	
	if( !inID || inID.length == 0 ) {
		inID = $('#industry :selected').text();
	}	
	
	if( inID.length > 0 ) {
		displayImg = passImage(inID);
		$('#industry [@value='+inID+']').attr('selected','true');
		makeChange(document.industryselector, inID);
		form.industryLink.value = displayImg[2];
	} else {
		$('#industry_flash').show();
	}

}

function setLastLoginCookieValue2(selection) {
	var exp = new Date();
	var currDate = exp.getTime();
	var newExpDate = currDate + (182 * 24 * 60 * 60 * 1000);
	exp.setTime(newExpDate);
	document.cookie = "lastLogin2=" + selection + "; expires=" + exp.toGMTString() + "; path=/";
}

function showLastLogin2() {
	var nameEq2 = "lastLogin2=";
	var lastLoginValue2 = 0;
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEq2) == 0) lastLoginValue2 = c.substring(nameEq2.length,c.length);
	}
	document.industryselector.industry.selectedIndex = lastLoginValue2;
	return lastLoginValue2;
}



