// JavaScript Document
var req=null;
var console=null;
var READY_STATE_UNINITIALIZED=0;
var READY_STATE_LOADING=1;
var READY_STATE_LOADED=2;
var READY_STATE_INTERACTIVE=3;
var READY_STATE_COMPLETE=4;
function sendRequest(url,params,HttpMethod)
{	
	if (!HttpMethod)
	{
		HttpMethod="POST";
	}
	req=initXMLHTTPRequest();
	if (req)
	{
		req.onreadystatechange=onReadyState;
		req.open(HttpMethod,url,true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(params);
	}
}
//****************************creating the XMLHTTPRequest object
function initXMLHTTPRequest()
{
	var xRequest=null;
	if (window.XMLHttpRequest)
	{
		xRequest=new XMLHttpRequest();
	} else if (window.ActiveXObject)
	{
		xRequest=new ActiveXObject
		("Microsoft.XMLHTTP");
	}
	return xRequest;
}



function ajax_create_page()
{
	value=document.getElementById('create_page_name').value;
	if(value=="") document.getElementById('error_page_name').style.display='block';
	else sendRequest("../ajax/ajaxpage.php","mode=insert_page&PageName="+value,"POST");
}

function ajax_delete_page()
{
	value=document.getElementById('delete_page_name').value;
	sendRequest("../ajax/ajaxpage.php","mode=delete_page&PageName="+value,"POST");
}

function ajax_create_menu()
{
	value=document.getElementById('create_menu_name').value;
	pos=document.getElementById('position').value;
	if(value=="") document.getElementById('error_menu_name').style.display='block';
	else sendRequest("../ajax/ajaxmenu.php","mode=insert_menu&MenuName="+value+"&Position="+pos,"POST");
}

function ajax_delete_menu()
{
	value=document.getElementById('delete_menu_name').value;
	sendRequest("../ajax/ajaxmenu.php","mode=delete_menu&MenuName="+value,"POST");
}

function ajax_create_submenu()
{
	value=document.getElementById('create_submenu_name').value;
	submenu=document.getElementById('submenu').value;
	if(value=="") document.getElementById('error_submenu_name').style.display='block';
	else sendRequest("../ajax/ajaxmenu.php","mode=insert_submenu&submenuName="+value+"&menuName="+submenu,"POST");
}
function ajax_delete_request()
{
	value=document.getElementById('delete_request_name').value;
	sendRequest("../ajax/ajaxrequest.php","mode=delete_request&requestName="+value,"POST");
}

function ajax_create_user()
{
	value=document.getElementById('create_user_name').value;
	pass=document.getElementById('create_user_pass').value;
	if(value=="") document.getElementById('error_user_name').style.display='block';
	else if(pass=="") document.getElementById('error_user_name').style.display='block';
	else sendRequest("../ajax/ajaxuser.php","mode=insert_user&userName="+value+"&pass="+pass,"POST");
}

function download(val,wh){
	sendRequest("../ajax/ajaxdownload.php","mode=download&wh="+wh+"&type="+val,"POST");
}

function send_email()
{
	fname=document.getElementById('fname').value;
	lname=document.getElementById('lname').value;
	email=document.getElementById('email').value;
	address=document.getElementById('address').value;
	phone=document.getElementById('phone').value;
	msg=document.getElementById('msg').value;
	
	param="mode=contact&fname="+fname+"&lname="+lname+"&email="+email+"&address="+address+"&phone="+phone+"&msg="+msg;
	sendRequest("ajax/ajaxemail.php",param,"POST");
	
}

function send_request()
{
	fname=document.getElementById('fname').value;
	lname=document.getElementById('lname').value;
	email=document.getElementById('email').value;
	address=document.getElementById('address').value;
	phone=document.getElementById('phone').value;
	msg=document.getElementById('msg').value;
	prod_list=document.getElementById('prod_list').value;
	
	param="mode=request&fname="+fname+"&lname="+lname+"&email="+email+"&address="+address+"&phone="+phone+"&msg="+msg+"&prod_list="+prod_list;
	sendRequest("ajax/ajaxemail.php",param,"POST");
	
}
