// JavaScript Document
function getHTTPObject(){                       
	var http;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); }
	else{ http = new XMLHttpRequest(); }
	return http;
}

function getpage(url,ID){
	var obj=document.getElementById(ID);
	var ajax = getHTTPObject();
	ajax.open("GET", url, true); 
	ajax.onreadystatechange = function(){   
		if(ajax.readyState==1){obj.innerHTML = "<img src='../images/images/loading.gif' style='margin:40px 0px 0 px 200px;'>";}
		if (ajax.readyState == 4 && ajax.status == 200){    
		   obj.innerHTML = ajax.responseText; 
		} 
	}
	ajax.send(null); 	
}

function getimg(obj){
	var big_img=document.getElementById("big_img");
	big_img.innerHTML=obj.innerHTML.replace('_s','');
}

function setValue(val){
	var obj = document.getElementById('fileNameArr');
	var objValue = obj.value;
	if(val==""){
		obj.value = val;
	}else{
		if(objValue == "") objValue = val;
		else objValue += ","+val;
		
		obj.value = objValue;
	}
	//alert(obj.value);
}

function _confirm(){
	var obj = document.getElementById("fileNameArr");
	if(obj.value != ""){
		return "您已经上传了文件，但是还没有留言。";
	}
}

function setShowForm(bFlag){
	if(bFlag){
		window.onbeforeunload = null;
	}else{
		window.onbeforeunload = _confirm;
	}
}

// submit form info
function submitForm(form_id, actionURL, target){
	document.forms[form_id].target=target;
	document.forms[form_id].action=actionURL;
	document.forms[form_id].submit();
	document.forms[form_id].reset();	
}

// check info
function checkDetail(){
	var name=document.getElementById('name');
	var tel=document.getElementById('tel');
	if(name.value=="" || tel.value==""){
		alert("名称及联系电话不能为空！");
		return false;
	}
	return true;
}

function checkInfo(){
	var message=document.getElementById('message');
	if(message.value==""){
		alert("留言不能为空！");
		return false;
	}
	return true;
}

function addLoadEvent(func){
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}
