pic0= new Image(23,20); 
pic0.src="images/topcorner.jpg";
	
pic1= new Image(23,20); 
pic1.src="images/bottomcorner.jpg";

pic2= new Image(220,19); 
pic2.src="images/ajax-loader2.gif";

pic3= new Image(16,16); 
pic3.src="images/ajax-loader.gif";

pic4= new Image(16,16); 
pic4.src="images/delete.gif";

function submitorder(){
	var errorMsg = "";
	var errorMsgLong = "";
	
	name = document.checkout.clientname.value;
	tel = document.checkout.clientcontact.value;
	email = document.checkout.clientemail.value;
	country = document.checkout.clientcountry.value;
	
	if (name == ""){
		errorMsg += "\nName - Please enter your name";
	} else {
		if (name.length < 3){
		errorMsg += "\nName - Name too short";
		}
	}
	
	if (tel == ""){
		errorMsg += "\nContact Number - Please enter a contact number";	
	} else {
		if (tel.length < 7){
			errorMsg += "\nContact Number - too short";	
		}
	}
	
	if (email == "" || (email.indexOf("@", 0) == -1 || email.indexOf(".", 0) == -1)) {
		errorMsg +="\nEmail address - Please enter a valid email address";
	}
	
	if (country == ""){
		errorMsg += "\nCountry - Please enter your country";
	}
	
	if ((errorMsg != "") || (errorMsgLong != "")) {
		msg = "The form was not submitted as there are errors in your input\n";
		msg += "Please correct the following error(s) and re-submit the form.\n\n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		
		// Return false
		return false;
	}
	
	mail(name,tel,email,contact);
	
	// Return true
	return true;
}

function gotoProduct(prodid){
	document.location="product.php?pid=" + prodid;
}

function gotoImage(imageid){
	document.location="images.php?imageid=" + imageid;
}

