//Statement will not run these lines to avoid javascript error.
if(window.runInclude != false){

	document.write('<script language="javascript" src="bank_folder/app_settings.js"></script>');
	document.write('<script language="javascript" src="bank_folder/localized_data.js"></script>');
	document.write('<script language="javascript" src="app_settings.js"></script>');
	document.write('<script language="javascript" src="localized_data.js"></script>');
	document.write('<script language="javascript" src="localized_data_es_US.js"></script>');
	document.write('<script language="javascript" src="bank_folder/localized_data_es_US.js"></script>');
}
var localProperties = "";

function getAppProperty(sProperty, sDefault)
{
var sTemp = '';
var iTemp1 = -1;
var iTemp2 = -1;
var sRC = '';

	//set the return value to the default
	sRC = sDefault;

	// Check if it is in the bank specific properties

	iTemp1=-1
	iTemp2=-1
	iTemp1 = BankAppProperties.indexOf("|" + sProperty + "=");
	if (iTemp1 > -1)
	{
		sTemp = BankAppProperties.substring(iTemp1+1);
		iTemp1 = sTemp.indexOf("=");
		iTemp2 = sTemp.indexOf("|");
		sRC = sTemp.substring(iTemp1+1,iTemp2);
	}
	else
	{
		// Check if it is in the global properties
		iTemp1=-1
		iTemp2=-1
		iTemp1 = GlobalAppProperties.indexOf("|" + sProperty + "=");
		if (iTemp1 > -1)
		{
			sTemp = GlobalAppProperties.substring(iTemp1+1);
			iTemp1 = sTemp.indexOf("=");
			iTemp2 = sTemp.indexOf("|");
			sRC = sTemp.substring(iTemp1+1,iTemp2);
		}
	}

	//replace ^^ with "
	sRC = stringReplace(sRC, '^^','"');

	//replace ^ with '
	sRC = stringReplace(sRC, "^","'");

	//return the result
	return sRC;
}

function getLocalizedProperty(sProperty, sDefault)
{
var sTemp = '';
var iTemp1 = -1;
var iTemp2 = -1;
var sRC = '';

	// Check if it is in the bank specific properties

	if(languages_multiple_enabled=="Y")
	{
		var locale = get_cookie("locale_supported");

		if(locale=="es_US")
		{
			iTemp1=-1
			iTemp2=-1
			iTemp1 = BankLocalizedSpanishProperties.indexOf("|" + sProperty + "=");
			if (iTemp1 > -1)
			{
				sTemp = BankLocalizedSpanishProperties.substring(iTemp1+1);
				iTemp1 = sTemp.indexOf("=");
				iTemp2 = sTemp.indexOf("|");
				sRC = sTemp.substring(iTemp1+1,iTemp2);
			}
			else
			{
				// Check if it is in the global properties
				iTemp1=-1
				iTemp2=-1
				iTemp1 = GlobalLocalizedSpanishProperties.indexOf("|" + sProperty + "=");
				if (iTemp1 > -1)
				{
					sTemp = GlobalLocalizedSpanishProperties.substring(iTemp1+1);
					iTemp1 = sTemp.indexOf("=");
					iTemp2 = sTemp.indexOf("|");
					sRC = sTemp.substring(iTemp1+1,iTemp2);
				}
			}
		}

		if (sRC == '')
		{
			iTemp1=-1
			iTemp2=-1
			iTemp1 = BankLocalizedProperties.indexOf("|" + sProperty + "=");
			if (iTemp1 > -1)
			{
				sTemp = BankLocalizedProperties.substring(iTemp1+1);
				iTemp1 = sTemp.indexOf("=");
				iTemp2 = sTemp.indexOf("|");
				sRC = sTemp.substring(iTemp1+1,iTemp2);
			}
			else
			{
				// Check if it is in the global properties
				iTemp1=-1
				iTemp2=-1
				iTemp1 = GlobalLocalizedProperties.indexOf("|" + sProperty + "=");
				if (iTemp1 > -1)
				{
					sTemp = GlobalLocalizedProperties.substring(iTemp1+1);
					iTemp1 = sTemp.indexOf("=");
					iTemp2 = sTemp.indexOf("|");
					sRC = sTemp.substring(iTemp1+1,iTemp2);
				}
			}
		}
	}
	else
	{
		iTemp1=-1
		iTemp2=-1
		iTemp1 = BankLocalizedProperties.indexOf("|" + sProperty + "=");
		if (iTemp1 > -1)
		{
			sTemp = BankLocalizedProperties.substring(iTemp1+1);
			iTemp1 = sTemp.indexOf("=");
			iTemp2 = sTemp.indexOf("|");
			sRC = sTemp.substring(iTemp1+1,iTemp2);
		}
		else
		{
			// Check if it is in the global properties
			iTemp1=-1
			iTemp2=-1
			iTemp1 = GlobalLocalizedProperties.indexOf("|" + sProperty + "=");
			if (iTemp1 > -1)
			{
				sTemp = GlobalLocalizedProperties.substring(iTemp1+1);
				iTemp1 = sTemp.indexOf("=");
				iTemp2 = sTemp.indexOf("|");
				sRC = sTemp.substring(iTemp1+1,iTemp2);
			}
		}
	}

	if (sRC == '')
	{
		sRC = sDefault;
	}

	//replace ^^ with "
	sRC = stringReplace(sRC, '^^','"');

	//replace ^ with '
	sRC = stringReplace(sRC, "^","'");

	//return the result
	return sRC;
}

