//devt path - with domain name
/** Devt Paths **/
//var overlay_path="http://wsmtsg99.sg.uobnet.com/";
//var overlay_path_secure="http://wsmtsg99.sg.uobnet.com:443/";
//var podcast_srcfiles="http://t-pib.sg.uobnet.com/investor/podcast/mp3/"
//var tpid_src="http://t-pib.sg.uobnet.com/"
//var atm_search_link="http://test2.street-directory.com/";

/** Live Paths **/
var overlay_path="https://uniservices1.uobgroup.com/";
var overlay_path_secure="https://uniservices1.uobgroup.com/";
var podcast_srcfiles="http://www.uobgroup.com/investor/podcast/mp3/"
var tpid_src="http://www2.uobgroup.com/"
var atm_search_link="http://www.street-directory.com/";

// Current Page Reference
function getURL(uri) {
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir;
	if (uri.dom.substr(0,7) == 'http:\/\/') 
		uri.dom = uri.dom.substr(7);
	uri.path = ''; 
	var pos = uri.dom.indexOf('\/'); 
	if (pos > -1) {
		uri.path = uri.dom.substr(pos+1); 
		uri.dom = uri.dom.substr(0,pos);
	}
	uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
	pos = uri.page.indexOf('?');
	if (pos > -1) {
		uri.page = uri.page.substring(0, pos);
	}
	pos = uri.page.indexOf('#');if (pos > -1){
		uri.page = uri.page.substring(0, pos);
	}
	uri.ext = ''; pos = uri.page.indexOf('.');
	if (pos > -1) {
		uri.ext =uri.page.substring(pos+1); 
		uri.page = uri.page.substr(0,pos);
	}
	uri.file = uri.page;
	if (uri.ext != '') 
		uri.file += '.' + uri.ext;
	if (uri.file == '') 
		uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}

var uri = new Object();
getURL(uri);
                  

function show_contactus_personal(type1, type2)
{
	var addr=overlay_path_secure+"secure/forms/emailusp_pweb.jsp?s1="+escape(type1)+"&s2="+escape(type2)+"&keepThis=true&TB_iframe=true&height=480&width=560";
	tb_show("Contact Us", addr, false);
}

function show_contactus_corporate(type1, type2)
{
	var addr=overlay_path_secure+"secure/forms/emailusb_pweb.jsp?s1="+escape(type1)+"&s2="+escape(type2)+"&keepThis=true&TB_iframe=true&height=540&width=560";
	tb_show("Contact Us", addr, false);
}

function show_contactus_corporatecards(title)
{
	var addr=overlay_path_secure+"secure/forms/corp_cards_contactus.jsp?keepThis=true&TB_iframe=true&height=470&width=540";
	tb_show(title, addr, false);
}

function show_business_inclusion(title){
	var addr=overlay_path_secure+"secure/forms/corp_merchants_inclusion.jsp?keepThis=true&TB_iframe=true&height=470&width=520";
	tb_show(title, addr, false);
}

function show_personal_cards_pa(url,title){
	var addr=overlay_path_secure+url+"?keepThis=true&TB_iframe=true&height=470&width=520";
	tb_show(title, addr, false);
}

function show_application_form(url,type)
{
	var addr="";
	if(type=="secure"){
		addr=overlay_path_secure+url;
	}else{
		addr=overlay_path_secure+url;
	}
	window.open (addr,"appln_form");
}

function show_secure_form(add, title){
	var addr=overlay_path_secure+add;
	tb_show(title, addr, false);
}

function show_taf_form(){
	/*
	Example: http://www.uobgroup.com/pages/personal/resource/application.html
	domain (uri.dom) : "www.uobgroup.com"
	path (uri.path) : "/www.uobgroup.com/pages/personal/resource"
	page (uri.page) : "application"
	extension (uri.ext) : "html"
	filename (uri.file) : "application.html"
	query string (uri.arg) : ""
	*/
	//var referlink=(uri.path).replace("/wcm.sg.uobnet.com/iw/cci/meta/no-injection/iw-mount/default/main/uobpweb/WORKAREA/1.%20uobgroup.com", "http://www.uobgroup.com/");
	var referlink=location.href;
	var addr=overlay_path_secure+"secure/forms/taf_form.jsp?link="+encodeURIComponent(referlink)+"&keepThis=true&TB_iframe=true&height=490&width=500";
	tb_show("Share this page with your friends!", addr, false);
}