function sendmail(name,emailaddress,message,contactid){
	
	var errorMsg = "";
	var errorMsgLong = "";
	
	if (name == ""){
		errorMsg += "\nYour Name - Please enter your name";
	} else {
		if (name.length < 3){
		errorMsg += "\nYour Name - Name too short";
		}
	}
	
	if (emailaddress == "" || (emailaddress.indexOf("@", 0) == -1 || emailaddress.indexOf(".", 0) == -1)) {
		errorMsg +="\nYour Email - Please enter a valid email address";
	}
	
	if ((errorMsg != "") || (errorMsgLong != "")) {
		msg = "The form was not submitted as there are errors in your input\n";
		msg += "Please correct the following error(s) and re-submit the form.\n\n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		
		// Return false
		return false;
	} else {
	
		document.getElementById('contactlist').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16"> Sending...';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'sendemail.php?cid='; //This is the path to the file we just finished making *
		var file1 = '&name='
		var file2 = '&email=';
		var file3 = '&message=';
    xmlhttp.open('GET', file + contactid + file1 + name + file2 + emailaddress + file3 + message, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('contactlist').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
	}
}

function mailresearcher(pageid){
	
	var errorMsg = "";
	var errorMsgLong = "";
	var name = document.rlist.name.value;
	var emailaddress = document.rlist.email.value;
	var message = document.rlist.message.value;
		
	if (name == ""){
		errorMsg += "\nYour Name - Please enter your name";
	} else {
		if (name.length < 3){
		errorMsg += "\nYour Name - Name too short";
		}
	}
	
	if (emailaddress == "" || (emailaddress.indexOf("@", 0) == -1 || emailaddress.indexOf(".", 0) == -1)) {
		errorMsg +="\nYour Email - Please enter a valid email address";
	}
	
	if ((errorMsg != "") || (errorMsgLong != "")) {
		msg = "The form was not submitted as there are errors in your input\n";
		msg += "Please correct the following error(s) and re-submit the form.\n\n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		
		// Return false
		return false;
	} else {
	
		document.getElementById(pageid).innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16"> Sending...';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'mailresearcher.php?pid='; //This is the path to the file we just finished making *
		var file1 = '&name='
		var file2 = '&email=';
		var file3 = '&message=';
    	xmlhttp.open('GET', file + pageid + file1 + name + file2 + emailaddress + file3 + message, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById(pageid).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
	}
}

function mailcontact(uid){
	
	var errorMsg = "";
	var errorMsgLong = "";
	var name = document.econtacts.name.value;
	var emailaddress = document.econtacts.email.value;
	var message = document.econtacts.message.value;
		
	if (name == ""){
		errorMsg += "\nYour Name - Please enter your name";
	} else {
		if (name.length < 3){
		errorMsg += "\nYour Name - Name too short";
		}
	}
	
	if (emailaddress == "" || (emailaddress.indexOf("@", 0) == -1 || emailaddress.indexOf(".", 0) == -1)) {
		errorMsg +="\nYour Email - Please enter a valid email address";
	}
	
	if ((errorMsg != "") || (errorMsgLong != "")) {
		msg = "The form was not submitted as there are errors in your input\n";
		msg += "Please correct the following error(s) and re-submit the form.\n\n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		
		// Return false
		return false;
	} else {
	
		document.getElementById('othercontact').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16"> Sending...';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'mailcontact.php?uid='; //This is the path to the file we just finished making *
		var file1 = '&name='
		var file2 = '&email=';
		var file3 = '&message=';
    	xmlhttp.open('GET', file + uid + file1 + name + file2 + emailaddress + file3 + message, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('othercontact').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
	}
}

function mailstudent(pageid){
	
	var errorMsg = "";
	var errorMsgLong = "";
	var name = document.rlist.name.value;
	var emailaddress = document.rlist.email.value;
	var message = document.rlist.message.value;
		
	if (name == ""){
		errorMsg += "\nYour Name - Please enter your name";
	} else {
		if (name.length < 3){
		errorMsg += "\nYour Name - Name too short";
		}
	}
	
	if (emailaddress == "" || (emailaddress.indexOf("@", 0) == -1 || emailaddress.indexOf(".", 0) == -1)) {
		errorMsg +="\nYour Email - Please enter a valid email address";
	}
	
	if ((errorMsg != "") || (errorMsgLong != "")) {
		msg = "The form was not submitted as there are errors in your input\n";
		msg += "Please correct the following error(s) and re-submit the form.\n\n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		
		// Return false
		return false;
	} else {
	
		document.getElementById(pageid).innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16"> Sending...';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'mailstudent.php?pid='; //This is the path to the file we just finished making *
		var file1 = '&name='
		var file2 = '&email=';
		var file3 = '&message=';
    	xmlhttp.open('GET', file + pageid + file1 + name + file2 + emailaddress + file3 + message, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById(pageid).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
	}
}

function contact(uid){
	
	
	if (uid <= 0 || uid > 4)  {
		
	} else {
		document.getElementById('othercontact').innerHTML = 'Loading...';
		document.getElementById('disable').style.display='';
		document.getElementById('othercontact').style.display='block';
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'buildform.php?uid='; //This is the path to the file we just finished making *
    	xmlhttp.open('GET', file + uid, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                    document.getElementById('othercontact').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
	}
}



function changeyear(theyear){
	document.getElementById('newslist').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/getbyyear.php?year='; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file + theyear, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('newslist').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
}

function sortit(sortorder){
	document.getElementById('contactlist').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16"> sorting by '+ sortorder +'';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'sortlist.php?order='; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file + sortorder, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('contactlist').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
}

function mail(name,tel,email,country){
	document.getElementById('mailer').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'sendorder.php?name='; //This is the path to the file we just finished making *
		var file2 = '&tel=';
		var file3 = '&email=';
		var file4 = '&country='
    xmlhttp.open('GET', file + name + file2 + tel + file3 + email + file4 + country, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
					  //window.location.reload();
					  emptymailedCart();
                      document.getElementById('mailer').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					  document.getElementById('mailer').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
					  window.location.reload();
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function addtoCart(productid){
	document.getElementById(productid).innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/addproduct.php?pid='; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file + productid, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById(productid).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
}

function removeItem(prod){
	qprod = "q" + prod;
	document.getElementById(qprod).innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/removeitem.php?pid='; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file + prod, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById(qprod).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					  totalcost();
					  if ( content == "0"){
						window.location.reload();  
					  }
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function addItem(prod){
	qprod = "q" + prod;
	document.getElementById(qprod).innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/additem.php?pid='; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file + prod, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById(qprod).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					  totalcost();
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function deleteItem(prod){
	qprod = "q" + prod;
	document.getElementById(qprod).innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/deleteitem.php?pid='; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file + prod, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById(qprod).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					  totalcost();
					  if ( content == "0"){
						window.location.reload();  
					  }
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function totalcost(){
	document.getElementById('total').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/gettotal.php'; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('total').innerHTML = content; //Change the inner content of your div to the newly retrieved content **** 
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function emptyCart(){
	document.getElementById('cart').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/emptycart.php'; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      //document.getElementById('cart').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					  totalcost();
					  window.location.reload();  
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function emptymailedCart(){
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/emptycart.php'; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
					  window.location.reload();  
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function addtoCartb(productid){
	document.getElementById("b"+productid).innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/addproduct.php?pid='; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file + productid, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById("b"+productid).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}


function getCategory(categoryid,categoryname){
	
		document.getElementById('products').innerHTML = '<img src="images/ajax-loader2.gif" width="220" height="19">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/getproductbycategory.php?cid='; //This is the path to the file we just finished making *
		var file2 = '&cname=';
    xmlhttp.open('GET', file + categoryid + file2 + categoryname, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('products').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					  document.getElementById('products').focus();
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function getGallery(categoryid,categoryname){
	
		document.getElementById('galleries').innerHTML = '<img src="images/ajax-loader2.gif" width="220" height="19">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/getimagesbygallery.php?cid='; //This is the path to the file we just finished making *
		var file2 = '&cname=';
    xmlhttp.open('GET', file + categoryid + file2 + categoryname, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('galleries').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					  document.getElementById('galleries').focus();
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function changemonth(month,year){
		document.getElementById('calchange').innerHTML = '<img src="images/ajax-loader2.gif" width="220" height="19">';
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/monthcalendar.php?month='; //This is the path to the file we just finished making *
		var file2 = '&year=';
    xmlhttp.open('GET', file + month + file2 + year, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('calchange').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

var menuids=["treemenu1"];

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	  ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
  }
}

function searchFunction(){
		var squery = document.searchform.searchquery.value;
		document.getElementById('searchresult').innerHTML = '<img src="images/ajax-loader.gif" width="16" height="16">';
	
		var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                    xmlhttp = new
                    ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'includes/searching.php?query='; //This is the path to the file we just finished making *
    xmlhttp.open('GET', file + squery, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    	xmlhttp.onreadystatechange=function() {
        	if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('searchresult').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;	
}

function handleKeyPress(e){
var key=e.keyCode || e.which;
if (key==13){
searchFunction();
}
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal)