// global variables used in the site
var g_country = "eng";
var hidePrintToolsIntervalId = 0;

//this function is not being used
//try to include the hide-print-tools.css instead
function hidePrintTools() {
	try
	{
		if (document.getElementById("printUtil"))
		{
			var printToolsContent = document.getElementById("printUtil").innerHTML;
			var newContent = printToolsContent.replace(/(<li class=add-to-basket>)(.*)(<\/li>)?/i, "");
			newContent = newContent.replace(/(<li class=manage-basket>)(.*)(<\/li>)?/i, "");
			newContent = newContent.replace(/(<li class=\"add-to-basket\">)(.*)(<\/li>)?/i, "");
			newContent = newContent.replace(/(<li class=\"manage-basket\">)(.*)(<\/li>)?/i, "");
			document.getElementById("printUtil").innerHTML = newContent;	
			clearInterval(hidePrintToolsIntervalId);
		}
	}
	catch (err)
	{
		//alert("@hidePrintTools Error");
	}
}

function showAudioGuide(audioFilePath)
{
	var audioPlayerFilePath = "/eng/images/audio-player.swf";
	var audioPlayerWidth = "250";
	var audioPlayerHeight = "23";
	var s = "<div class=\"audioguidetxt\">Hear Audio Guide</div><div id=\"audioguide\"></div>\n";
	s += "<script language=\"javascript\" type=\"text/javascript\">\n";
	s += "var fo = new FlashObject(\"" + audioPlayerFilePath + "\", \"fo\", \"" + audioPlayerWidth + "\", \"" + audioPlayerHeight + "\", \"8\", \"#ffffff\", true);\n";
	s += "fo.addParam(\"wmode\", \"transparent\");\n";
	s += "fo.addVariable(\"scriptPath\", \"" + audioFilePath + "\");\n";
	s += "fo.write(\"audioguide\");\n";
	s += "</script>\n";
	document.write(s);
}

function showShortAudioGuide(audioFilePath, id)
{
	var audioPlayerFilePath = "/eng/images/audio-player-short.swf";
	var audioPlayerWidth = "140";
	var audioPlayerHeight = "23";
	//var s = "<div class=\"audioguidetxt\">Hear Audio Guide</div><div id=\"audioguide\"></div>\n";
	var s = "<div id=\"audioguide"+id+"\"></div>\n";
	s += "<script language=\"javascript\" type=\"text/javascript\">\n";
	s += "var fo = new FlashObject(\"" + audioPlayerFilePath + "\", \"fo\", \"" + audioPlayerWidth + "\", \"" + audioPlayerHeight + "\", \"8\", \"#ffffff\", true);\n";
	s += "fo.addParam(\"wmode\", \"transparent\");\n";
	s += "fo.addVariable(\"scriptPath\", \"" + audioFilePath + "\");\n";
	s += "fo.write(\"audioguide"+id+"\");\n";
	s += "</script>\n";
	document.write(s);
}

function delegate( target, callback )
{
	var func;
	if(arguments.length > 2)
	{
		var _params = [];
		for(var n = 2; n < arguments.length; n++) _params.push(arguments[n]);
		func = function() { 
			var params = [];
			for(var n = 0; n < arguments.length; n++) params.push(arguments[n]);
			for(var n = 0; n < _params.length; n++) params.push(_params[n]);
			callback.apply(target,params); 
		}
	}
	else {
		func =  function() {
			callback.apply(target,arguments);
		}
	}
	
	return func;
}


function newwin(url, w, h) {
	/*
	var ie_fullscreen = "";
	if (detectBrowser() == "IE")
	{
		ie_fullscreen = "fullscreen=yes";
	}

	if (w<1)
	{
		w = screen.availWidth;
	}

	if (h<1)
	{
		h = screen.availHeight;
	}
	*/

	if (w<1)
	{
		var popWin = window.open(url, "popWin", "toolbar=yes,resizable=yes,menubar=yes,location=yes,scrollbars=yes,status=yes");
	}
	else
	{
		var popWin = window.open(url, "popWin", "width="+w+",height="+h+",toolbar=yes,resizable=yes,menubar=yes,location=yes,scrollbars=yes,status=yes");
	}

	popWin.focus();
}

function detectOS()
{
	if (navigator.userAgent.indexOf('Win') == -1) {
		OS = 'Macintosh';
	} else {
		OS = 'Windows';
	}
	return OS;
}

function detectBrowser()
{
	if (navigator.appName.indexOf('Netscape') == -1) {
		browser = 'IE';
	} else {
		browser = 'Netscape';
	}
	return browser;
}



/* ////////////////////// SDC tag for WebTrend, provided by client, 2008/03/25
*/
var gDomain="sdc.inetasia.com";
var gDcsId="dcslov2mn10000cd6jhiaaaod_1s1t";
var gFpc="WT_FPC";
var gConvert=true;
if ((typeof(gConvert)!="undefined")&&gConvert&&(document.cookie.indexOf(gFpc+"=")==-1)&&(document.cookie.indexOf("WTLOPTOUT=")==-1)){
	document.write("<scr"+"ipt type='text/javascript' src='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'><\/scr"+"ipt>");
}

//document.write("<scr"+"ipt type='text/javascript' src='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'><\/scr"+"ipt>");
document.write("<scr"+"ipt type='text/javascript' src='"+"/eng/js/dcs_tag.js"+"'><\/scr"+"ipt>");
///////////////////// End SDC tag for WebTrend

/*
	Online survey related
*/
var expDays = 30;
var pageCount = 2;
var page = "http://210.245.160.228/questionnaire/index_en.html";
var windowprops = "width=650,height=350,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes";

function GetCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function SetCookie(name, value)
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}

function DeleteCookie(name)
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function initSurvey()
{
	var exp = new Date();
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

	var count = GetCookie('count');
	if (count == null) count = 0;
	//alert(count);
	count++;
	//window.status="count:"+count;
	SetCookie('count', count, exp, "/");
	if (count == pageCount)
	{
		var surveyWin = window.open(page, "surveyWin", windowprops);
		surveyWin.focus();
	}
}

function onlineSurvey()
{
}

//initSurvey();