function show_appln_form(url,params,formname)
{
	var addr="";
	var address="";
	if(params==""){
		addr=overlay_path_secure+url+"?";
	}else{
		addr=overlay_path_secure+url+params+"&";
	}
	var address=addr+"keepThis=true&TB_iframe=true&height=540&width=800";
	tb_show(formname, address, false);
}

function show_atm_search_form(url,params,formname)
{
	
	var address=url+"?"+params+"&keepThis=true&TB_iframe=true&height=540&width=560";
	tb_show(formname, address, false);
}


function show_uobtp_resources_natas(formname,width,height){
	var address=tpid_src + "uobtravel/resources/" + formname +"&keepThis=true&TB_iframe=true&height=" + height + "&width=" + width;
	tb_show(" ", address, false);	
}

function show_uobtp_resources_starwood(formname,width,height){
	var address=tpid_src + "uobtravel/resources/" + formname +"&keepThis=true&TB_iframe=true&height=" + height + "&width=" + width;
	tb_show(" ", address, false);	
}

function show_uobtp_resources(formname,width,height){
	var address=tpid_src + "uobtravel/resources/" + formname +"?keepThis=true&TB_iframe=true&height=" + height + "&width=" + width;
	tb_show(" ", address, false);	
}

function show_uobtp_resources_parameters(formname,width,height){
	var address=tpid_src + "uobtravel/resources/" + formname +"&keepThis=true&TB_iframe=true&height=" + height + "&width=" + width;
	tb_show(" ", address, false);	
}


function rightnav_usefulinfo_goto(url, formname,width,height){
	if(url!=""){
		if(formname=='Rates'){
			document.getElementById("SGD_Money").style.display="none";
			document.getElementById("Uniplus").style.display="none";
			document.getElementById("gold_silver").style.display="none";
		}
		
		if(url.substr(0,8)=="rates - "){
			//var divName=document.getElementById("menu1").value;
			document.getElementById(url.substr(8)).style.display="block";
		}else if(url.substr(0,9)=="_blank - "){
			//alert(url.substr(9));
			var myURL=url.substr(9);
			window.open (myURL,"mypdfs");
		}else if(url.substr(0,10)=="overlay - "){
			var addr = {url:url.substr(10), hash:'', query:''};
			var pos = -1;
			if ((pos = addr.url.indexOf('#')) != -1)
			{
				addr.hash = addr.url.substr(pos + 1); 
				addr.url = addr.url.substr(0, pos);  
			}
			if ((pos = addr.url.indexOf('?')) != -1)
			{
				addr.query = addr.url.substr(pos + 1); 
				addr.url = addr.url.substr(0, pos);  
			}
			var address = addr.url + '?' + addr.query + '&TB_iframe=true&height=' + height + "&width=" + width + '#' + addr.hash;
			if ($('#TB_window').css('display') != 'block') tb_show(formname, address, false);
		}else{
			document.location.href=url;
		}
	}
		
}

function playPodcast(xmlname){
	var servername=tpid_src;
	var realPath = servername+"/investor/podcast/detectitunes.html?id="+xmlname;
	//itpc://www3.uobgroup.com/rss/podcasts/podcast_2006Q2.xml
	var myWidth = 500; 
	var myHeight = 400;  
	var myLeft = (screen.width - myWidth) / 2;
	var myTop = (screen.height - myHeight - 15) / 2;
	myFeatures = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,width=' + myWidth + ',height=' + myHeight + ',left=' + myLeft +',top='+ myTop +',scrollbars=yes';
	var TheNewWindow = window.open(realPath,'PodcastXML',myFeatures);
	//TheNewWindow.close();	
}

