/********************************************/
function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE   
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

//var wait = '<p style="width:100%;height:100%;text-align:center;"><img src="../../images/icon/wait.gif" alt="" style="width:16px;height:16px;"></P>';
var img = '<img src="../../images/icon/wait.gif" alt="" style="width:16px;height:16px;">';

function processajax(url,val,obj,w,wait){	
	var req = Inint_AJAX();
	val += "&amp;_xxx=" + new Date().getTime() + Math.random() ;
	document.getElementById(w).innerHTML=wait;
		
          req.onreadystatechange = function () { 
               if (req.readyState==4 && req.status==200) {            		   
                         var ret=req.responseText; //รับค่ากลับมา      
						 if(ret.length > 0){
							document.getElementById(w).innerHTML="";                          
                         	document.getElementById(obj).innerHTML=ret;  							
						 }else {							
							processajax(url,val,obj,w,wait);	
						}					 
               }
          }; 
          req.open("POST",url,true);
          req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); // set Header
          req.send(val); //ส่งค่า   	

}//end

function load_borad(val){
	var x = '<table width="95%" hegith="100%" border="0" align="center"><tr><td><table width="95%" height="100%" border="0" align="center"><tr><td align="center" valign="middle"><p><br />'+img+'</p></td></tr></table></td></tr></table>';
	processajax('board.php',val,'point','w-point',x);
}
function load_article(val){	
	var b = '<table width="95%" heigth="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="100%" align="center" valign="middle">'+img+'</td></tr></table>';
	processajax('article.php',val,'article','w-article',b);
}
function load_activity(val){
	var x = '<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">'+img+'</td></tr></table>';
	processajax('activity.php',val,'activity','w-activity',x);
}
function load_download(val){	
	 var icon = '<table width="95%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle" width="100%" height="100%">'+img+'</td></tr></table>';	
	 processajax('download.php',val,'downl','w-downl',icon);		
}
function load_llink(val){
	var a = '<table width="95%" border="0" align="center" cellpadding="0" cellspacing="5"><tr><td align="center" valign="middle">'+img+'</td></tr></table>';	 	
	processajax('link.php',val,'r-link','w-link',a);
}

/********************************************/
function $(el){							
		if (!el) return null;
	if (el.htmlElement) return Garbage.collect(el);
	if ([window, document].contains(el)) return el;
	var type = $type(el);
	if (type == 'string'){
		el = document.getElementById(el);
		type = (el) ? 'element' : false;
	}
	if (type != 'element') return null;
	if (el.htmlElement) return Garbage.collect(el);
	if (['object', 'embed'].contains(el.tagName.toLowerCase())) return el;
	$extend(el, Element.prototype);
	el.htmlElement = function(){};
	return Garbage.collect(el);
}
function vdoTab(val){
		if( val=="vdo"){
			//vdo		
			$('area-vdo').style.display='';
			$('area-vdopic').style.display='none';
			$('SystemModuleKey').value=val;
			$('bt-image-vdo-off').style.display='';			
			$('bt-image-vdo-on').style.display='none';		
			
			$('bt-image-vdopic-off').style.display='none';			
			$('bt-image-vdopic-on').style.display='';
		}else{
			//vdopic	
			$('area-vdo').style.display='none';
			$('area-vdopic').style.display='';	
			$('SystemModuleKey').value=val;
			$('bt-image-vdopic-off').style.display='';			
			$('bt-image-vdopic-on').style.display='none';		
			
			$('bt-image-vdo-off').style.display='none';			
			$('bt-image-vdo-on').style.display='';
		}
}
function submitVdoLink(){
	document.myVDOForm.submit();
}

//<img src="../../images/main/design-for-life-btn.gif" alt="Desing for Life" name="bt-image-vdo" width="125" height="35" id="bt-image-vdo" onclick="vdoTab('vdo');" style="cursor:pointer;" onmouseover="MM_swapImage('bt-image-vdo','','../../images/main/design-for-life-btn2.gif',1)" onmouseout="MM_swapImgRestore()"/>