// SHKP ==========================
// ===============================
function jump(section) {
	if ("memberZone" == section){
		if (zmsCharsetID == 1){
		//	popup('https://www.reinsurancemall.com/medical/login_en.asp?lang=en','med_enq_login','840','600')
			popup('https://www.shkpi.com.hk/memberzone/login_en.asp?lang=en','med_enq_login','840','600')		
		}else{
		//	popup('https://www.reinsurancemall.com/medical/login_tc.asp?lang=ch','med_enq_login','840','600');
			popup('https://www.shkpi.com.hk/memberzone/login_tc.asp?lang=ch','med_enq_login','840','600')		
		}
	}else if ("downloadArea" == section){
		if (zmsCharsetID == 3){
			window.location = "/sc/download_area/index.html";
		}else if (zmsCharsetID == 2){
			window.location = "/tc/download_area/index.html";
		}else{
			window.location = "/en/download_area/index.html";
		}
	}
}
function popup(mylink, windowname, w, h){
	var str
	
	str = "status=1,";
	str += "height=" + h + ","
	str += "width=" + w + ","
	str += "toolbar=no,location=no,scrollbars=yes,resizable=yes,location=no,left=0,top=0"
	
	window.open(mylink,windowname,str);
	return false;
}
// End of SHKP ===================
// ===============================



function printPage()
{
	var URL;
	URL = location.href;
	if (URL.indexOf("?")>0) {
		URL += "&print=1";
	} else {
		URL += "?print=1";
	}
	window.open(URL);
}

function switchLang(charsetID){
	var url = window.location.toString();
	var isStaticURL = false;
	var langPaths = new Array("en", "tc", "sc");
	var oldLangPath = "";

	// Check url type (is static page or dynamic page)
	for (i=0; i < langPaths.length; i++){
		if (url.indexOf("/"+langPaths[i]+"/") != -1){
			oldLangPath = "/"+langPaths[i]+"/";
			isStaticURL = true;
			break;
		}
	}

	if (isStaticURL){
		window.location = 
			url.replace(oldLangPath, "/"+langPaths[charsetID - 1]+"/");
	}else{
		if (url.indexOf("lang=") != -1){
			window.location = 
				url.replace(/lang=\d/, "lang="+charsetID);
		}
	}
}

/// Get value from query string
function gup(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 MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




function getY(arg)
{
	return arg.offsetTop + (arg.offsetParent?getY(arg.offsetParent):0);
}

function getX(arg)
{
	return arg.offsetLeft + (arg.offsetParent?getX(arg.offsetParent):0);
}

//onload
$(document).ready(function() {
		$('img.btn_over').mouseover(function(){
				$(this).attr('src', $(this).attr('src').toString().replace('.','_over.'));
		    }).mouseout(function(){
				$(this).attr('src', $(this).attr('src').toString().replace('_over.','.'));
		    });

		/* alternative row color
		$('table.table-teal tr').each(function() {
				var rowspan = $(this).children(":first").attr("rowspan");
				if (rowspan % 2 == 0 && rowspan >= 2){
					var i=0;
					var cmd = "$(this)";

					for (i=0; i < rowspan - 1; i++){
						cmd += ".next()";
					}
					cmd += ".after(\"<tr><td colspan='100'></td></tr>\");";
					eval(cmd);
				}
			});
			*/
		$('table.table-teal').children().children('tr:odd').addClass('odd');
		$(".menu .sub").each(function() { 
			var currSub = $(this);

			$(this).parent().hover(function(){
				var mainMenu = $(this).parent(".menu");
				mainMenu.attr("active", 1)
				if (mainMenu.filter(".posBOTTOM").size() > 0)
				{
				var heightAdjust = 4;
				//if (BrowserDetect.browser=="Explorer" && BrowserDetect.version==6) heightAdjust = 3;
				//currSub.css({display: "block", top: getY(this) + mainMenu.height() - heightAdjust, left: getX(this)});
				currSub.css({zIndex: 999, display: "block", top: getY(this) + 21, left: getX(this)});
				}
				else //if (mainMenu.filter(".posRIGHT").size() > 0)
				{
				var iWidth = mainMenu.width();
				// Original COde
				//currSub.css({display: "block", top: getY(this), left: getX(this) + iWidth});
				currSub.css({display: "block", top: getY(this) - 4, left: getX(this) + iWidth - 4});
				}
				//currSub.width(mainMenu.width());
				currSub.show();
				}, function() {
				currSub.hide();
				});
		});
})

