function displayActiveX(elm,strValue)
{
    var displayHTML;
    displayHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="642" height="429">';
    displayHTML +='<param name="movie" value="flash/main.swf">';
    displayHTML +='<param name="quality" value="high">';
    displayHTML +='<param name="flashVars" value="'+strValue+'">';
    displayHTML +='<param name="wmode" value="transparent">';
    displayHTML +='<embed src="flash/main.swf" quality="high" flashVars="'+strValue+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="642" height="429"></embed>';
    displayHTML +='</object>';
    
    //document.write(displayHTML);
    document.getElementById(elm).innerHTML = displayHTML;


}

function displayActiveXwithPath(elm,strValue, strPath, strH, strW)
{
    var displayHTML;
    displayHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+strW+'" height="'+strH+'">';
    displayHTML +='<param name="movie" value="'+strPath+'">';
    displayHTML +='<param name="quality" value="high">';    
    displayHTML +='<param name="wmode" value="transparent">';
    displayHTML +='<embed src="'+strPath+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+strW+'" height="'+strH+'"></embed>';
    displayHTML +='</object>';
    
    
    //document.write(displayHTML);
    document.getElementById(elm).innerHTML = displayHTML;


}

function displayActiveXwithVar(elm,strValue, strPath, strH, strW)
{
    var displayHTML;
    displayHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+strW+'" height="'+strH+'">';
    displayHTML +='<param name="movie" value="'+strPath+'">';
    displayHTML +='<param name="quality" value="high">';    
    displayHTML +='<param name="flashVars" value="'+strValue+'">';
    displayHTML +='<param name="wmode" value="transparent">';
    displayHTML +='<embed src="'+strPath+'" quality="high" flashVars="'+strValue+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+strW+'" height="'+strH+'"></embed>';
    displayHTML +='</object>';
    
    //alert(displayHTML);
    //document.write(displayHTML);
	document.getElementById(elm).innerHTML = displayHTML;


}

