// Get the HTTP Object
function getHTTPObject(){
   if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) return new XMLHttpRequest();
   else {
      alert("Your browser does not support AJAX.");
      return null;
   }
}   
function updatewlcm(gg){
var http = new XMLHttpRequest();
var url = "home.php";
var introtext = document.editform.intro.value;
var fstext = document.editform.fs.value;
var edittext = document.editform.edit.value;
var params = "edit=" + edittext + "&intro=" + introtext + "&fs=" + fstext + "";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		// document.getElementById('myBody').innerHTML = http.responseText;
		loadSite(gg);
	}
}
http.send(params);
}

function gogo(){
	loadSite('reports.php?mess=gggggg');
}
function addnewsadd(gg){
var http = new XMLHttpRequest();
var url = "reports.php";
var titletext = document.addnews.title.value;
var newstext = document.addnews.news.value;
var addtext = document.addnews.add.value;
var params = "add=" + addtext + "&title=" + titletext + "&news=" + newstext + "";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		// document.getElementById('myBody').innerHTML = http.responseText;
		loadSite(gg);
	}
}
http.send(params);
}
function addreportadd(gg){
var http = new XMLHttpRequest();
var url = "reports.php";
var titletext = document.addreport.title.value;
var srctext = document.addreport.src.value;
var addrtext = document.addreport.addr.value;
var params = "addr=" + addrtext + "&title=" + titletext + "&src=" + srctext + "";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		// document.getElementById('myBody').innerHTML = http.responseText;
		loadSite(gg);
	}
}
http.send(params);
}


// Change the value of the outputText field
function setOutput(){
   if(httpObject.readyState == 4){
      document.getElementById('myBody').innerHTML = httpObject.responseText;
	  
	document.getElementById('myBody').style.display = '';
	document.getElementById('loader').style.display = 'none';
   }
}


// Implement business logic
function loadSite(ff){
	document.getElementById('loader').style.display = '';
	document.getElementById('myBody').style.display = 'none';
   httpObject = getHTTPObject();
   if (httpObject != null) {
      httpObject.open("GET", ff, true);
      httpObject.send(null);
      httpObject.onreadystatechange = setOutput;
   }
}

// Change the value of the outputText field
function setOutput2(ff){
   if(httpObject.readyState == 4){
		loadSite(ff + '&finished=1');
	}
}
// Implement business logic
function loadSite2(ff){
	document.getElementById('loader').style.display = '';
	document.getElementById('myBody').style.display = 'none';
   httpObject = getHTTPObject();
   if (httpObject != null) {
      httpObject.open("GET", ff, true);
      httpObject.send(null);
      httpObject.onreadystatechange = function() {//Call a function when the state changes.
	if(httpObject.readyState == 4 && httpObject.status == 200) {
		// document.getElementById('myBody').innerHTML = http.responseText;
		setOutput2(ff);
	}
   }
   }
}
var httpObject = null;

