//KAREN AMENDED HERE. 2009 09 03 2:47AM
//THIS FUNCTION IS BEST PUT IN A GLOBAL/COMMON JS FILE //Karen Added here: 20091109 - Add Favicon. Didn't change Default.js because no need to restart.
function createFavicon(){
	document.write("<link rel='SHORTCUT ICON' href='http;//www.hotlink.com.my/hotlink/09refresh/favicon.ico' />");
}
createFavicon();
//Karen Added here: 20090809 - Work around for fixing sidenav subnav to expand
//TO USE THIS FUNCTION - getSubnavLink(n)
// Add this into all the a href links:
//  onclick="getSubNavLink(this.href);return false;"
// Must follow exactly above.
// :)
function getSubNavLink(n){	
	var url = n;	
	var uPos = url.indexOf('?WCM_GLOBAL_CONTEXT=');
	var curl = url.substr('?WCM_GLOBAL_CONTEXT='.length +uPos);
	var aurl = '?WCM_GLOBAL_CONTEXT='+curl;
	//Put in the tags/keywords you want to replace with the actual tag that has the correct Uppercase letters
	//Otherwise the subnav will not load if it can't detect EXACT NAME ( uppercase+lowercase combination )
	//Then the URL can be "dynamic"
	var replacetags = new Array({o:"home_site_en", n:"Home_Site_en"},
								{o:"my_profile_sa_en", n:"My_Profile_SA_en"},
								{o:"change_password_sa_en", n:"Change_Password_SA_en"},
								{o:"manage_activ10_sa_en", n:"Manage_Activ10_SA_en"},
								{o:"hotlink_e_statement_sa_en", n:"Hotlink_E_Statement_SA_en"},
								{o:"redeem_rewards_sa_en", n:"Redeem_Rewards_SA_en"},
								{o:"puk_code_sa_en", n:"PUK_Code_SA_en"},
								{o:"fault_report_sa_en", n:"Fault_Report_SA_en"},
								{o:"feedback_sa_en", n:"Feedback_SA_en"},
								{o:"plans_sa_en", n:"Plans_SA_en"},
								{o:"basic_sa_en", n:"Basic_SA_en"},
								{o:"extra_plan_sa_en", n:"EXtra_Plan_SA_en"},
								{o:"sabah_and_sarawak_plan_sa_en", n:"Sabah_and_Sarawak_Plan_SA_en"},
								{o:"simpati_kangen_sa_en", n:"Simpati_Kangen_SA_en"},
								{o:"mobile_services_sa_en", n:"Mobile_Services_SA_en"},
								{o:"prepaid_blackberry_sa_en", n:"Prepaid_BlackBerry_SA_en"},
								{o:"idd_and_roaming_sa_en", n:"IDD_and_Roaming_SA_en"},
								{o:"hotlink_365_sa_en", n:"Hotlink_365_SA_en"},
								{o:"super_savers_sa_en", n:"Super_Savers_SA_en"},
								{o:"zon_hotlink_sa_en", n:"Zon_Hotlink_SA_en"},
								{o:"mobile_internet_sa_en", n:"Mobile_Internet_SA_en"},
								{o:"prepaid_broadband_sa_en", n:"Prepaid_Broadband_SA_en"},
								{o:"3g_sa_en", n:"3G_SA_en"},
								{o:"friend_finder_sa_en", n:"Friend_Finder_SA_en"},
								{o:"maybank_m2u_mobile_sa_en", n:"Maybank_M2U_Mobile_SA_en"},
								{o:"m-money_and_international_remittance_sa_en", n:"M-money_and_International_Remittance_SA_en"},
								{o:"whats_new_sa_en", n:"Whats_New_SA_en"},
								{o:"top_up_sa_en", n:"Top_Up_SA_en"},
								{o:"top_up_online_sa_en", n:"Top_Up_Online_SA_en"},
								{o:"cash_top_up_sa_en", n:"Cash_Top_Up_SA_en"},
								{o:"cashless_top_up_sa_en", n:"Cashless_Top_Up_SA_en"},
								{o:"postaid_top_up_sa_en", n:"PostAid_Top_Up_SA_en"},
								{o:"rewards_sa_en", n:"Rewards_SA_en"},
								{o:"rewards_points_sa_en", n:"Rewards_Points_SA_en"},
								{o:"double_birthday_sa_en", n:"Double_Birthday_SA_en"},
								{o:"terms_and_conditions_sa_en", n:"Terms_and_Conditions_SA_en"},
								{o:"support_sa_en", n:"Support_SA_en"},
								{o:"customer_services_sa_en", n:"Customer_Services_SA_en"},
								{o:"members_to_remember_sa_en", n:"Members_to_Remember_SA_en"},
								{o:"balance_retrieval_sa_en", n:"Balance_Retrieval_SA_en"},
								{o:"sos_and_call_me_back_sa_en", n:"SOS_and_Call_Me_Back_SA_en"},
								{o:"important_notices_sa_en", n:"Important_Notices_SA_en"});
								

								
	for(var i=0;i <replacetags.length; i++){
		aurl = aurl.split(replacetags[i].o).join(replacetags[i].n);
	}
	submitform( aurl );
	return false;
}
function FINDSUBNAV(currentpage,currenturl){
	var subnavs, i;
    var pageurl = document.location.href;
	//alert (pageurl);
	subnavs=document.getElementsByTagName('ul');
    var nosubnav=true;       
	for(var i=0; i<subnavs.length; i++){
		if ( subnavs[i].className == "subnavlist" ){         
			nosubnav=false;
            break;
		} 
	}
    if (nosubnav){
		submitform(currenturl);
    }
}
//TO USE:
//@currentpage is the current unique name of the subnav on the sidenav
//@currenturl is the submitform url format
//FINDSUBNAV("Basic_Plan_SA_en","?WCM_GLOBAL_CONTEXT=/web/wcm/connect/Hotlink_Content_lib_en/Home_Site_en/Plans_SA_en/Basic_Plan_SA_en");
//END