function playPodcast1(xmlname){
	var servername=tpid_src;
	var realPath = servername+"/investor/podcast/detectitunes.html?id="+xmlname;
	//itpc://www3.uobgroup.com/rss/podcasts/podcast_2006Q2.xml
	//var myWidth = 400; 
	//var myHeight = 400;  
	//var myLeft = (screen.width - myWidth) / 2;
	//var myTop = (screen.height - myHeight - 15) / 2;
	//myFeatures = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,width=' + myWidth + ',height=' + myHeight + ',left=' + myLeft +',top='+ myTop +',scrollbars=yes';
	//var TheNewWindow = window.open(realPath,'PodcastXML',myFeatures);	
	
	var addr=realPath+"&keepThis=true&TB_iframe=true&height=450&width=450";
	//document.write(addr);
	tb_show("Play Podcast", addr, false);
}

// JavaScript Document
function clearFields()
{
	document.getElementById("amount").value="";
	document.getElementById("from").value="SGD";
	document.getElementById("to").value="SGD";
	
}

function isNumberDup(string)
{
    if (!string) return false;
    var Chars = "0123456789.,";

    for (var i = 0; i < string.length; i++) {
       if (Chars.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
}

function toTruncateDup(string)
{
	var lstring = string;
	var dotpos = lstring.indexOf('.');
        if (dotpos == -1) return lstring;
	var moneystr = lstring.substring(0,dotpos);
    	return moneystr;
} 


function mnycalc()
{
	var amount = document.getElementById("amount_CurConv").value;
	
	// if not numeric, set to zero
	if (!isNumberDup(amount))
		document.getElementById("amount_CurConv").value = "0";
	
	// if numeric, mask out comma character
	document.getElementById("amount_CurConv").value = document.getElementById("amount_CurConv").value.replace(/,/g, "");
	
	// remove cents
	document.getElementById("amount_CurConv").value = toTruncateDup(document.getElementById("amount_CurConv").value);
	
	var address    =  overlay_path_secure + "secure/forms/calculators/moneyChangingResults.jsp?";
	var addr = address + "amount=" + document.getElementById("amount_CurConv").value
			   + "&from="  + document.getElementById("menu_from_CurConv").options[document.getElementById("menu_from_CurConv").selectedIndex].value
			   + "&to=" + document.getElementById("menu_to_CurConv").options[document.getElementById("menu_to_CurConv").selectedIndex].value + "&keepThis=true&TB_iframe=true&height=430&width=555";
	//var win3 = window.open("", "what_I_want", option);
	//var win4 = window.open(addr, "what_I_want");
	tb_remove();
	tb_show("Money Changing Calculator", addr, false);
}

function selectRates(){
	var divName = document.getElementById("menu_Rates").value;
	document.getElementById("SGD_Money").style.display="none";
	document.getElementById("Uniplus").style.display="none";
	document.getElementById("gold_silver").style.display="none";
	if(divName!=""){
		document.getElementById(divName).style.display="block";
	}

}

//get a parameter from url

function get_parameter_value_from_url(name){  
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
	var regexS = "[\\?&]"+name+"=([^&#]*)";  
	var regex = new RegExp( regexS ); 
	var results = regex.exec( window.location.href );  
	if( results == null )    
		return "";  
	else    
		return results[1];
}


function tp_traveltools_nav(){
	var traveltools_link=document.getElementById("travel_tools").value;
	if(traveltools_link==""){
		alert("Please select a tool");
	}else if(traveltools_link=="flight_schedules"){
		show_uobtp_resources('flight.html',560,480);			
	}else if(traveltools_link=="post_travel_feedback"){	
		show_uobtp_resources('feedback.html',560,480);
	}else if(traveltools_link=="money_changing_rates"){	
		tb_show('SGD Money', overlay_path_secure+ 'secure/online_rates/money.jsp?&keepThis=true&TB_iframe=true&height=480&width=560', false);
	}else if(traveltools_link=="global_time_converter"){	
		show_uobtp_resources('time_converter.html',560,480);
	}else if(traveltools_link=="currency_converter"){	
		show_uobtp_resources('currency_converter.html',560,400);
	}else if(traveltools_link=="global-time_converter"){	
		show_uobtp_resources('time_converter.html',560,480);	
	}else{
		document.location.href=traveltools_link;
	}
}

function openthirdpartypopup(url){	
window.open(url,'Bodyframe','toolbar=no,directories=no,scrollbars=no,resizable=no, menubar=no,location=no,width=580,height=350,maximize=no,minimize=no');
}