function writeProperty(sProperty, sDefault) {
var sRC = '';

	sRC = getProperty(sProperty, sDefault);
	document.write(sRC);
	return;
}

function stringReplace(str, v1, v2) {
var sRC = '';

	var arr = str.split(v1);
   for (var i=0; i < arr.length; i++) {
		sRC = sRC + arr[i] + v2
	}
	//remove the last v2
	sRC = sRC.substring(0, sRC.length-v2.length);
	return sRC;
}

function output(str)
{
	document.write(str);
}


function getProperty(sProperty, sDefault) {
var sTemp = '';
var iTemp1 = -1;
var iTemp2 = -1;
var sRC = '';

	//set the return value to the default
	sRC = sDefault;

	//if it's in the global.js, replace the value
	iTemp1=-1
	iTemp2=-1
	iTemp1 = BankAppProperties.indexOf("|" + sProperty + "=");
	if (iTemp1 > -1) {
		sTemp = globalProperties.substring(iTemp1+1);
		iTemp1 = sTemp.indexOf("=");
		iTemp2 = sTemp.indexOf("|");
		sRC = sTemp.substring(iTemp1+1,iTemp2);
	}

	//if it's in the common.js, replace the value
	iTemp1=-1
	iTemp2=-1
	iTemp1 = BankAppProperties.indexOf("|" + sProperty + "=");
	if (iTemp1 > -1) {
		sTemp = commonProperties.substring(iTemp1+1);
		iTemp1 = sTemp.indexOf("=");
		iTemp2 = sTemp.indexOf("|");
		sRC = sTemp.substring(iTemp1+1,iTemp2);
	}

	//if it's in the page-specific properties file, replace the value
	iTemp1=-1
	iTemp2=-1
	iTemp1 = localProperties.indexOf("|" + sProperty + "=");
	if (iTemp1 > -1) {
		sTemp = localProperties.substring(iTemp1+1);
		iTemp1 = sTemp.indexOf("=");
		iTemp2 = sTemp.indexOf("|");
		sRC = sTemp.substring(iTemp1+1,iTemp2);
	}

	//replace ^^ with "
	sRC = stringReplace(sRC, '^^','"');

	//replace ^ with '
	sRC = stringReplace(sRC, "^","'");

	//return the result
	return sRC;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );

  if ( secure )
        cookie_string += "; secure";

  document.cookie = cookie_string;
}

function getLocale()
{
  var locale_support = "";
  var loc = location.search.substring(1, location.search.length);
  var param_value="";
  var params = loc.split("&");
  for(i=0; i<params.length; i++){
	  param_name = params[i].substring(0,params[i].indexOf('='));
	  if(param_name == "locale_supported"){
	     param_value = params[i].substring(params[i].indexOf('=')+1)
	  }
  }
  return param_value
}


