﻿document.write(unescape('%3C!--[if IE 6]%3E%3Cscript type="text/javascript" src="js/DD_belatedPNG_0.0.8a.js"%3E%3C/script%3E%3C![endif]--%3E'));
var M18box = new Object();
M18box.livequotebox = {
	// UAT
	/*rootpath: 'http://210.177.167.128',*/
	rootpath: 'http://210.177.167.35:92',
	
	// LIVE
	/*rootpath: 'http://money18.on.cc',*/
	LQB_WIDTH: 0,
	LQB_HEIGHT: 0,
	ajaxContentW: 0,
	ajaxContentH: 0,
	hiddenObjs: '',
	LQB_launch: function(){
		this.hiddenObjs = '#PlayerHolder,#FooterHolder,#MainmenuHolder,#TextlinkFrame,#LargerectFrame'; //ontv only
		//this.hiddenObjs = (ODN.sect_L3 != '' && ODN.priority != '') ? '#superIframe, #adsCTN object, #adsCTN embed, #newsInfoCTN object, #newsInfoCTN embed' : 'object, embed'; //ODN
		//this.hiddenObjs = (TSN.sect_L3 != '' && TSN.priority != '') ? '#superIframe, #adsCTN object, #adsCTN embed, #newsInfoCTN object, #newsInfoCTN embed' : 'object, embed'; //TSN
		//this.hiddenObjs = 'object, embed'; //others
	},//e:LQB_launch,
	LQB_show: function(insymbol){
		try {
			with (M18box.livequotebox) {
				if (typeof document.body.style.maxHeight === 'undefined') {//if IE 6
					if (document.getElementById('LQB_HideSelect') === null) {//iframe to hide select elements in ie6
						$('body').append('<iframe id="LQB_HideSelect"></iframe><div id="LQB_overlay"></div><div id="LQB_shadow"></div><div id="LQB_window"></div>');
					}
				}else{//all others
					if(document.getElementById('LQB_overlay') === null){
						$('body').append('<div id="LQB_overlay"></div><div id="LQB_shadow"></div><div id="LQB_window"></div>');
					}
				}
				
				if(lqb_detectMacXFF()){
					$('#LQB_overlay').addClass('LQB_overlayMacFFBGHack');//use png overlay so hide flash
				}else{
					$('#LQB_overlay').addClass('LQB_overlayBG');//use background and opacity
				}		

				//hide the underlining ads in the page
				$(hiddenObjs).each(function(){
				 		$(this).css({visibility:'hidden'});
				 });
				
				
				//var queryString = url.replace(/^[^\?]+\??/,'');
				//var params = lqb_parseQuery(queryString);

// 
// Old Dimension (2010/01/07)
//
/*LQB_WIDTH =  547;
LQB_HEIGHT = 357;*/

				LQB_WIDTH =  320;
				LQB_HEIGHT = 467;
				/*if (screen.width <= 800) {
					LQB_WIDTH =  650;
					LQB_HEIGHT = 400;
				} else if (screen.width <= 1024) {
					LQB_WIDTH =  894;
					LQB_HEIGHT = 568;
				}*/
				ajaxContentW = LQB_WIDTH;
				ajaxContentH = LQB_HEIGHT;

				$('#LQB_iframeContent').remove();
				$("#LQB_window").append("<table cellpadding='0' cellspacing='0' border='0'><tr><td colspan='3'><a href='javascript:void(0);' onclick='javascript:M18box.livequotebox.lqb_remove();'><div class='png_bg' style='width:374px;height:23px;background:url("+rootpath+"/img/lightbox_top.png) no-repeat;'></div></a></td></tr><tr><td><div class='png_bg' style='width:20px;height:467px;background:url("+rootpath+"/img/lightbox_left.png) no-repeat;'></div></td><td><iframe frameborder='0' hspace='0' src='' id='LQB_iframeContent' scrolling='no' name='LQB_iframeContent"+Math.round(Math.random()*1000)+"' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;margin:0px;padding:0px;' > </iframe></td><td><div class='png_bg' style='width:34px;height:467px;background:url("+rootpath+"/img/lightbox_right.png) no-repeat;'></div></td></tr><tr><td colspan='3'><div class='png_bg' style='width:374px;height:28px;background:url("+rootpath+"/img/lightbox_bottom.png) no-repeat;'></div></td></tr></table>"+unescape('%3C!--[if IE 6]%3E%3Cscript type="text/javascript"%3EDD_belatedPNG.fix(\'.png_bg\')%3C/script%3E%3C![endif]--%3E'));

// 
// Old Dimension (2010/01/07)
//
/*
				$("#LQB_window").append("<table cellpadding='0' cellspacing='0' border='0'><tr><td colspan='3'><a href='javascript:void(0);' onclick='javascript:M18box.livequotebox.lqb_remove();'><div class='png_bg' style='width:601px;height:23px;background:url("+rootpath+"/img/lightbox_top.png) no-repeat;'></div></a></td></tr><tr><td><div class='png_bg' style='width:20px;height:357px;background:url("+rootpath+"/img/lightbox_left.png) no-repeat;'></div></td><td><iframe frameborder='0' hspace='0' src='' id='LQB_iframeContent' scrolling='no' name='LQB_iframeContent"+Math.round(Math.random()*1000)+"' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;margin:0px;padding:0px;' > </iframe></td><td><div class='png_bg' style='width:34px;height:357px;background:url("+rootpath+"/img/lightbox_right.png) no-repeat;'></div></td></tr><tr><td colspan='3'><div class='png_bg' style='width:601px;height:28px;background:url("+rootpath+"/img/lightbox_bottom.png) no-repeat;'></div></td></tr></table>"+unescape('%3C!--[if IE 6]%3E%3Cscript type="text/javascript"%3EDD_belatedPNG.fix(\'.png_bg\')%3C/script%3E%3C![endif]--%3E'));
*/
				
				$('#LQB_window').css({display:'block'});
				var res_symbol = checkidx(insymbol);
				insymbol = removedummy0(insymbol);
				if(res_symbol == "notidx")
				{
					$('#LQB_iframeContent').attr('src',rootpath+'/info/liveinfo_lightbox.html?symbol='+insymbol+'&refer=ontv');
				}
				else
				{
					$('#LQB_iframeContent').attr('src',rootpath+'/info/liveinfo_idx_lightbox.html?symbol='+res_symbol+'&refer=ontv');
				}

				lqb_position();
				
				if($.browser.safari){//safari needs help because it will not fire iframe onload
					$('#LQB_window').css({display:'block'});
				}

				document.onkeyup = function(e){ 	
					if (e == null) { // ie
						keycode = event.keyCode;
					} else { // mozilla
						keycode = e.which;
					}
					if(keycode == 27){ // close
						lqb_remove();
					}	
				}
				
			}
		} catch (e) {
			alert(e);
		}
	},//e: LQB_show
	checkidx: function(insymbol){
		if(insymbol == "110000")
		{
			return "HSI";
		}
		else if(insymbol == "110001")
		{
			return "HSI_FIN";
		}
		else if(insymbol == "110002")
		{
			return "HSI_UTL";
		}
		else if(insymbol == "110003")
		{
			return "HSI_PRO";
		}
		else if(insymbol == "110004")
		{
			return "HSI_C_I";
		}
		else if(insymbol == "110010")
		{
			return "HSCEI";
		}
		else if(insymbol == "110030")
		{
			return "HSCCI";
		}
		else if(insymbol == "110050")
		{
			return "GEM";
		}
		else if(insymbol == "111010")
		{
			return "HSCEI";
		}
		else if(insymbol == "111020")
		{
			return "HSHKCI";
		}
		else if(insymbol == "111030")
		{
			return "HSMLCI";
		}
		else if(insymbol == "111040")
		{
			return "HSHKLI";
		}
		else if(insymbol == "111050")
		{
			return "HSHKMI";
		}
		else if(insymbol == "111060")
		{
			return "HSHKSI";
		}
		else
		{
			return "notidx";
		}
	},
	removedummy0: function(isymbol){
		if(isymbol.length==6 && isymbol.charAt(0) == '0')
		{
			return isymbol.substring(1,isymbol.length);
		}
		else
		{
			return isymbol;
		}
		
	},
	lqb_showIframe: function(){
		$('#LQB_load').remove();
		$('#LQB_window').css({display:'block'});
	},//e: lqb_showIframe
	lqb_showshadow: function(){
		$('#LQB_shadow').css({display:'block'});
	},//e:lqb_showshadow
	lqb_remove: function(){
		with (M18box.livequotebox) {
			
			$('#LQB_window').css({display:'none'});
			$('#LQB_window,#LQB_overlay,#LQB_shadow,#LQB_HideSelect').trigger('unload').unbind().remove();

			//Restore the underlining ads
			$(hiddenObjs).each(function(){
				$(this).css({visibility:'visible'})
			});
			
			document.onkeydown = '';
			document.onkeyup = '';
			return false;
		}
	},//e:lqb_remove
	lqb_position: function(){
		var scTop = $(document).scrollTop();
		var adjTop = $(window).height() - this.LQB_HEIGHT;
		if (adjTop < 0)
			adjTop = scTop;
		else
			adjTop = scTop+Math.round(adjTop/2);
		
		with (M18box.livequotebox) {
			if ($(window).width() > LQB_WIDTH) {
				$('#LQB_window').css({left:'50%', marginLeft: '-' + parseInt((LQB_WIDTH / 2),10) + 'px', width: LQB_WIDTH + 'px'});
			} else {
				$('#LQB_window').css({left:'0px', marginLeft:'0px'});
			}
			//$('#LQB_shadow').css({marginLeft: '-' + parseInt((LQB_WIDTH / 2),10) + 'px', width: LQB_WIDTH + 'px'});
			/*
			if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
				$('#LQB_window').css({marginTop: ((adjTop < 0) ? 0-Math.round($(window).height()/2) : 0-Math.round(this.LQB_HEIGHT/2)) + 'px'});
			} else {
				$('#LQB_window').css({marginTop: ((adjTop < 0) ? scTop-Math.round($(window).height()/2) : scTop-Math.round(this.LQB_HEIGHT/2)) + 'px'});
			}
			*/
			$('#LQB_window').css({marginTop: adjTop + 'px'});
		}
	},//e:lqb_position
	lqb_parseQuery: function(query){
		var Params = {};
		if ( ! query ) {return Params;}// return empty object
		var Pairs = query.split(/[;&]/);
		for ( var i = 0; i < Pairs.length; i++ ) {
			var KeyVal = Pairs[i].split('=');
			if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
			var key = unescape( KeyVal[0] );
			var val = unescape( KeyVal[1] );
			val = val.replace(/\+/g, ' ');
			Params[key] = val;
		}
		return Params;
	},//e: lqb_parseQuery
	lqb_getPageSize: function() {
		var de = document.documentElement;
		var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
		var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
		var arrayPageSize = [w,h];
		return arrayPageSize;
	},//e: lqb_getPageSize
	lqb_detectMacXFF: function(){
		var userAgent = navigator.userAgent.toLowerCase();
		if (userAgent.indexOf('mac')!=-1 && userAgent.indexOf('firefox')!=-1) {
			return true;
		}
	}
};

$(document).ready(function(){
	M18box.livequotebox.LQB_launch();
})