function Popup(win,url) {
	popupWindow = window.open(
		url,win,'height=420,width=830,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}

function showLayer() {
	setLayerPosition();
	if(window.addEventListener){
		window.addEventListener("scroll", setLayerPosition, false);
	}else if(window.attachEvent){
		window.attachEvent("onscroll", setLayerPosition);
	}
		
	var shadow = document.getElementById('shadow');
	var question = document.getElementById('question');

	shadow.style.display = 'block'; 
	question.style.display = 'block';

	shadow = null;
	question = null;       
}
function hideLayer() {
	var shadow = document.getElementById('shadow');
	var question = document.getElementById('question');
	shadow.style.display = 'none'; 
	question.style.display = 'none';
	if(window.removeEventListener){
		window.removeEventListener("scroll", setLayerPosition, false);
	}else if(window.detachEvent){
		window.detachEvent("onscroll", setLayerPosition);
	}
	shadow = null;
	question = null; 
}


function getBrowserHeight() {	
	var bodySL, bodyST, bodyCW, bodyCH, bodyH; 
	if(window.pageXOffset){
    	bodySL=window.pageXOffset;
	}else if(document.documentElement&&document.documentElement.scrollLeft){
		bodySL=document.documentElement.scrollLeft;
	}else if(document.body){
    	bodySL=document.body.scrollLeft; //author: meizz
	}
	if(window.pageYOffset){
		bodyST=window.pageYOffset;
	}else if(document.documentElement&&document.documentElement.scrollTop){
		bodyST=document.documentElement.scrollTop;
	}else if(document.body){
		bodyST=document.body.scrollTop;
	}
	if(window.innerWidth){
		bodyCW=window.innerWidth;
	}else if(document.documentElement&&document.documentElement.clientWidth){ 
		bodyCW=document.documentElement.clientWidth;
	}else if(document.body){
		bodyCW=document.body.clientWidth; //author: meizz
	}
	if(window.innerHeight){
		bodyCH=window.innerHeight;
	}else if(document.documentElement&&document.documentElement.clientHeight){ 
		bodyCH=document.documentElement.clientHeight; 
	}else if(document.body){
		bodyCH=document.body.clientHeight;
	}
	
	if(document.body){
		bodyH=document.body.clientHeight; //author: meizz
	}else if(document.documentElement&&document.documentElement.clientHeight){ 
		bodyH=document.documentElement.clientHeight;
	}
	
 //totalHeight(document.body.offsetHeight)
	return { width: parseInt(bodyCW), height: parseInt(bodyCH), top: parseInt(bodyST), totalHeight: parseInt(bodyH)};
}  
function setLayerPosition() {
	var shadow = document.getElementById('shadow');
	var question = document.getElementById('question');

	var bws = getBrowserHeight();
	
	shadow.style.width = bws.width + 'px';
	shadow.style.height = bws.totalHeight + 'px';
	shadow.style.top = parseInt(bws.top);
	question.style.left = parseInt((bws.width - 780) / 2);
	//question.style.top = parseInt((bws.height - document.documentElement.scrollTop - 345) / 2 + document.documentElement.scrollTop);
	question.style.top = parseInt((bws.height - 410) / 2 + bws.top);
	//alert(document.documentElement.scrollTop);

	shadow = null;
	question = null;
}

function submitform (frm) {
  if (document.getElementById("NAME").value == '') {
    alert('Please enter your name');
    return false;
  }
  if (document.getElementById("COMPANY").value == '') {
    alert('Please enter your company name');
    return false;
  }
  if (document.getElementById("TELEPHONE").value == '') {
    alert('Please enter telephone number');
    return false;
  }else{
		var stripped = document.getElementById("TELEPHONE").value.replace(/[\(\)\.\-\ ]/g, '');
		var f = /\D+/;
		if (f.test(stripped)){
			alert("The phone number contains illegal characters.");
			return false;		
		}
		if (isNaN(parseInt(stripped))) {
			alert("The phone number contains illegal characters.");
			return false;
		}
	}
  if (document.getElementById("EMAIL").value == '') {
    alert('Please enter your email address');
    return false;
  }else{
		var str=document.getElementById("EMAIL").value
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(str)){
			alert("Please input a valid email address!")
			return false;		
		}
	}
  if (document.getElementById("SOLNPROD").value == '') {
    alert('Please select an option you interested');
    return false;
  }
  if (frm != 'frm3' && document.getElementById("CONTENT").value == '') {
    alert('Please input your enquiry content');
    return false;
  }
  document.getElementById(frm).submit();
}

function Reset(frm){
	var objs = document.getElementById(frm);
	for(var i=0; i<objs.length; i++){
		objs[i].value = "";
	}
}

var ajaxFetch={
ajaxloadingmsg: '<div style="margin: 20px 0 0 20px"><img src="images/loading.gif" /> Fetching Contents. Please wait...</div>',
bustajaxcache: true, //bust caching of external ajax page after 1st request?
enablepersist: true, //persist to last content viewed when returning to page?

settingcaches: {}, //object to cache "setting" object of each script instance
ajaxconnect:function(setting){
	var page_request = false
	if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else
		return false
	var pageurl=setting.url
	
	page_request.onreadystatechange=function(){
		ajaxFetch.ajaxpopulate(page_request, setting)
	}
	document.getElementById(setting.id).innerHTML=this.ajaxloadingmsg
	var bustcache=(!this.bustajaxcache)? "" : (pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', pageurl+bustcache, true)
	page_request.send(null)
},
ajaxpopulate:function(page_request, setting){

	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
	//	alert(page_request.responseText)
		if(typeof setting.s != undefined && setting.s == '1'){
			var html = page_request.responseText;			
			var i = 0;
			var c = '';
			var newHTML = '';
			html = html.substr(html.indexOf('<SPAN class=color_nc_1>CVE </SPAN>', 0), (html.indexOf('<DIV id=footer>',0)- html.indexOf('<SPAN class=color_nc_1>CVE </SPAN>', 0)));
			html = html.replace(/^\s+|\s+$/g, '') ;
			while( i < html.length){
				c = html.substr(i,1);
				if(c == "c"){
					if((html.substr(i,6)) == 'class='){	
						c='';
						if(html.indexOf('>', i) < html.indexOf(' ', i)){
							i = html.indexOf('>', i);
							c = ">" ;
						}else i = html.indexOf(' ', i);
						if(i < 0) i = html.length;
						
					}
				}
				newHTML += c;
				i++;
			}
			//alert(newHTML);
			document.getElementById(setting.id).innerHTML=newHTML;
		}else
			document.getElementById(setting.id).innerHTML=page_request.responseText;
		//document.getElementById(setting.id).innerHTML="dfds";
		
	}
}
}

