﻿// move from banner to banner (in order) on WELCOME SCREEN
function bannerChange(n) {
	banner_number = document.getElementById('bannerNumber').value;
	
	if (n == 0) {	// go down
		banner_number = banner_number - 1;
		if (banner_number == 0) {
			banner_number = 5;
		}
	} else {		// go up
		banner_number = parseInt(banner_number) + 1;
		if (banner_number == 6) {
			banner_number = 1;
		}
	}
	random_image = "images/home_banner" + banner_number + ".jpg";
	
	
	document.getElementById('banner').style.background="url('" + random_image +"')";
	document.getElementById('bannerNumber').value=banner_number;
}

// switch languages
function changeLanguage(rootPath) {
  var box = document.forms.language.selectLang;
  myLanguage = box.options[box.selectedIndex].value;
  // alert (myLanguage);
  if (myLanguage != "ignore") {
  	if (myLanguage.toLowerCase() == "es") {
  		destination = rootPath + "es";
  	} else {  
		destination = rootPath + "main.cfm/welcome/" + myLanguage.toLowerCase();
	}
	//alert (destination);
	if (destination) location.href = destination;
  }
}

// switch audience
function changeAudience() {
	destination = document.getElementById("audience").value;
	location.href = destination;
}


// Save changes...
function rateContent(rating) {
  var formObj; 
  
  formObj = document.forms['rating'];
  formObj.theRating.value = rating;
  formObj.submit();
  return true;
}

//Redirect form submission
function redirect(redirectURL) {
  var formObj= document.forms['aspnetForm'];
  var hiddenObj = document.getElementById('ctl00_ctl00_ctl00_theRedirect');
  hiddenObj.value = redirectURL;
  formObj.action = "/redirect/redirect.htm";
  formObj.submit();
  return true;
}

//Redirect form submission
function redirectHome(redirectURL) {
  var formObj= document.forms['aspnetForm'];
  var hiddenObj = document.getElementById('ctl00_ctl00_theRedirect');
  hiddenObj.value = redirectURL;
  formObj.action = "/redirect/redirect.htm";
  formObj.submit();
  return true;
}

//Redirect form submission (foreign)
function redirectForeign(redirectURL) {
  var formObj= document.forms['aspnetForm'];
  var hiddenObj = document.getElementById('ctl00_ctl00_theRedirect');
  hiddenObj.value = redirectURL;
  formObj.action = "/redirect/redirect.htm";
  formObj.submit();
  return true;
}



//Redirect form submission (on static errors/error.htm)
function redirectError(redirectURL, ektID) {
   document.getElementById("ctl00$ctl00$theRedirect").value = redirectURL;
   document.getElementById("ctl00_ctl00_theRedirect").value = redirectURL;
   document.getElementById("FormRedirect").action = "/newmoney/redirect/default_ektid" + ektID + ".aspx";
   document.getElementById("FormRedirect").submit();
   return true;
}

// opens pop up window
var popupWin
function openWindow2(winname,url) {
	if (!popupWin || popupWin.closed) {
	 popupWin = window.open(url, winname, "width=660,height=530,status=no,scrollbars=no,resize=no,menubar=no")
	 if (popupWin.opener == null) {
	   popupWin.opener = self;
	 }
	} else {
	 popupWin.location.href = url
	}
	popupWin.focus();
}

function openWindow3(winname,url) {
	if (!popupWin || popupWin.closed) {
	 popupWin = window.open(url, winname, "width=340,height=263,status=no,scrollbars=no,resize=no,menubar=no")
	 if (popupWin.opener == null) {
	   popupWin.opener = self;
	 }
	} else {
	 popupWin.location.href = url
	}
	popupWin.focus();
}

// open up window for image popup
function imgPopup(url,w,h) {
	w = w + 150;
	h = h + 50;
	if (!popupWin || popupWin.closed) {
		popupWin = window.open(url, "remote", "width="+w+",height="+h+",status=no,scrollbars=yes,resizable=1,menubar=no");
			if (popupWin.opener == null) {
				popupWin.opener = self;
			}
	} else {
		popupWin.location.href = url;
	} popupWin.focus();
}
