
// page url
var base_url            = "/pos";
var home_url            = base_url + "/homepage/";

var homepage_track_url  = home_url + "homepg_track.aspx";
var homepage_rate_url   = home_url + "homepg_rate.aspx";
var homepage_stamp_url  = home_url + "homepg_stamp.aspx";

var search_url    = "homepage/search_result.aspx?IndexCatalogue=pos_index&SearchQuery=";


// JavaScript Document
$(document).ready(function(){
  $('li').hover(function(){
    $(this).children('.nav_left').css({'background':'url(/pos_bm/Images/homepage/nav_left_selected.gif) bottom right no-repeat'});
    $(this).children('.nav_repeat').css({'background':'url(/pos_bm/Images/homepage/nav_repeat_selected.gif) bottom left repeat-x'});
    $(this).children('.nav_repeat').children('div').children('a').children('img').attr({'src':'/pos/Images/homepage/arrow_red.gif'});
	$(this).children('.nav_repeat').children('div').children('a').css({'color':'#ff0000'});
    $(this).children('.nav_right').css({'background':'url(/pos_bm/Images/homepage/nav_right_selected.gif) bottom left no-repeat'});
  },function(){
    $(this).children('.nav_left').css({'background':'url(/pos_bm/Images/homepage/nav_left.gif) bottom right no-repeat'});
    $(this).children('.nav_repeat').css({'background':'url(/pos_bm/Images/homepage/nav_repeat.gif) bottom left repeat-x'});
    $(this).children('.nav_repeat').children('div').children('a').children('img').attr({'src':'/pos/Images/homepage/arrow_white.gif'});
	$(this).children('.nav_repeat').children('div').children('a').css({'color':'#ffffff'});
    $(this).children('.nav_right').css({'background':'url(/pos_bm/Images/homepage/nav_right.gif) bottom left no-repeat'});
  });
  
  $('a').children('p').hover(function(){
    $(this).css({'color':'#999999'});
  },function(){
    $(this).css({'color':'#333333'});
  });
  
  $('a.font14Pure').hover(function(){
    $(this).css({'color':'#999999'});
  },function(){
    $(this).css({'color':'#333333'});
  });
});

function popup(mylink, windowname, width, height){
  if (! window.focus)return true;
  var href;
  if (typeof(mylink) == 'string')
     href=mylink;
  else
     href=mylink.href;
     
  window.open(href, windowname, 'width='+width+',height='+height+',scrollbars=yes');
  return false;
}

/* redirect the homepage tab pages, base on pass-in page-ID */
function loadPageWIthId(pageID) {
  var pageURL = base_url;
  if (pageID == "home_track") {
    pageURL = homepage_track_url;
  } else if (pageID == "home_rate") {
    pageURL = homepage_rate_url;
  } else if (pageID == "home_stamp") {
    pageURL = homepage_stamp_url;
  }
  //alert(pageURL);
  window.location = pageURL;
  return true;
}

/* redirect the homepage tab pages, base on pass-in page-ID */
function loadPage(pageURL) {
  var target_url = base_url + "/" + pageURL;
  //alert("load: " + target_url);
  window.location = target_url;
  return true;
}


/* redirect the search to sitefinirt search result pages, base on enter search text */
function searchPage() {
  var searchTxt = document.getElementById('search_txt').value;
  var target_url = search_url + searchTxt + "&WordsMode=AnyWord";
  //alert("search - url " + target_url);
  loadPage(target_url);
}


/* inject the selected navi css class */
function injectSelectNavi (tid) {
  //alert(tid);
  $(document).ready(function(){ 
    $("#" + tid).attr("class", "font12 fontRedNormal");
  });
}


/*change the language */
function submitLang () {
     var langId = document.getElementById('lang').value;
	
	
     if (langId == "en")
       {
		   url_link="/pos/homepage.aspx";
	   }
     else if (langId == "ms"){
		  url_link="/pos_bm/homepage.aspx";
	 }
     window.location = url_link;
     return true;
//	 alert(url_link)   
 }
   
