// JavaScript Document
function pageup() {
	var posi;
	posi = document.documentElement.scrollTop;
	moveObje(posi);
}
function moveObje(position) {
	move = position / 7;
	point = parseInt(position - move);
	scrollTo(0,point);
	if (point > 0) { setTimeout("moveObje(point)",1); }
}

//left space
function ltrim(s){
return s.replace( /^[" "|"　"]*/, "");
}
//right space
function rtrim(s){
return s.replace( /[" "|"　"]*$/, "");
}
//left and right space
function trim(s){
return rtrim(ltrim(s));
} 

function black(num){
   num.back();
   return false;
}

function resetBtn(fm){
    fm.reset();
    return false;
}

function showDiv(num){
	var num = num;
	var img1 = document.getElementById("a");
	var img2 = document.getElementById("b");
	var img3 = document.getElementById("c");
	switch(num){
		case 1 : img1.setAttribute("src", img1.getAttribute("src").replace("_b.", "_a."));
				 img2.setAttribute("src", img2.getAttribute("src").replace("_a.", "_b."));
				 img3.setAttribute("src", img3.getAttribute("src").replace("_a.", "_b."));
		break;
		case 2 : img1.setAttribute("src", img1.getAttribute("src").replace("_a.", "_b."));
				 img2.setAttribute("src", img2.getAttribute("src").replace("_b.", "_a."));
				 img3.setAttribute("src", img3.getAttribute("src").replace("_a.", "_b."));
		break;
		case 3 :img1.setAttribute("src", img1.getAttribute("src").replace("_a.", "_b."));
				img2.setAttribute("src", img2.getAttribute("src").replace("_a.", "_b."));
				img3.setAttribute("src", img3.getAttribute("src").replace("_b.", "_a."));
		break;
	}
}


function applyForm(){
	var company = trim(document.getElementById("company").value);
	var name = trim(document.getElementById("name").value);
	var tel = trim(document.getElementById("tel").value);
	var email = trim(document.getElementById("email").value);
	var people = trim(document.getElementById("people").value);
	var reg = new RegExp(/^([a-zA-Z0-9]+[_|\_|\.|\-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|\-]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/);	

	var info = "";
	if(company==""){
		info += "请输入公司名称\n";
	}
	if(name==""){
		info += "请输入联系人姓名\n";
	}
	if (tel == "") {
		info += "请输入电话号码\n";
	}
	if(email=="" || !reg.test(email)){
		info += "请输入正确的Email地址\n";	
	} 
	if(people==""){
		info += "请选择咨询项目\n";
	}
	
	if(info!=""){
		alert(info);
		return false;
	}else{
		return true;
	}
}

function merumagaForm(){
	var email = trim(document.getElementById("email").value);
	var remail = trim(document.getElementById("remail").value);
	var reg = new RegExp(/^([a-zA-Z0-9]+[_|\_|\.|\-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|\-]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/);	

	var info = "";
	if(email=="" || !reg.test(email)){
		info += "请输入正确的Email地址\n";	
	} 
	if(remail==""){
		info += "请输入正确的Email地址\n";
	}
	if(email != remail){
		info +="两次输入的Email地址不一致\n";
	}
	
	if(info!=""){
		alert(info);
		return false;
	}else{
		return true;
	}
}

function contactForm(){
	var company = trim(document.getElementById("company").value);
	var name = trim(document.getElementById("name").value);
	var tel = trim(document.getElementById("tel").value);
	var email = trim(document.getElementById("email").value);
	var message = trim(document.getElementById("message").value);
	var reg = new RegExp(/^([a-zA-Z0-9]+[_|\_|\.|\-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|\-]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/);	

	var info = "";
	if(company==""){
		info += "请输入公司名称\n";
	}
	if(name==""){
		info += "请输入联系人姓名\n";
	}
	if (tel == "") {
		info += "请输入电话号码\n";
	}
	if(email=="" || !reg.test(email)){
		info += "请输入正确的Email地址\n";	
	} 
	if(message==""){
		info += "请输入内容\n";
	}
	
	if(info!=""){
		alert(info);
		return false;
	}else{
		return true;
	}
}

function Disable(e){
  var Itxt = document.getElementById("btn");
  if(e.checked==true)
  {
   Itxt.disabled=false;
  }
  else
  {
   Itxt.disabled=true;
  }
 }

function setTab(n){
  var deploy1=document.getElementById("deploy1");
  var deploy2=document.getElementById("deploy2");
  var a1=document.getElementById("n1");
  var a2=document.getElementById("n2");
  
  switch(n){
	 case 1 : deploy1.style.display="block";
	 		  deploy2.style.display="none";
			  a1.className="cur";
			  a2.className="";
			  break;
	 case 2 : deploy1.style.display="none";
	 		  deploy2.style.display="block";
			  a1.className="";
			  a2.className="cur";
			  break;
	 }
}

function addDOMLoadEvent(func) {
    if (!window.__load_events) {
       var init = function () {
           // quit if this function has already been called
           if (arguments.callee.done) return;
           // flag this function so we don't do the same thing twice
           arguments.callee.done = true;
           // kill the timer
           if (window.__load_timer) {
               clearInterval(window.__load_timer);
               window.__load_timer = null;
           }
           // execute each function in the stack in the order they were added
           for (var i=0;i < window.__load_events.length;i++) {
              window.__load_events[i]();
           }
           window.__load_events = null;
       };
       // for Mozilla/Opera9
       if (document.addEventListener) {
           document.addEventListener("DOMContentLoaded", init, false);
       }
      
       // for Internet Explorer
       /*@cc_on @*/
       /*@if (@_win32)
           document.write("<scr"+"ipt id=__ie_onload defer src=//0><\/scr"+"ipt>");
           var script = document.getElementById("__ie_onload");
           script.onreadystatechange = function() {
               if (this.readyState == "complete") {
                   init(); // call the onload handler
               }
           };
       /*@end @*/
      
       // for Safari
       if (/WebKit/i.test(navigator.userAgent)) { // sniff
           window.__load_timer = setInterval(function() {
               if (/loaded|complete/.test(document.readyState)) {
                   init(); // call the onload handler
               }
           }, 10);
       }
       // for other browsers
       window.onload = init;
       // create event function stack
       window.__load_events = [];
    }
    // add function to event stack
    window.__load_events.push(func);
}