// Implement business logic
function mainenter(){
   httpObject = getHTTPObject();
   if (httpObject != null) {
      httpObject.open("GET", 'mainenter.php', true);
      httpObject.send(null);
      httpObject.onreadystatechange = function() {//Call a function when the state changes.
	if(httpObject.readyState == 4 && httpObject.status == 200) {
		 document.getElementById('bodyin').innerHTML = httpObject.responseText;
	}
   }
   }
}
var httpObject = null;
// Implement business logic
function maienenter(){
document.getElementById('scripted').innerHTML = '<div style="display:none;" class="overlay" id="overlay"><div class="lightbox" id="lightbox"><div align="center" class="container"><div style="display:none; background:#C7E5E9" align="center" id="containerbodycontentloading"><table width="600" border="0" align="center" cellspacing="0" cellpadding="0"><tr height="300" valign="middle"><td style="text-align:center; color:#000; font-size:7pt" width="600">I N I T I A L I Z I N G &nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;.</td></tr></table></div><div id="containerbodycontent" style="display:none; background:#C7E5E9" align="center"></div></div></div>';

   httpObject = getHTTPObject();
   if (httpObject != null) {
      httpObject.open("GET", 'memberpage.php', true);
      httpObject.send(null);
      httpObject.onreadystatechange = function() {//Call a function when the state changes.
	if(httpObject.readyState == 4 && httpObject.status == 200) {
		 document.getElementById('bodyin').innerHTML = httpObject.responseText;
	}
   }
   }
}
var httpObject = null;


	function hihihi(){
	$('AjaxUploaderFiles_Loader').style.display='none';
	CuteWebUI_AjaxUploader_Initialize('AjaxUploaderFiles_Loader');
	}

	 function CuteWebUI_AjaxUploader_OnTaskComplete(task)
	 {
		// var div=document.createElement("DIV");
		// var link=document.createElement("A");
		// link.setAttribute("href","savefiles/"+task.FileName);
		// link.innerHTML="You have uploaded file : savefiles/"+task.FileName;
		// link.target="_blank";
		// div.appendChild(link);
		// document.body.appendChild(div);
		document.addreport.src.value = task.FileName;
		document.getElementById('hh2').innerHTML = task.FileName;
		document.getElementById('button').style.display = "none";
		document.getElementById('input').style.display = "";
	 }
	 function remove()
	 {
		document.addreport.src.value = '';
		document.getElementById('hh2').innerHTML = '';
		document.getElementById('button').style.display = "";
		document.getElementById('input').style.display = "none";
	 }
	 
	 
	 
	function goSubmit(f,ml){
		if(!(ml)){
			mylink = 'main.php';
		} else mylink = ml + '.php';
		if(f=="uwlcm"){
		mylink = ml;
		}
		if(f=="login" ||  f=="logout"){
		mylink = ml;
		if(!(ml)){
			mylink = 'main.php';
		}
		}
		if(f=="addreport"){
		tit = document.addreport.title;
		src = document.addreport.src;		
		if(tit.value==""){
		  alert("Please Type In The Report Title.");
		  tit.focus();
		  return false;
		}
		if(src.value==""){
		  alert("Please Select Your File.");
		  return false;
		}
		}
		if(f=="addnews"){
		tit = document.addnews.title;
		ns = document.addnews.news;	
		if(tit.value==""){
		  alert("Please Type In The News Title.");
		  tit.focus();
		  return false;
		}
		if(ns.value==""){
		  alert("Please Type In The News.");
		  ns.focus();
		  return false;
		}
		}
		if(f=="newuser"){
		UserName = document.newuser.UserName;
		password = document.newuser.password;
		password2 = document.newuser.password2;
		type = document.newuser.type;
		unit = document.newuser.unit;
		newunitname = document.newuser.newunitname;
		fname = document.newuser.name;
		country = document.newuser.country;
		phone = document.newuser.phone;
		email = document.newuser.email;
		if(UserName.value==""){
		  alert("Please Type In The User Name");
		  UserName.focus();
		  return false;
		}
		if(password.value==""){
		  alert("Please Type In A Password.");
		  password.focus();
		  return false;
		}
		if(password.value!=password2.value){
		  alert("Passwords Do Not Match.");
		  password.focus();
		  return false;
		}
		if(type.value==""){
		  alert("Please Choose The User Type.");
		  type.focus();
		  return false;
		}
		if(unit.value==""){
		  alert("Please Choose The Unit.");
		  unit.focus();
		  return false;
		}
		if(unit.value=="newunit"){
			if(newunitname.value==""){
			  alert("Please Enter The New Unit Title.");
			  newunitname.focus();
			  return false;
			  }
		}
		if(fname.value==""){
		  alert("Please Type In The Full Name.");
		  fname.focus();
		  return false;
		}
		if(country.value==""){
		  alert("Please Type In The Country.");
		  country.focus();
		  return false;
		}
		if(phone.value==""){
		  alert("Please Type In The Phone.");
		  phone.focus();
		  return false;
		}
		if(email.value==""){
		  alert("Please Type In The Email Address.");
		  email.focus();
		  return false;
		}
		if (!email.value.match('^[A-z0-9\._-]+@[a-z0-9][a-z0-9_-]*(\.[a-z0-9_-]+)*'+'\.([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|'+'int|mil|museum|name|net|org|pro|travel)$', 'i'))
		{
		  alert("Please Type In A Correct Email Address.");
		  email.focus();
		  return false;
		}
		}
	window.addEvent('domready', function() {
	$(f).addEvent('submit', function(e) {
		e.stop();
		//Empty the log and show the spinning indicator.
		$('mainenter').style.display='none';
		$('mainloading').style.display='';
		//Set the options of the form's Request handler. 
		//("this" refers to the $('myForm') element).
		this.set('send', {onComplete: function(response) {
			$('bodyin').set('html', response);
				//$('bodyin2').set('html', response);			 
				
		}});
		//Send the form.
		this.send();
	
	});
	});
	};
	
	
function goSubmithref(f,ml){
		if(!(ml)){
			mylink = 'main.php';
		} else mylink = ml + '.php';
		if(ml=="ru"){
		mylink = mylink + "?run=" + f;
		}
		
	window.addEvent('domready', function() {
	$(f).addEvent('click', function(e) {
		e.stop();
		//Empty the log and show the spinning indicator.
		$('mainenter').style.display='none';
		$('mainloading').style.display='';
		//Set the options of the form's Request handler. 
		//("this" refers to the $('myForm') element).
		this.set('send', {onComplete: function(response) {
			$('bodyin').set('html', response);
				//$('bodyin2').set('html', response);			 
				
		}});
		//Send the form.
		this.send();
	});
	});
	};
	
	

function show(id1,id2,id3,id4,id5){
if(id1) document.getElementById(id1).style.display = '';
if(id2) document.getElementById(id2).style.display = '';
if(id3) document.getElementById(id3).style.display = '';
if(id4) document.getElementById(id4).style.display = '';
if(id5) document.getElementById(id5).style.display = '';
}

function hide(id1,id2,id3,id4,id5){
if(id1) document.getElementById(id1).style.display = 'none';
if(id2) document.getElementById(id2).style.display = 'none';
if(id3) document.getElementById(id3).style.display = 'none';
if(id4) document.getElementById(id4).style.display = 'none';
if(id5) document.getElementById(id5).style.display = 'none';
}

function goSubmithrefing(f,ml){
		mylink = '../' + ml + '.php';
		if (f == "corporate" || f == "enterprise" || f == "business"){
		mylink = ml + '.php?frameurl='+f;
		}
	window.addEvent('domready', function() {
	$(f).addEvent('click', function(e) {
		e.stop();
		document.getElementById('overlay').style.display = '';
		$('containerbodycontent').style.display='none';
		window.setTimeout( function() { $('containerbodycontentloading').style.display=''; } , 500);
			
		
			
		//Empty the log and show the spinning indicator.
		//$('mainenter').style.display='none';
		//$('mainloading').style.display='';
		//Set the options of the form's Request handler. 
		//("this" refers to the $('myForm') element).
		this.set('send', {onComplete: function(response) {
			window.setTimeout( function() { $('containerbodycontent').set('html', response); $('containerbodycontentloading').style.display='none'; $('containerbodycontent').style.display='';  } , 1000);
			
		}});
		//Send the form.
		this.send();
	});
	});
	};