//

document.title = 'Hotlink - So much is possible';

var secs
var timerID = null
var timerRunning = false
var expand = true

window.onload = function() {
//	expandSup = new fx.Height('showhide');
//	naviHideInitial()
//	$('toggler').onmouseover = function() {
//		naviExpand();
//		};
//	$('toggler').onmouseout = function() {
//		naviHide();
//		};
	MassageLinks();
	};
RegExp.escape = function(text) {
	if (!arguments.callee.sRE) {
		var specials = [
		'/', '.', '*', '+', '?', '|',
		'(', ')', '[', ']', '{', '}', '\\'
		];
		arguments.callee.sRE = new RegExp(
		'(\\' + specials.join('|\\') + ')', 'g'
		);
	}
	return text.replace(arguments.callee.sRE, '\\$1');
}
	
function MassageLinks(){
	
	var vLinks=document.getElementsByTagName("a")
	for(var iCnt=0;iCnt<vLinks.length;iCnt++){
		vLinks[iCnt].href=formatURL(vLinks[iCnt].href);		
	}
	
	var vArea=document.getElementsByTagName("area")
	for(var iCnt=0;iCnt<vArea.length;iCnt++){
		vArea[iCnt].href=formatURL(vArea[iCnt].href);		
	}	
}

function formatURL(sURL){
return sURL;

	var re1=new RegExp(RegExp.escape("/myconnect/"),"gi");
	sURL=sURL.replace(re1,"/connect/");
		
	if (sURL.indexOf("/portal/hotlink/")!=-1 && sURL.indexOf("/portal/hotlink/hotlinkpage?")==-1){
		var re=new RegExp(RegExp.escape("/portal/hotlink/"),"gi");
		sURL=sURL.replace(re,"/portal/hotlink/hotlinkpage?");
	}
	else if (sURL.indexOf("/myportal/hotlink/")!=-1 && sURL.indexOf("/myportal/hotlink/hotlinkpage?")==-1){
		var re=new RegExp(RegExp.escape("/myportal/hotlink/"),"gi");
		sURL=sURL.replace(re,"/myportal/hotlink/hotlinkpage?");
	}

	else if(sURL.indexOf("/web/wcm/connect/"!=-1) && sURL.indexOf("/portal/hotlink/hotlinkpage?")==-1){
		var re=new RegExp(RegExp.escape("/web/wcm/connect/"),"gi");
		sURL=sURL.replace(re,"/web/portal/hotlink/hotlinkpage?WCM_GLOBAL_CONTEXT=/");		
	}
	else if(sURL.indexOf("/web/wcm/myconnect/"!=-1) && sURL.indexOf("/myportal/hotlink/hotlinkpage?")==-1){
		var re=new RegExp(RegExp.escape("/web/wcm/myconnect/"),"gi");
		sURL=sURL.replace(re,"/web/myportal/hotlink/hotlinkpage?WCM_GLOBAL_CONTEXT=/");		
	}



	return sURL;		
}

function naviExpand()
{
/*
	if (expand == false) {
		expandSup.toggle()
		expand = true
	}
	StopTheClock()
*/
}

function naviHideInitial()
{
/*
	if (expand == true) {
		// Set the length of the timer, in seconds
	    secs = 4
	    StopTheClock()
	    StartTheTimer()
	}
*/
}

function naviHide()
{
/*
    if (expand == true) {
		// Set the length of the timer, in seconds
	    secs = 1
	    StopTheClock()
	    StartTheTimer()
	}
*/
}

function StopTheClock()
{
/*
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
*/
}

function StartTheTimer()
{
/*
	if (secs==0)
    {
        StopTheClock()
		expand = false;
        //expandSup.toggle();
    }
    else
    {
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", 1000)
    }
*/
}



function changeSite(URL_List)
{
	var URL = URL_List.options[URL_List.selectedIndex].value;
	var OpenNewBrowers = true;
	if (URL == "http://www.maxis.com.my" )
	{   OpenNewBrowers = false; }
	else if (URL == "http://www.maxis.com.my/3g" )
	{	OpenNewBrowers = false;	}
	else if (URL == "http://store.maxis.com.my" )
	{	OpenNewBrowers = false;	}
	else if (URL == "http://www.maxis.com.my/moc_new/moc_highlight.asp" )
	{	OpenNewBrowers = false;	}
	else if (URL == "http://unifun.maxis.com.my" )
	{	OpenNewBrowers = false;	}	
	if (OpenNewBrowers)
	{
		window.open(URL,"sites");
	}
	else
	{
		window.location=URL;
	}	
}



function sites() { 
url = document.frmothersite.othersites.value;
aWindow=window.open(url,"sites");
}
function jumpTo(URL_List){
   var URL = URL_List.options[URL_List.selectedIndex].value;
   aWindow=window.open(URL,"sites");

}
