
	var FJADC={};
	FJADC.ProductCode="";
	var userAgent = navigator.userAgent.toLowerCase();

	// Figure out what browser is being used
	FJADC.browser = {
		version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
		safari: /webkit/.test( userAgent ),
		opera: /opera/.test( userAgent ),
		msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
		mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
	};
	
	FJADC.Init = function(productCode){
		FJADC.ProductCode = productCode;
	}
		
	FJADC.ShowWindow = function (skin,proxyUrl){
		try {
			if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
				document.body.style.height="100%";
				document.body.style.width="100%";
				document.body.style.overflow="hidden";
				if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
					var e = document.createElement("iframe");
					e.setAttribute("id","TB_HideSelect");
					document.body.appendChild(e);
					e = document.createElement("div");
					e.setAttribute("id","TB_overlay");
					document.body.appendChild(e);
					e = document.createElement("div");
					e.setAttribute("id","TB_window");
					document.body.appendChild(e);
				}
			}else{//all others
				if(document.getElementById("TB_overlay") === null){
					var e = document.createElement("div");
					e.setAttribute("id","TB_overlay");
					document.body.appendChild(e);
					e = document.createElement("div");
					e.setAttribute("id","TB_window");
					document.body.appendChild(e);
				}
			}			
			if(FJADC.tb_detectMacXFF()){
				document.getElementById("TB_overlay").className = "TB_overlayMacFFBGHack";//use png overlay so hide flash
			}else{
				document.getElementById("TB_overlay").className = "TB_overlayBG";//use background and opacity
			}
			
			TB_WIDTH=605||630;			
			TB_HEIGHT=358||440;
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 45;
			if(document.getElementById("TB_iframeContent")!=null){
				document.getElementById("TB_iframeContent").remove();
			}
			var e = document.createElement("iframe");
			e.setAttribute("frameborder","0");
			e.setAttribute("hspace","0");
			e.setAttribute("src","http://adc.fmcc.com.cn/ADCECPortal/GetECCode.aspx?ProductCode="+FJADC.ProductCode+"&Skin="+skin+"&ProxyUrl="+proxyUrl);
			e.setAttribute("id","TB_iframeContent");
			document.getElementById("TB_window").appendChild(e);
			document.getElementById("TB_iframeContent").style.width= ajaxContentW + 29 +"px";
			document.getElementById("TB_iframeContent").style.height= ajaxContentH + 17 +"px";
			document.getElementById("TB_window").style.display="block";
			
			FJADC.tb_position();
			
			document.onkeyup = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					FJADC.iFrameRemove();
				}	
			};	        
			return false;
		} catch(e) {alert(e);
			//nothing here
		}
	}
	FJADC.iFrameRemove = function () {
		if(document.getElementById("TB_window").length!=0)
		{
			if(	document.getElementById("TB_overlay")!=null){		
			    obj=document.getElementById("TB_overlay");
				obj.parentNode.removeChild(obj);
			}
			if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
				document.body.style.height="auto";
				document.body.style.width="auto";
				document.body.style.overflow="";
				obj=null;
				obj=document.getElementById("TB_HideSelect");
				obj.parentNode.removeChild(obj);
				
				
			}
			
			obj=null;
			obj=document.getElementById("TB_window");
			obj.parentNode.removeChild(obj);
				
			//document.getElementById("TB_window").removeNode(true);
			document.onkeydown = "";
			document.onkeyup = "";
		}
		else if(parent.frames["TB_iframeContent"]==null)
		{
			window.close();
		}
		else
		{
			parent.FJADC.iFrameRemove()
		}
		return false;
	}
	FJADC.tb_position = function () {
		document.getElementById("TB_window").style.marginLeft= '-' + parseInt((TB_WIDTH / 2),10) + 'px';
		document.getElementById("TB_window").style.width= TB_WIDTH + 'px';
		if ( !(FJADC.browser.msie && FJADC.browser.version < 7)) { // take away IE6
			document.getElementById("TB_window").style.marginTop= '-' + parseInt((TB_HEIGHT / 2),10) + 'px';
		}
	}
	
	FJADC.tb_detectMacXFF = function () {
		var userAgent = navigator.userAgent.toLowerCase();
		if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
			return true;
		}
	}	
