function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();


function send_form_signup(){

document.form2.submit();

}

function vip_login(){
	

if( document.getElementById('email').value != "" && document.getElementById('password').value != "" ){

	var strSubmitContent = 'lg='+document.getElementById('email').value+'&pd='+document.getElementById('password').value;
	http.open('POST', 'loginres.php', true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    http.onreadystatechange = handleResponse;
    http.send(strSubmitContent);
	
}else{

	  document.getElementById('show_res').style.display = 'inline';
	  document.getElementById('loading').innerHTML = "<span style=\"color:#FF0000;\">email &amp; password required</span>";


}

}

function handleResponse() {
    if(http.readyState == 4){
	    
        var response = http.responseText;
        var update = new Array();
		
		if(response == "denied"){
		 document.getElementById('loading').innerHTML = "<span style=\"color:#FF0000;\">incorrect login.</span>";

		}
		else if(response == "granted"){
		 window.location = 'admin.php';
		 //alert("u are logged in");
		}


    }
	else{
	  document.getElementById('show_res').style.display = 'inline';
	  document.getElementById('loading').innerHTML = "<span style=\"color:#462d06;\">loging in...</span>";
	}
	  
}




var http2 = createRequestObject();

function set_openclose(prodid, type){
    //alert("set_openclose");
	
	
  	var strSubmitContent = 'prodid='+prodid+"&type="+type;
	http2.open('POST', 'opencloseres.php?type=1', true);
	http2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    http2.onreadystatechange = opencloseResponse;
    http2.send(strSubmitContent);


}

function opencloseResponse() {
	//alert("opencloseResponse");
    if(http2.readyState == 4){
	    
		
    }
	else{ 

	}
	  
}


function load_se(){

  tb_show("", "loadestimator.php?TB_iframe=true&height=655&width=965&modal=true", "");

}

function gotobookaunit(){
	
	var winloc = window.location.toString();
	//alert(winloc);
	var loc_array = winloc.split('/');
	//alert(loc_array[loc_array.length-1]);
	if( loc_array[loc_array.length-1] == 'book_a_storage_unit.php' )
	  window.location = 'book_a_storage_unit.php';
	else if( loc_array[loc_array.length-1].substring(0,23) == 'book_a_storage_unit.php' )
	  window.location = loc_array[loc_array.length-1];
	else
	  window.location = 'book_a_storage_unit.php';
	/*
	if( loc_array[loc_array.length-1] != 'book_a_storage_unit.php' ){
	  //alert("this will eventually redirect u to the booking page");
	  window.location = 'book_a_storage_unit.php';
	}else{
	  alert("we are here already");
	}*/
}

function reloadcurrent(){
	window.location.href = window.location.href;	
}

function gotobookaunit_close(){

	var winloc = window.location.toString();
	//alert(winloc);
	var loc_array = winloc.split('/');
	//alert(loc_array[loc_array.length-1]);
	if( loc_array[loc_array.length-1] == 'book_a_storage_unit.php' )
	  window.location = 'book_a_storage_unit.php';
	else if( loc_array[loc_array.length-1].substring(0,23) == 'book_a_storage_unit.php' )
	  window.location = loc_array[loc_array.length-1];
	  	
	
}
