/******************************************************************************
 * IMPORT IE6.CSS IF BROWSER == IE6                                           *
 ******************************************************************************/

var appVer = navigator.appVersion;
appVer = appVer.split(';');
if(appVer[1] == ' MSIE 6.0') {
	var headID = document.getElementsByTagName("head")[0];
	      
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = '/portal_resources/ie6.css';
	cssNode.media = 'screen';
	headID.appendChild(cssNode);
}

/******************************************************************************
 * portal_resources/utilities.js                                              *
 ******************************************************************************/

function resetForm(formId) {
  document.getElementById(formId).reset();
}

function submitForm(formId) {
  document.getElementById(formId).submit();
}

function redirect(redirectURL) {
  window.location = redirectURL;
}


/******************************************************************************
 * portal_resources/ajax.js                                                   *
 ******************************************************************************/

function getXmlHttpRequest() {
  var xhr;
  try {
    // Firefox, Opera 8.0+, Safari
    xhr=new XMLHttpRequest();
  }
  catch (ex){
    // Internet Explorer
    try {
      xhr=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (ex){
      try {
        xhr=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (ex) {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  return xhr;
}


/******************************************************************************
 * portal_resources/mail.js                                                          *
 ******************************************************************************/

function sendMail() {
	var mailForm = document.mailForm;
	var send = true;
	var mandatories = mailForm.getElementsByTagName('input');
	for (var i = 0; i < mandatories.length; i++) {
		var mandatory = mandatories[i];
		var error = "" + mandatory.value + "ErrorMsgMandatory";
		if (mandatory.name == 'mandatoryText') {
			var textField = mailForm.elements[mandatory.value];
			if (textField && textField.value == '') {
				send = false;
				document.getElementById(error).style.visibility = "visible";
  			document.getElementById(error).style.display = "block";
			} else {
				document.getElementById(error).style.visibility = "hidden";
  			document.getElementById(error).style.display = "none";
			}
		} else if (mandatory.name == 'mandatoryOption') {
			var optionList = mailForm.elements[mandatory.value];
			var oneChecked = false;
			if (optionList[0]) {
				for (var j = 0; j < optionList.length; j++) {
					if (optionList[j].checked) {
						oneChecked = true;
					}
				}
			} else if (optionList.checked) {
				oneChecked = true;
			}
			if (!oneChecked) {
				send = false;
				document.getElementById(error).style.visibility = "visible";
  			document.getElementById(error).style.display = "block";
			} else {
				document.getElementById(error).style.visibility = "hidden";
  			document.getElementById(error).style.display = "none";
			}
		}  else if (mandatory.name == 'mandatoryCheck') {
			var checkListName = mandatory.value;
			var checkListNameLength = checkListName.length;
			var allCheckElements = getElementsByClassName('mailform-checkbox','');
			var theseCheckElements = [];
			var y = 0;
			var oneChecked = false;
			for (var x = 0; x < allCheckElements.length; x++) {
				if (String(allCheckElements[x].name).substring(0,checkListNameLength) == checkListName) {
					theseCheckElements[y]=allCheckElements[x];
					y++;
				}
			}
			for (var z = 0; z < theseCheckElements.length; z++) {
				if (theseCheckElements[z].checked) {
					oneChecked = true;
				}
			}
			if (!oneChecked) {
				send = false;
				document.getElementById(error).style.visibility = "visible";
  			document.getElementById(error).style.display = "block";
			} else {
				document.getElementById(error).style.visibility = "hidden";
  			document.getElementById(error).style.display = "none";
			}
		}
	}
	if (!send) {
		document.getElementById("errorMsgMandatory1").style.visibility = "visible";
		document.getElementById("errorMsgMandatory1").style.display = "block";
		document.getElementById("errorMsgMandatory2").style.visibility = "visible";
		document.getElementById("errorMsgMandatory2").style.display = "block";
	} else {
		document.getElementById("errorMsgMandatory1").style.visibility = "hidden";
		document.getElementById("errorMsgMandatory1").style.display = "none";
		document.getElementById("errorMsgMandatory2").style.visibility = "hidden";
		document.getElementById("errorMsgMandatory2").style.display = "none";
	}
	return send;
}

function validateNumberBox(field) {
	var send = true;
  var fieldValue = document.getElementById(field).value;
  var error = "" + field + "Error";
  
  if(isNaN(fieldValue)) {
    document.getElementById(error).style.visibility = "visible";
    document.getElementById(error).style.display = "block";
		return false;
  } else {
	  document.getElementById(error).style.visibility = "hidden";
	  document.getElementById(error).style.display = "none";
		return true;
  }
}

function validateEmailbox(field) {
	var send = true;
  var fieldValue = document.getElementById(field).value;
  var error = "" + field + "Error";
  
  if (fieldValue != "") {
	  var emailFilter=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if (!(emailFilter.test(fieldValue))) { 
		   send = false;
		}
		
		var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
		if (fieldValue.match(illegalChars)) {
		   send = false;
		}
  }
  
  if (!send) {
		document.getElementById(error).style.visibility = "visible";
		document.getElementById(error).style.display = "block";
		return false;
	} else {
		document.getElementById(error).style.visibility = "hidden";
		document.getElementById(error).style.display = "none";
		return true;
	}
}

function getElementsByClassName(classname, node) {
	if(!node) node = document.getElementsByTagName("body")[0];
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for(var i=0,j=els.length; i<j; i++)
	if(re.test(els[i].className))a.push(els[i]);
	return a;
}

/******************************************************************************
 * portal_resources/fund selector functions                                   *
 ******************************************************************************/

function copySelectedFund(availableFundsField,selectedFundsField,concatenatedField) {
	var boxLength = document.getElementById(selectedFundsField).length;
	var selectedItem = document.getElementById(availableFundsField).selectedIndex;
	var selectedText = document.getElementById(availableFundsField).options[selectedItem].text;
	var selectedValue = document.getElementById(availableFundsField).options[selectedItem].value;
	var i;
	var isNew = true;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			thisitem = document.getElementById(selectedFundsField).options[i].text;
			if (thisitem == selectedText) {
				isNew = false;
				break;
			}
		}
	} else {
		document.getElementById(selectedFundsField).style.width = "150px";
	}
	if (isNew) {
		newoption = new Option(selectedText, selectedValue, false, false);
		document.getElementById(selectedFundsField).options[boxLength] = newoption;
	}
	document.getElementById(availableFundsField).selectedIndex=-1;
	
	document.getElementById(selectedFundsField).style.width = document.getElementById(availableFundsField).style.width;
	
	document.getElementById(concatenatedField).value = saveSelectedFund(selectedFundsField);
}

function removeSelectedFund(availableFundsField,selectedFundsField,concatenatedField) {
	var boxLength = document.getElementById(selectedFundsField).length;
	arrSelected = new Array();
	var count = 0;
	for (i = 0; i < boxLength; i++) {
		if (document.getElementById(selectedFundsField).options[i].selected) {
			arrSelected[count] = document.getElementById(selectedFundsField).options[i].value;
		}
		count++;
	}
	var x;
	for (i = 0; i < boxLength; i++) {
		for (x = 0; x < arrSelected.length; x++) {
			if (document.getElementById(selectedFundsField).options[i].value == arrSelected[x]) {
				document.getElementById(selectedFundsField).options[i] = null;
			}
		}
		boxLength = document.getElementById(selectedFundsField).length;
	}
	
	if (document.getElementById(selectedFundsField).length == 0) {
		document.getElementById(selectedFundsField).style.width = "150px";
	} else {
		document.getElementById(selectedFundsField).style.width = document.getElementById(availableFundsField).style.width;
	}
	
	document.getElementById(concatenatedField).value = saveSelectedFund(selectedFundsField);
}

function saveSelectedFund(selectedFundsField) {
	var strValues = "";
	var boxLength = document.getElementById(selectedFundsField).length;
	var count = 0;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			if (count == 0) {
				strValues = document.getElementById(selectedFundsField).options[i].value;
			}
			else {
				strValues = strValues + ", " + document.getElementById(selectedFundsField).options[i].value;
			}
			count++;
		}
	}
	
	return strValues;
}


/******************************************************************************
 * portal_resources/Buy shares functions                                      *
 ******************************************************************************/

function handlerSolo (select, category, hidden) {
	//handler on a fund-dropdown for the 'Solo' buy shares form
	setLinksHidden();
	resetDropDowns(select);
	setLinkVisible(select, category);
	copyToHidden(select, hidden);
}

function handlerForm (select, category, hidden) {
	//handler on a fund-dropdown for the 'Form' buy shares form
	setLinksHidden();
	setLinkVisible(select, category);
}

function setLinksHidden() {
	//hide all pdf-links
	var spans = document.getElementsByTagName("span");
	for (var i = 0; i < spans.length; i++) {
		spans[i].style.display='none';
	}
}

function setLinkVisible(select, category) {
	//set the pdf-link visible (if there is one)
	var selectedItem = document.getElementById(select).selectedIndex;
	var selectedValue = document.getElementById(select).options[selectedItem].value;
	var toDisplayLink = category + '_' + selectedValue;

	if (document.getElementById(toDisplayLink) != null) {
		document.getElementById(toDisplayLink).style.display='block';
	}
}

function copyToHidden(select, hidden) {
	//copy the selected fund of a funddropdown to a hidden field
	var selectedItem = document.getElementById(select).selectedIndex;
	var selectedValue = document.getElementById(select).options[selectedItem].value;
	document.getElementById(hidden).value = selectedValue;
	var selectLength = select.length;
	document.getElementById(hidden).name = select.substring(0,(selectLength-7));
}

function resetDropDowns(select) {
	//function to clear the other funddropdownboxes, only one dd may be filled in
	var fundDropDowns = document.getElementsByTagName('input');
	for (var i = 0; i < fundDropDowns.length; i++) {
		var fundDropDown = fundDropDowns[i];
		if (fundDropDown.name=="fundDropDowns") {
			if (fundDropDown.value != select) {
				var reset = fundDropDown.value;
				document.getElementById(reset).options[0].selected = true;
			}
		}
	}
}

function validateAndHide(bool) {
	if(bool) {
		if(checkMailFormValidity()) {
			//if the form is valid, display the validation div and hide the input div
			document.getElementById("mailFormInput").style.display='none';
			document.getElementById("mailFormValidation").style.display='block';
			
			//fill the validation div
			GetAllFormItems();
		}
	} else if(!bool) {
		//back button has been hit, hide the validation div and show the input div
		document.getElementById("mailFormInput").style.display='block';
		document.getElementById("mailFormValidation").style.display='none';
	}
}

function GetAllFormItems() {
	//get all the fields being sent to the mailform
	var itemsString = document.getElementById("formFieldsCSV").value;
	var AllFormItems = itemsString.split(",");
	
	//get the div where we want to put the table in.
	var obj=document.getElementById("GetAllFormItems");
	
	//create a table
	var strHTML = "<table>";
	strHTML += "<colgroup>";
	strHTML += "<col class='labels' \/>";
	strHTML += "<col class='fields' \/>";
	strHTML += "<\/colgroup>";
	
	//loop over the fields
	for (var i = 0; i < AllFormItems.length; i++) {
		//get the item by it's name
		var theseItems = document.getElementsByName(String(AllFormItems[i]));
		var itemValue = "";
		
		//if the item has not been found, it is a fund-select-box with another name.
		if (theseItems.length == 0) {
			theseItems = document.getElementsByName(String(AllFormItems[i])+"_select");
		}
		
		//display the name for checkboxes without _#
		var itemName = AllFormItems[i];
		var itemNameLength = itemName.length;
		if (itemName.substring((itemNameLength-2),(itemNameLength-1)) == '_') {
			itemName = itemName.substring(0,(itemNameLength-2));
		}
		
		for (var j = 0; j < theseItems.length; j++) {
			var thisItem = theseItems[j];
			if(thisItem.type == "text" || thisItem.type == "textarea") {
				itemValue = thisItem.value;
			}	else if(thisItem.type == "checkbox") {
				if (thisItem.checked) {
					//only set the value if the checkbox has been checked
					itemValue = thisItem.value;
				}
			}	else if(thisItem.type == "select-one") {
				itemValue = thisItem.options[thisItem.selectedIndex].text;
			} else if(thisItem.type == "radio") {
				//radiobuttons have the same name, but another id
				var tempItemName = ""+ (thisItem.name).split(' ').join('') + "-radio" + String(j+1);
				var tempItem = document.getElementById(tempItemName);
				if (tempItem.checked == true) {
					itemValue = tempItem.value;
					continue;
				}
			}
		}
		
		var strAmountVar = "*AMOUNT_VAR*";
		// checking if the itemName ends with *AMOUNT_VAR*
		if (itemName && (itemName.match ("\\*AMOUNT_VAR\\*$") == strAmountVar)) {
		  // if so, we extract it from the name
		  itemName = itemName.substr (0, itemName.length - strAmountVar.length);
		}
		
		//only show a row if both a label & value are present
		if ( itemName != "" && itemValue!= "") {
			strHTML += String("<tr><td>" + itemName + "<\/td><td>" + itemValue +"<\/td><\/tr>");
		}
	}
	//close the table
	strHTML += "</table>";
	
	//dump the created html code (table) in the selected div
	obj.innerHTML = "" + strHTML;
}




/******************************************************************************
 * portal_resources/date-functions.js                                                *
 ******************************************************************************/

/*
 * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, version 2.1.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * $Revision: 1.2 $
 */

Date.parseFunctions = {count:0};
Date.parseRegexes = [];
Date.formatFunctions = {count:0};

Date.prototype.dateFormat = function(format) {
    if (Date.formatFunctions[format] == null) {
        Date.createNewFormat(format);
    }
    var func = Date.formatFunctions[format];
    return this[func]();
}

Date.createNewFormat = function(format) {
    var funcName = "format" + Date.formatFunctions.count++;
    Date.formatFunctions[format] = funcName;
    var code = "Date.prototype." + funcName + " = function(){return ";
    var special = false;
    var ch = '';
    for (var i = 0; i < format.length; ++i) {
        ch = format.charAt(i);
        if (!special && ch == "\\") {
            special = true;
        }
        else if (special) {
            special = false;
            code += "'" + String.escape(ch) + "' + ";
        }
        else {
            code += Date.getFormatCode(ch);
        }
    }
    eval(code.substring(0, code.length - 3) + ";}");
}

Date.getFormatCode = function(character) {
    switch (character) {
    case "d":
        return "String.leftPad(this.getDate(), 2, '0') + ";
    case "D":
        return "Date.dayNames[this.getDay()].substring(0, 3) + ";
    case "j":
        return "this.getDate() + ";
    case "l":
        return "Date.dayNames[this.getDay()] + ";
    case "S":
        return "this.getSuffix() + ";
    case "w":
        return "this.getDay() + ";
    case "z":
        return "this.getDayOfYear() + ";
    case "W":
        return "this.getWeekOfYear() + ";
    case "F":
        return "Date.monthNames[this.getMonth()] + ";
    case "m":
        return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
    case "M":
        return "Date.monthNames[this.getMonth()].substring(0, 3) + ";
    case "n":
        return "(this.getMonth() + 1) + ";
    case "t":
        return "this.getDaysInMonth() + ";
    case "L":
        return "(this.isLeapYear() ? 1 : 0) + ";
    case "Y":
        return "this.getFullYear() + ";
    case "y":
        return "('' + this.getFullYear()).substring(2, 4) + ";
    case "a":
        return "(this.getHours() < 12 ? 'am' : 'pm') + ";
    case "A":
        return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
    case "g":
        return "((this.getHours() %12) ? this.getHours() % 12 : 12) + ";
    case "G":
        return "this.getHours() + ";
    case "h":
        return "String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";
    case "H":
        return "String.leftPad(this.getHours(), 2, '0') + ";
    case "i":
        return "String.leftPad(this.getMinutes(), 2, '0') + ";
    case "s":
        return "String.leftPad(this.getSeconds(), 2, '0') + ";
    case "O":
        return "this.getGMTOffset() + ";
    case "T":
        return "this.getTimezone() + ";
    case "Z":
        return "(this.getTimezoneOffset() * -60) + ";
    default:
        return "'" + String.escape(character) + "' + ";
    }
}

Date.parseDate = function(input, format) {
    if (Date.parseFunctions[format] == null) {
        Date.createParser(format);
    }
    var func = Date.parseFunctions[format];
    return Date[func](input);
}

Date.createParser = function(format) {
    var funcName = "parse" + Date.parseFunctions.count++;
    var regexNum = Date.parseRegexes.length;
    var currentGroup = 1;
    Date.parseFunctions[format] = funcName;

    var code = "Date." + funcName + " = function(input){\n"
        + "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n"
        + "var d = new Date();\n"
        + "y = d.getFullYear();\n"
        + "m = d.getMonth();\n"
        + "d = d.getDate();\n"
        + "var results = input.match(Date.parseRegexes[" + regexNum + "]);\n"
        + "if (results && results.length > 0) {"
    var regex = "";

    var special = false;
    var ch = '';
    for (var i = 0; i < format.length; ++i) {
        ch = format.charAt(i);
        if (!special && ch == "\\") {
            special = true;
        }
        else if (special) {
            special = false;
            regex += String.escape(ch);
        }
        else {
            obj = Date.formatCodeToRegex(ch, currentGroup);
            currentGroup += obj.g;
            regex += obj.s;
            if (obj.g && obj.c) {
                code += obj.c;
            }
        }
    }

    code += "if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"
        + "{return new Date(y, m, d, h, i, s);}\n"
        + "else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"
        + "{return new Date(y, m, d, h, i);}\n"
        + "else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"
        + "{return new Date(y, m, d, h);}\n"
        + "else if (y > 0 && m >= 0 && d > 0)\n"
        + "{return new Date(y, m, d);}\n"
        + "else if (y > 0 && m >= 0)\n"
        + "{return new Date(y, m);}\n"
        + "else if (y > 0)\n"
        + "{return new Date(y);}\n"
        + "}return null;}";

    Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$");
    eval(code);
}

Date.formatCodeToRegex = function(character, currentGroup) {
    switch (character) {
    case "D":
        return {g:0,
        c:null,
        s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};
    case "j":
    case "d":
        return {g:1,
            c:"d = parseInt(results[" + currentGroup + "], 10);\n",
            s:"(\\d{1,2})"};
    case "l":
        return {g:0,
            c:null,
            s:"(?:" + Date.dayNames.join("|") + ")"};
    case "S":
        return {g:0,
            c:null,
            s:"(?:st|nd|rd|th)"};
    case "w":
        return {g:0,
            c:null,
            s:"\\d"};
    case "z":
        return {g:0,
            c:null,
            s:"(?:\\d{1,3})"};
    case "W":
        return {g:0,
            c:null,
            s:"(?:\\d{2})"};
    case "F":
        return {g:1,
            c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "].substring(0, 3)], 10);\n",
            s:"(" + Date.monthNames.join("|") + ")"};
    case "M":
        return {g:1,
            c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "]], 10);\n",
            s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};
    case "n":
    case "m":
        return {g:1,
            c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n",
            s:"(\\d{1,2})"};
    case "t":
        return {g:0,
            c:null,
            s:"\\d{1,2}"};
    case "L":
        return {g:0,
            c:null,
            s:"(?:1|0)"};
    case "Y":
        return {g:1,
            c:"y = parseInt(results[" + currentGroup + "], 10);\n",
            s:"(\\d{4})"};
    case "y":
        return {g:1,
            c:"var ty = parseInt(results[" + currentGroup + "], 10);\n"
                + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
            s:"(\\d{1,2})"};
    case "a":
        return {g:1,
            c:"if (results[" + currentGroup + "] == 'am') {\n"
                + "if (h == 12) { h = 0; }\n"
                + "} else { if (h < 12) { h += 12; }}",
            s:"(am|pm)"};
    case "A":
        return {g:1,
            c:"if (results[" + currentGroup + "] == 'AM') {\n"
                + "if (h == 12) { h = 0; }\n"
                + "} else { if (h < 12) { h += 12; }}",
            s:"(AM|PM)"};
    case "g":
    case "G":
    case "h":
    case "H":
        return {g:1,
            c:"h = parseInt(results[" + currentGroup + "], 10);\n",
            s:"(\\d{1,2})"};
    case "i":
        return {g:1,
            c:"i = parseInt(results[" + currentGroup + "], 10);\n",
            s:"(\\d{2})"};
    case "s":
        return {g:1,
            c:"s = parseInt(results[" + currentGroup + "], 10);\n",
            s:"(\\d{2})"};
    case "O":
        return {g:0,
            c:null,
            s:"[+-]\\d{4}"};
    case "T":
        return {g:0,
            c:null,
            s:"[A-Z]{3}"};
    case "Z":
        return {g:0,
            c:null,
            s:"[+-]\\d{1,5}"};
    default:
        return {g:0,
            c:null,
            s:String.escape(character)};
    }
}

Date.prototype.getTimezone = function() {
    return this.toString().replace(
        /^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace(
        /^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");
}

Date.prototype.getGMTOffset = function() {
    return (this.getTimezoneOffset() > 0 ? "-" : "+")
        + String.leftPad(Math.floor(this.getTimezoneOffset() / 60), 2, "0")
        + String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
}

Date.prototype.getDayOfYear = function() {
    var num = 0;
    Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
    for (var i = 0; i < this.getMonth(); ++i) {
        num += Date.daysInMonth[i];
    }
    return num + this.getDate() - 1;
}

Date.prototype.getWeekOfYear = function() {
    // Skip to Thursday of this week
    var now = this.getDayOfYear() + (4 - this.getDay());
    // Find the first Thursday of the year
    var jan1 = new Date(this.getFullYear(), 0, 1);
    var then = (7 - jan1.getDay() + 4);
    document.write(then);
    return String.leftPad(((now - then) / 7) + 1, 2, "0");
}

Date.prototype.isLeapYear = function() {
    var year = this.getFullYear();
    return ((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
}

Date.prototype.getFirstDayOfMonth = function() {
    var day = (this.getDay() - (this.getDate() - 1)) % 7;
    return (day < 0) ? (day + 7) : day;
}

Date.prototype.getLastDayOfMonth = function() {
    var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
    return (day < 0) ? (day + 7) : day;
}

Date.prototype.getDaysInMonth = function() {
    Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
    return Date.daysInMonth[this.getMonth()];
}

Date.prototype.getSuffix = function() {
    switch (this.getDate()) {
        case 1:
        case 21:
        case 31:
            return "st";
        case 2:
        case 22:
            return "nd";
        case 3:
        case 23:
            return "rd";
        default:
            return "th";
    }
}

String.escape = function(string) {
    return string.replace(/('|\\)/g, "\\$1");
}

String.leftPad = function (val, size, ch) {
    var result = new String(val);
    if (ch == null) {
        ch = " ";
    }
    while (result.length < size) {
        result = ch + result;
    }
    return result;
}

Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
Date.monthNames =
   ["January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"];
Date.dayNames =
   ["Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"];
Date.y2kYear = 50;
Date.monthNumbers = {
    Jan:0,
    Feb:1,
    Mar:2,
    Apr:3,
    May:4,
    Jun:5,
    Jul:6,
    Aug:7,
    Sep:8,
    Oct:9,
    Nov:10,
    Dec:11};
Date.patterns = {
    ISO8601LongPattern:"Y-m-d H:i:s",
    ISO8601ShortPattern:"Y-m-d",
    ShortDatePattern: "n/j/Y",
    LongDatePattern: "l, F d, Y",
    FullDateTimePattern: "l, F d, Y g:i:s A",
    MonthDayPattern: "F d",
    ShortTimePattern: "g:i A",
    LongTimePattern: "g:i:s A",
    SortableDateTimePattern: "Y-m-d\\TH:i:s",
    UniversalSortableDateTimePattern: "Y-m-d H:i:sO",
    YearMonthPattern: "F, Y"};



/******************************************************************************
 * portal_resources/datechooser.js                                                   *
 ******************************************************************************/

/*
 * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, version 2.1.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * $Revision: 1.1 $
 */

// Shows or hides the date chooser on the page
function showChooser(obj, inputId, divId, start, end, format, isTimeChooser) {
    if (document.getElementById) {
        var input = document.getElementById(inputId);
        var div = document.getElementById(divId);
        if (input !== undefined && div !== undefined) {
            if (input.DateChooser === undefined) {
                input.DateChooser = new DateChooser(input, div, start, end, format, isTimeChooser);
            }
            input.DateChooser.setDate(Date.parseDate(input.value, format));
            if (input.DateChooser.isVisible()) {
                input.DateChooser.hide();
            }
            else {
                input.DateChooser.show();
            }
        }
    }
}

// Sets a date on the object attached to 'inputId'
function dateChooserSetDate(inputId, value) {
    var input = document.getElementById(inputId);
    if (input !== undefined && input.DateChooser !== undefined) {
        input.DateChooser.setDate(Date.parseDate(value, input.DateChooser._format));
        if (input.DateChooser.isTimeChooser()) {
            var theForm = input.form;
            var prefix = input.DateChooser._prefix;
            input.DateChooser.setTime(
                parseInt(theForm.elements[prefix + 'hour'].options[
                    theForm.elements[prefix + 'hour'].selectedIndex].value)
                    + parseInt(theForm.elements[prefix + 'ampm'].options[
                    theForm.elements[prefix + 'ampm'].selectedIndex].value),
                parseInt(theForm.elements[prefix + 'min'].options[
                    theForm.elements[prefix + 'min'].selectedIndex].value));
        }
        input.value = input.DateChooser.getValue();
        input.DateChooser.hide();
    }
}

// The callback function for when someone changes the pulldown menus on the date
// chooser
function dateChooserDateChange(theForm, prefix) {
    var input = document.getElementById(
        theForm.elements[prefix + 'inputId'].value);
    var newDate = new Date(
        theForm.elements[prefix + 'year'].options[
            theForm.elements[prefix + 'year'].selectedIndex].value,
        theForm.elements[prefix + 'month'].options[
            theForm.elements[prefix + 'month'].selectedIndex].value,
        1);
    // Try to preserve the day of month (watch out for months with 31 days)
    newDate.setDate(Math.max(1, Math.min(newDate.getDaysInMonth(),
                    input.DateChooser._date.getDate())));
    input.DateChooser.setDate(newDate);
    if (input.DateChooser.isTimeChooser()) {
        input.DateChooser.setTime(
            parseInt(theForm.elements[prefix + 'hour'].options[
                theForm.elements[prefix + 'hour'].selectedIndex].value)
                + parseInt(theForm.elements[prefix + 'ampm'].options[
                theForm.elements[prefix + 'ampm'].selectedIndex].value),
            parseInt(theForm.elements[prefix + 'min'].options[
                theForm.elements[prefix + 'min'].selectedIndex].value));
    }
    input.DateChooser.show();
}

// Gets the absolute position on the page of the element passed in
function getAbsolutePosition(obj) {
    var result = [0, 0];
    while (obj != null) {
        result[0] += obj.offsetTop;
        result[1] += obj.offsetLeft;
        obj = obj.offsetParent;
    }
    return result;
}

// DateChooser constructor
function DateChooser(input, div, start, end, format, isTimeChooser) {
    this._input = input;
    this._div = div;
    this._start = start;
    this._end = end;
    this._format = format;
    this._date = new Date();
    this._isTimeChooser = isTimeChooser;
    // Choose a random prefix for all pulldown menus
    this._prefix = "";
    var letters = ["a", "b", "c", "d", "e", "f", "h", "i", "j", "k", "l",
        "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
    for (var i = 0; i < 10; ++i) {
        this._prefix += letters[Math.floor(Math.random() * letters.length)];
    }
}

// DateChooser prototype variables
DateChooser.prototype._isVisible = false;

// Returns true if the chooser is currently visible
DateChooser.prototype.isVisible = function() {
    return this._isVisible;
}

// Returns true if the chooser is to allow choosing the time as well as the date
DateChooser.prototype.isTimeChooser = function() {
    return this._isTimeChooser;
}

// Gets the value, as a formatted string, of the date attached to the chooser
DateChooser.prototype.getValue = function() {
    return this._date.dateFormat(this._format);
}

// Hides the chooser
DateChooser.prototype.hide = function() {
    this._div.style.visibility = "hidden";
    this._div.style.display = "none";
    this._div.innerHTML = "";
    this._isVisible = false;
}

// Shows the chooser on the page
DateChooser.prototype.show = function() {
    // calculate the position before making it visible
    var inputPos = getAbsolutePosition(this._input);
    this._div.style.top = (inputPos[0] + this._input.offsetHeight) + "px";
    this._div.style.left = (inputPos[1] + this._input.offsetWidth) + "px";
    this._div.innerHTML = this.createChooserHtml();
    this._div.style.display = "block";
    this._div.style.visibility = "visible";
    this._div.style.position = "absolute";
    this._isVisible = true;
}

// Sets the date to what is in the input box
DateChooser.prototype.initializeDate = function() {
    if (this._input.value != null && this._input.value != "") {
        this._date = Date.parseDate(this._input.value, this._format);
    }
    else {
        this._date = new Date();
    }
}

// Sets the date attached to the chooser
DateChooser.prototype.setDate = function(date) {
    this._date = date ? date : new Date();
}

// Sets the time portion of the date attached to the chooser
DateChooser.prototype.setTime = function(hour, minute) {
    this._date.setHours(hour);
    this._date.setMinutes(minute);
}

// Creates the HTML for the whole chooser
DateChooser.prototype.createChooserHtml = function() {
    var formHtml = "<input type=\"hidden\" name=\""
        + this._prefix + "inputId\" value=\""
        + this._input.getAttribute('id') + "\">"
        + "\r\n  <select name=\"" + this._prefix 
        + "month\" onChange=\"dateChooserDateChange(this.form, '"
        + this._prefix + "');\">";
    for (var monIndex = 0; monIndex <= 11; monIndex++) {
        formHtml += "\r\n    <option value=\"" + monIndex + "\""
            + (monIndex == this._date.getMonth() ? " selected=\"1\"" : "")
            + ">" + Date.monthNames[monIndex] + "</option>";
    }
    formHtml += "\r\n  </select>\r\n  <select name=\""
        + this._prefix + "year\" onChange=\"dateChooserDateChange(this.form, '"
        + this._prefix + "');\">";
    for (var i = this._start; i <= this._end; ++i) {
        formHtml += "\r\n    <option value=\"" + i + "\""
            + (i == this._date.getFullYear() ? " selected=\"1\"" : "")
            + ">" + i + "</option>";
    }
    formHtml += "\r\n  </select>";
    formHtml += this.createCalendarHtml();
    if (this._isTimeChooser) {
        formHtml += this.createTimeChooserHtml();
    }
    return formHtml;
}

// Creates the extra HTML needed for choosing the time
DateChooser.prototype.createTimeChooserHtml = function() {
    // Add hours
    var result = "\r\n  <select name=\"" + this._prefix + "hour\">";
    for (var i = 0; i < 12; ++i) {
        result += "\r\n    <option value=\"" + i + "\""
            + (((this._date.getHours() % 12) == i) ? " selected=\"1\">" : ">")
            + i + "</option>";
    }
    // Add extra entry for 12:00
    result += "\r\n    <option value=\"0\">12</option>";
    result += "\r\n  </select>";
    // Add minutes
    result += "\r\n  <select name=\"" + this._prefix + "min\">";
    for (var i = 0; i < 60; i += 15) {
        result += "\r\n    <option value=\"" + i + "\""
            + ((this._date.getMinutes() == i) ? " selected=\"1\">" : ">")
            + String.leftPad(i, 2, '0') + "</option>";
    }
    result += "\r\n  </select>";
    // Add AM/PM
    result += "\r\n  <select name=\"" + this._prefix + "ampm\">";
    result += "\r\n    <option value=\"0\""
        + (this._date.getHours() < 12 ? " selected=\"1\">" : ">")
        + "AM</option>";
    result += "\r\n    <option value=\"12\""
        + (this._date.getHours() >= 12 ? " selected=\"1\">" : ">")
        + "PM</option>";
    result += "\r\n  </select>";
    return result;
}

// Creates the HTML for the actual calendar part of the chooser
DateChooser.prototype.createCalendarHtml = function() {
    var result = "\r\n<table cellspacing=\"0\" class=\"dateChooser\">"
        + "\r\n  <tr><th>S</th><th>M</th><th>T</th>"
        + "<th>W</th><th>T</th><th>F</th><th>S</th></tr>\r\n  <tr>";
    // Fill up the days of the week until we get to the first day of the month
    var firstDay = this._date.getFirstDayOfMonth();
    var lastDay = this._date.getLastDayOfMonth();
    if (firstDay != 0) {
        result += "<td colspan=\"" + firstDay + "\">&nbsp;</td>";
    }
    // Fill in the days of the month
    var i = 0;
    while (i < this._date.getDaysInMonth()) {
        if (((i++ + firstDay) % 7) == 0) {
            result += "</tr>\r\n  <tr>";
        }
        var thisDay = new Date(
            this._date.getFullYear(),
            this._date.getMonth(), i);
        var js = '"dateChooserSetDate(\''
            + this._input.getAttribute('id') + "', '"
            + thisDay.dateFormat(this._format) + '\');"'
        result += "\r\n    <td class=\"dateChooserActive"
            // If the date is the currently chosen date, highlight it
            + (i == this._date.getDate() ? " dateChooserActiveToday" : "")
            + "\" onClick=" + js + ">" + i + "</td>";
    }
    // Fill in any days after the end of the month
    if (lastDay != 6) {
        result += "<td colspan=\"" + (6 - lastDay) + "\">&nbsp;</td>";
    }
    return result + "\r\n  </tr>\r\n</table><!--[if lte IE 6.5]><iframe></iframe><![endif]-->";
}


/******************************************************************************
 * portal_resources/fundfinder.js                                             *
 ******************************************************************************/

firstResultVar = "";
lastResultVar = "";
sortFieldVar = "";
sortTypeVar = "";
numberOfPageLinksVar = "";
dropdownDefaultVar = "---";
subAssetclassTempVar = "";
nameFieldVar = "";

function initFundfinderVars(firstResult, lastResult, sortField, sortType, numberOfPageLinks, nameField) {
  firstResultVar = firstResult;
  lastResultVar = lastResult;
  sortFieldVar = sortField;
  nameFieldVar = nameField;
  sortTypeVar = sortType;
  numberOfPageLinksVar = numberOfPageLinks;
}

function executeQuery(ajaxPageURL, siteCode, langCode, typeCode, baseURL, firstResult, lastResult, sortField, sortType) {
  if (firstResult != "") firstResultVar = firstResult;
  if (lastResult != "") lastResultVar = lastResult;
  if (sortField != "") sortFieldVar = sortField;
  if (sortType != "") sortTypeVar = sortType;
  var request = ajaxPageURL + 'url=' + escapeAutnUrl(getConcatenatedDataURLString(siteCode, langCode, typeCode, baseURL, firstResult, lastResult, sortField, sortType)) + '&view=' + getView() + '&pageLinks=' + (numberOfPageLinksVar!="" ? numberOfPageLinksVar : '10');
  var xhr = getXmlHttpRequest();
  xhr.onreadystatechange = function() {
    if(xhr.readyState==4){
      var page = xhr.responseText;
      var number1 = page.substring(page.indexOf("[NUMBERSTART]")+13,page.indexOf("[NUMBEREND]"));
      var span1 = document.getElementById('numberOfResults');
      span1.innerHTML = (number1==''?'0':number1);
      var number2 = page.substring(page.indexOf("[RANGESTART]")+12,page.indexOf("[RANGEEND]"));
      var span2 = document.getElementById('rangeOfResults');
      span2.innerHTML = (number2==''?'0 - 0':number2);
      var content = page.substring(page.indexOf("[CONTENTSTART]")+14,page.indexOf("[CONTENTEND]"));
      var div = document.getElementById('resultTableDiv');
      div.innerHTML = content;
      //changeDisclaimerViewTo(getView());
    }
  }
  xhr.open("GET", request, true);
  xhr.send(null);
}

function getView() {
  return document.getElementById('viewSelect').value;
}

/*function changeDisclaimerViewTo(viewId) {
	document.getElementById('disclaimer_v1').style.display = "none";
	document.getElementById('disclaimer_v2').style.display = "none";
	document.getElementById('disclaimer_v3').style.display = "none";
	document.getElementById('disclaimer_v4').style.display = "none";
	document.getElementById('disclaimer_' + viewId).style.display = "block";
}*/

function escapeAutnUrl(urlString) {
  return escape(urlString.replace(/&/g,"@"));
}

function getConcatenatedDataURLString(siteCode, langCode, typeCode, baseURL, firstResult, lastResult, sortField, sortType) {
  var name = document.getElementById('nameField').value;
  var assetClass = document.getElementById('assetClassField').value;
  var subAssetClass = document.getElementById('subAssetClassField').value;
  var risk1 = document.getElementById('risk1Field').checked;
  var risk2 = document.getElementById('risk2Field').checked;
  var risk3 = document.getElementById('risk3Field').checked;
  var risk4 = document.getElementById('risk4Field').checked;
  var risk5 = document.getElementById('risk5Field').checked;
  var rating1 = document.getElementById('rating1Field').checked;
  var rating2 = document.getElementById('rating2Field').checked;
  var rating3 = document.getElementById('rating3Field').checked;
  var rating4 = document.getElementById('rating4Field').checked;
  var rating5 = document.getElementById('rating5Field').checked;
  var rating6 = document.getElementById('rating6Field').checked;
  var currency = document.getElementById('currencyField').value;
  var shareClass = document.getElementById('shareClassField').value;
  var policy = document.getElementById('policyField').value;
  
  var concatenatedDataURLString = "";
  
  var pagingString = "&start=" + firstResultVar + "&maxresults=" + lastResultVar;
  
  var sortString = "&sort=" + sortFieldVar + ":" + sortTypeVar;
  
  if (langCode != "" || siteCode != "" || typeCode != "") {
    if (langCode != "") {
      concatenatedDataURLString = "&fieldtext=";
      concatenatedDataURLString += "MATCH{" + langCode + "}:LANGUAGE";
      first = true;
    }
    if (siteCode != "") {
      if (concatenatedDataURLString == "") {
        concatenatedDataURLString = "&fieldtext=";
      } else {
        concatenatedDataURLString += " AND ";
      }
      concatenatedDataURLString += "MATCH{" + siteCode + "}:COUNTRY";
      first = true;
    }
    if (typeCode != "") {
      if (concatenatedDataURLString == "") {
        concatenatedDataURLString = "&fieldtext=";
      } else {
        concatenatedDataURLString += " AND ";
      }
      concatenatedDataURLString += "MATCH{" + typeCode + "}:CLIENT_TYPE";
    }
  }
  if (name != "") {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "&fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    concatenatedDataURLString += "WILD{*" + name + "*}:" + nameFieldVar + ":ISIN_CODE";
  }
  if (assetClass != "" && assetClass != dropdownDefaultVar) {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "&fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    concatenatedDataURLString += "MATCH{" + assetClass + "}:ASSET_CLASS";
  }
  if (subAssetClass != "" && subAssetClass != dropdownDefaultVar && subAssetclassTempVar != dropdownDefaultVar) {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "&fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    concatenatedDataURLString += "MATCH{" + subAssetClass + "}:SUB_ASSET_CLASS";
  }
  subAssetclassTempVar = "";
  if (risk1 || risk2 || risk3 || risk4 || risk5 ) {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "&fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    var riskTemp = (risk1?"1,":"") + (risk2?"2,":"") + (risk3?"3,":"") + (risk4?"4,":"") + (risk5?"5,":"");
    riskTemp = riskTemp.substring(0,riskTemp.length-1);
    concatenatedDataURLString += "MATCH{" + riskTemp + "}:RISK";
  }
  if (rating1 || rating2 || rating3 || rating4 || rating5 || rating6 ) {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "&fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    var ratingsTemp = (rating1?"!!!,---,":"") + (rating2?"*,":"") + (rating3?"**,":"") + (rating4?"***,":"") + (rating5?"****,":"") + (rating6?"*****,":"");
    if (ratingsTemp.length > 0) {
      ratingsTemp = ratingsTemp.substring(0,ratingsTemp.length-1);
    }
    concatenatedDataURLString += "MATCH{" + ratingsTemp + "}:RATINGS";
  }
  if (currency != "" && currency != dropdownDefaultVar) {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "&fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    concatenatedDataURLString += "MATCH{" + currency + "}:BASE_CURRENCY";
  }
  if (shareClass != "" && shareClass != dropdownDefaultVar) {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "&fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    concatenatedDataURLString += "MATCH{" + shareClass + "}:SHARE_CLASS";
  }
  if (policy != "" && policy != dropdownDefaultVar) {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "&fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    concatenatedDataURLString += "MATCH{" + policy + "}:SHARE_CATEGORY";
  }
  return "" + baseURL + pagingString + sortString + concatenatedDataURLString;
}

function executeSubAssetClassQuery(ajaxPage, subAssetClassURL, siteCode, langCode, typeCode, dropdownDefault, selectedSubAssetClass) {
  var request = ajaxPage + 'url=' + escapeAutnUrl(getConcatenatedSubAssetClassDataURLString(siteCode, langCode, typeCode, subAssetClassURL));
  var xhr = getXmlHttpRequest();
  xhr.onreadystatechange = function() {
    var assetClassValue = document.getElementById('assetClassField').value;
    var subAssetClassField = document.getElementById('subAssetClassField');
    var target = document.getElementById('subAssetClassTarget');
    if (assetClassValue != "---") {
      if(xhr.readyState==4){
        var page = xhr.responseText;
        var content = page.substring(page.indexOf("[CONTENTSTART]")+14,page.indexOf("[CONTENTEND]"));
        target.innerHTML = content;
        var subAssetClassOptions = document.getElementById("subAssetClassField").childNodes;
        for (var i=0; i<subAssetClassOptions.length; i++) {
          if (subAssetClassOptions[i].value == selectedSubAssetClass) {
            subAssetClassOptions[i].selected = "selected";
          }
        }
        subAssetClassField.disabled = "false";
      }
    } else {
      target.innerHTML = "<select name='subAssetClass' id='subAssetClassField' disabled='disabled'><option value='---' selected='selected'>" + dropdownDefault + "</option></select>";
      //subAssetClassField.disabled = "disabled";
    }
  }
  xhr.open("GET", request, true);
  xhr.send(null);
}

function getConcatenatedSubAssetClassDataURLString(siteCode, langCode, typeCode, subAssetClassURL) {
  var site = siteCode;
  var lang = langCode;
  var type = typeCode;
  var base = subAssetClassURL;
  var assetClass = document.getElementById('assetClassField').value;
  var concatenatedDataURLString = "";
  
  if (lang != "" || site != "" || type != "") {
    if (lang != "") {
      concatenatedDataURLString = "fieldtext=";
      concatenatedDataURLString += "MATCH{" + lang + "}:LANGUAGE";
      first = true;
    }
    if (site != "") {
      if (concatenatedDataURLString == "") {
        concatenatedDataURLString = "fieldtext=";
      } else {
        concatenatedDataURLString += " AND ";
      }
      concatenatedDataURLString += "MATCH{" + site + "}:COUNTRY";
      first = true;
    }
    if (type != "") {
      if (concatenatedDataURLString == "") {
        concatenatedDataURLString = "fieldtext=";
      } else {
        concatenatedDataURLString += " AND ";
      }
      concatenatedDataURLString += "MATCH{" + type + "}:CLIENT_TYPE";
    }
  }
  if (assetClass != "") {
    if (concatenatedDataURLString == "") {
      concatenatedDataURLString = "fieldtext=";
    } else {
      concatenatedDataURLString += " AND ";
    }
    concatenatedDataURLString += "MATCH{" + assetClass + "}:ASSET_CLASS";
  }
  return "" + base + concatenatedDataURLString;
}


/******************************************************************************
 * portal_resources/header.js                                                        *
 ******************************************************************************/

function setCookie(name, content, days){
	days = days || 365;
	var now = new Date();
	var exp = new Date(now.getTime() + days*24*60*60*1000);
	document.cookie = escape(name) + "=" + escape(content) + "; expires=" + exp.toGMTString() + "; path=/";
}

function deleteCookie(name){
	setCookie(name, "", -1);
}

function readCookie(name){
	var search = name + "=";
	if(document.cookie.length > 0){
		var pos = document.cookie.indexOf(search);
		if(pos != -1){
			pos += search.length;
			var end = document.cookie.indexOf(";", pos);
			if(end == -1){
				end = document.cookie.length;
			}
			return unescape(document.cookie.substring(pos, end));
		}
	}
	return "";
}

function URLForward (input) {
  var urlp = input.href.split("?");

  if(urlp.length > 1) {
    var myParams = urlp[1].split("&");
    for(var i = 0; i < myParams.length; i++){
      var singleParam = myParams[i].split("=");
      setCookie(singleParam[0], singleParam[1], 365 );
    }
  }
  
  var strTarget = "";
  
  if (input.name === "country") {
  	strTarget = "/";
  } else if (input.name === "language") {
  	strTarget = addOrReplaceUrlParam (window.location.href, "lang", readCookie("lang"));
  	strTarget = addOrReplaceUrlParam (window.location.href, "language", readCookie("lang").toUpperCase());
  } else {
  	strTarget = addOrReplaceUrlParam (window.location.href, "type", readCookie("type"));
  }
  
  window.location = strTarget;
  return false;
  //return true;
}

function addOrReplaceUrlParam (strUrl, strParamName, strValue) {
  var strToReturn = "";
  var reMatch = new RegExp ("([?&]{1})" + strParamName + "=([\\w]{2,})");
  
  if (strUrl.match (reMatch)) { strToReturn = replaceUrlParam (strUrl, strParamName, strValue); }
  else { strToReturn = addUrlParam (strUrl, strParamName, strValue); }
  
  return strToReturn;
}

function replaceUrlParam (strUrl, strParamName, strValue) {
  var strToReturn = "";
  var reMatch = new RegExp ("([?&]{1})" + strParamName + "=([\\w]{2,})");
  var aMatches = reMatch.exec (strUrl);
  
  var strSeparator = aMatches[1];
  var strReplacement = strSeparator + strParamName + "=" + strValue;
  
  strToReturn = strUrl.replace (reMatch, strReplacement);
    
  return strToReturn;
}

function addUrlParam (strUrl, strParamName, strValue) {
  var strSeparator = (strUrl.indexOf ("?") == -1 ? "?" : "&");
  return (strUrl + strSeparator + strParamName + "=" + strValue); 
}

/*startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		if(navRoot !== null) {
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}
window.onload=startList;*/



/******************************************************************************
 * portal_resources/AC_RunActiveContent.js                                           *
 ******************************************************************************/

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

/******************************************************************************
 * portal_resources/swfobject.js  																										*
 ******************************************************************************/

/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();


/******************************************************************************
 * portal_resources/tableH.js  //tablerow highlighting for fundfinder         *
 ******************************************************************************/

// F. Permadi 2005.
// Highlights table row
// Copyright (C) F. Permadi
// This code is provided "as is" and without warranty of any kind.  Use at your own risk.

// These variables are for saving the original background colors
var savedStates=new Array();
var savedStateCount=0;

// This function takes an element as a parameter and 
//   returns an object which contain the saved state
//   of the element's background color.
function saveBackgroundStyle(myElement)
{
  saved=new Object();
  saved.element=myElement;
  saved.className=myElement.className;
  saved.backgroundColor=myElement.style["backgroundColor"];
  return saved;   
}

// This function takes an element as a parameter and 
//   returns an object which contain the saved state
//   of the element's background color.
function restoreBackgroundStyle(savedState)
{
  savedState.element.style["backgroundColor"]=savedState.backgroundColor;
  //if (savedState.className)
  //{
    savedState.element.className=savedState.className;    
  //}
}

// This function is used by highlightTableRow() to find table cells (TD) node
function findNode(startingNode, tagName)
{
  // on Firefox, the TD node might not be the firstChild node of the TR node
  myElement=startingNode;
  var i=0;
  while (myElement && (!myElement.tagName || (myElement.tagName && myElement.tagName!=tagName)))
  {
    myElement=startingNode.childNodes[i];
    i++;
  }  
  if (myElement && myElement.tagName && myElement.tagName==tagName)
  {
    return myElement;
  }
  // on IE, the TD node might be the firstChild node of the TR node  
  else if (startingNode.firstChild)
    return findNode(startingNode.firstChild, tagName);
  return 0;
}

// Highlight table row.
// newElement could be any element nested inside the table
// highlightClass is the color of the highlight
function highlightTableRow(myElement, highlightClass)
{
  var i=0;
  // Restore color of the previously highlighted row
  for (i; i<savedStateCount; i++)
  {
    restoreBackgroundStyle(savedStates[i]);          
  }
  savedStateCount=0;

  // To get the node to the row (ie: the <TR> element), 
  // we need to traverse the parent nodes until we get a row element (TR)
  // Netscape has a weird node (if the mouse is over a text object, then there's no tagName
  while (myElement && ((myElement.tagName && myElement.tagName!="TR") || !myElement.tagName))
  {
    myElement=myElement.parentNode;
  }

  // If you don't want a particular row to be highlighted, set it's id to "header"
  // If you don't want a particular row to be highlighted, set it's id to "header"
  if (!myElement || (myElement && myElement.id && myElement.id=="header") )
    return;
		  
  // Highlight every cell on the row
  if (myElement)
  {
    var tableRow=myElement;
    
    // Save the backgroundColor style OR the style class of the row (if defined)
    if (tableRow)
    {
	  savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
      savedStateCount++;
    }

    // myElement is a <TR>, then find the first TD
    var tableCell=findNode(myElement, "TD");    

    var i=0;
    // Loop through every sibling (a sibling of a cell should be a cell)
    // We then highlight every siblings
    while (tableCell)
    {
      // Make sure it's actually a cell (a TD)
      if (tableCell.tagName=="TD")
      {
        // If no style has been assigned, assign it, otherwise Netscape will 
        // behave weird.
        if (!tableCell.style)
        {
          tableCell.style={};
        }
        else
        {
          savedStates[savedStateCount]=saveBackgroundStyle(tableCell);        
          savedStateCount++;
        }
        // Assign the highlight color
        //tableCell.style["backgroundColor"]=highlightClass;
        tableCell.className = highlightClass;

        // Optional: alter cursor
        tableCell.style.cursor='default';
        i++;
      }
      // Go to the next cell in the row
      tableCell=tableCell.nextSibling;
    }
  }
}

// This function is to be assigned to a <table> mouse event handler.
// If the element that fired the event is within a table row,
//   this function will highlight the row.
function trackTableHighlight(mEvent, highlightClass)
{
  if (!mEvent)
    mEvent=window.event;
		
  // Internet Explorer
  if (mEvent.srcElement)
  {
    highlightTableRow( mEvent.srcElement, highlightClass);
  }
  // Netscape and Firefox
  else if (mEvent.target)
  {
    highlightTableRow( mEvent.target, highlightClass);		
  }
}

// Highlight table row.
// newElement could be any element nested inside the table
// highlightClass is the color of the highlight
function highlightTableRowVersionA(myElement, highlightClass)
{
  var i=0;
  // Restore color of the previously highlighted row
  for (i; i<savedStateCount; i++)
  {
    restoreBackgroundStyle(savedStates[i]);
  }
  savedStateCount=0;

  // If you don't want a particular row to be highlighted, set it's id to "header"
  if (!myElement || (myElement && myElement.id && myElement.id=="header") )
    return;
		  
  // Highlight every cell on the row
  if (myElement)
  {
    var tableRow=myElement;
    
    // Save the backgroundColor style OR the style class of the row (if defined)
    if (tableRow)
    {
	  savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
      savedStateCount++;
    }

    // myElement is a <TR>, then find the first TD
    var tableCell=findNode(myElement, "TD");    

    var i=0;
    // Loop through every sibling (a sibling of a cell should be a cell)
    // We then highlight every siblings
    while (tableCell)
    {
      // Make sure it's actually a cell (a TD)
      if (tableCell.tagName=="TD")
      {
        // If no style has been assigned, assign it, otherwise Netscape will 
        // behave weird.
        if (!tableCell.style)
        {
          tableCell.style={};
        }
        else
        {
          savedStates[savedStateCount]=saveBackgroundStyle(tableCell);        
          savedStateCount++;
        }
        // Assign the highlight color
        //tableCell.style["backgroundColor"]=highlightClass;
        tableCell.className = highlightClass;

        // Optional: alter cursor
        tableCell.style.cursor='default';
        i++;
      }
      // Go to the next cell in the row
      tableCell=tableCell.nextSibling;
    }
  }
}

function changeDetailsView(select) {
  changeDetailsViewTo(select.value, select.id);
}

function changeDetailsViewTo(view, selectId) {
  document.getElementById('view_overview').style.display = "none";
  document.getElementById('view_details').style.display = "none";
  document.getElementById('view_downloads').style.display = "none";
  var options = document.getElementById(selectId).getElementsByTagName('option');
  for (var i=0; i<options.length; i++) {
    if (options[i].value == view) {
      options[i].selected = 'selected';
    }
  }
  if (view == 'view_downloads') {
    if (document.getElementById('keyfactssubdocuments')) {
      document.getElementById('keyfactssubdocuments').style.display = "none";
    }
    document.getElementById('documentLinks').style.display = "none";
  } else {
    if (document.getElementById('keyfactssubdocuments')) {
      document.getElementById('keyfactssubdocuments').style.display = "block";
    }
    document.getElementById('documentLinks').style.display = "block";
  }
  document.getElementById(view).style.display = "block";
}

function download(link,selectId) {
  //link.href=document.getElementById(selectId).value;
  var myDate =  new Date();
  var url = document.getElementById(selectId).value;
  var temp = "https://nl.sitestat.com/abnamro/abnamro-am/s?fim" + readCookie('site') + "." + readCookie('lang') + "." + url.substring(url.lastIndexOf("/") + 1) + "@hmresults.com&ns_type=pdf&ns__t=" + myDate.getTime() + "&ns_url=" + url;
  link.href=temp;
  link.target="_blank";
  return true;
}

function redrawGraph(containerId, embedId, formId, flashvarsBaseURL, useLegalName) {
  var flashvarsString = flashvarsBaseURL;
  var elCompare = document.getElementById('compareField');
  if (elCompare) { flashvarsString += "%26compareid=" + elCompare.value; }
  else { flashvarsString += "%26compareid=0"; }

  flashvarsString += "%26uselegalname=" + useLegalName;
  flashvarsString += "%26start_date=" + document.getElementById('beginDateField').value;
  flashvarsString += "%26end_date=" + document.getElementById('endDateField').value;
  flashvarsString += "%26interval=" + document.getElementById('intervalField').value;
  flashvarsString += "%26currency=" + document.getElementById('currencyField').value;
  document.getElementById(embedId).setAttribute('flashvars', flashvarsString);
  
  var flashGraphCode = document.getElementById(containerId).innerHTML;
  document.getElementById(containerId).innerHTML = "<!--0-->";
  document.getElementById(containerId).innerHTML = flashGraphCode;
}