/**********************************************************************************************************************************************************************/
/*                                                                                                                                                                    */
/*                                                         ALL THE FUNCTION IN THIS PAGE ARE DESIGNED FOR AJAX                                                        */
/*                                                                                                                                                                    */
/**********************************************************************************************************************************************************************/
/**********************************************************************************************************************************************************************/
/* ESTABLISH A CONNECTION WITH THE SERVER     											                                                                              */
/**********************************************************************************************************************************************************************/
//Don't modifie this one !!! 
//If you know what your doing, you may have to change all the function in this file
function file(filePath)
{
	if(window.XMLHttpRequest) // FIREFOX
	{
  		xhr_object = new XMLHttpRequest();
	}
	else
	{
		if(window.ActiveXObject) // IE
		{
  			xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{
  			return(false); // can't create object
		}
	}
	
	//submit the ajax request
	xhr_object.open("GET", filePath, false);
	xhr_object.send(null);
	
	if(xhr_object.readyState == 4) //server response completed
	{
		return(xhr_object.responseText); //return the content of the page which was called
	}
	else
	{
		return(false);
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AJAX FOR THE ADMINISTRATION SECTION
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**********************************************************************************************************************************************************************/
/* GENERATE A COMPANY NUMBER FOR THE MANUAL CREATION OF A COMPANY ACCOUNT			  											                                      */
/**********************************************************************************************************************************************************************/
function generateCompNb()
{
	url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/generateCompNb.asp";
	
	content = file(url); //call the Ajax builder function
	document.getElementById('refNb').value = content; //write the content of the page in a block	
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'CUSTOMER COMMENT' PAGE IN THE ADMINISTRATION SECTION  											                                      */
/**********************************************************************************************************************************************************************/
function updateContent(dataType, action, id, page)
{
	//dataType -> What kind of data must be displayed: old comments or new comments or all
	//action -> What we are asked to do with the data: delete or accept a comment
	//id -> Unique number of the comment
	//page -> What page must displayed after updated data
	
	if(dataType == "new" && action == "")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContent.asp?dataType=new&action=null&page="+page;
	if(dataType == "new" && action == "delete")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContent.asp?dataType=new&action=delete&id="+id+"&page="+page;
	if(dataType == "new" && action == "accept")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContent.asp?dataType=new&action=accept&id="+id+"&page="+page;
	
	if(dataType == "old" && action == "")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContent.asp?dataType=old&action=null&page="+page;
	if(dataType == "old" && action == "delete")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContent.asp?dataType=old&action=delete&id="+id+"&page="+page;
	
	if(dataType == "all" && action == "")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContent.asp?dataType=all&action=null&page="+page;
	if(dataType == "all" && action == "delete")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContent.asp?dataType=all&action=delete&id="+id+"&page="+page;
	if(dataType == "all" && action == "accept")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContent.asp?dataType=all&action=accept&id="+id+"&page="+page;
	
	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block	
}

/**********************************************************************************************************************************************************************/
/* CLEAR THE CONTENT OF A POST IN THE FORUM IF IT IS UNAPPROPRIATE                  											                                      */
/**********************************************************************************************************************************************************************/
function clearForumPost(id,forum)
{
	//id -> Unique number of a post
	
	url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/clearForumPost.asp?id="+id+"&forum="+forum;
	
	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block	
}

/**********************************************************************************************************************************************************************/
/* DELETE A FORUM 													                  											                                      */
/**********************************************************************************************************************************************************************/
function deleteForum(id)
{
	//id -> Unique number of a forum
	
	url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/deleteForum.asp?id="+id;
	
	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block	
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'BLOCK ACCOUNT' PAGE IN THE ADMINISTRATION SECTION  											                                          */
/**********************************************************************************************************************************************************************/
function updateContentAccount(accType, action, id, page)
{
	//accType -> What kind of account must be displayed: company or private
	//action -> What we are asked to do with an account: lock or unlock or delete it
	//id -> Unique number of the account
	//page -> What page must displayed after updated data
	
	if(action == "")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContentAccount.asp?action=null&page="+page+"&accType="+accType;
	
	if(action == "update")
	{
		refCode = document.getElementById("refCode"+id).value;
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContentAccount.asp?action=update&id="+id+"&page="+page+"&accType="+accType;
		url += "&refCode="+refCode;
	}

	if(action == "lock")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContentAccount.asp?action=lock&id="+id+"&page="+page+"&accType="+accType;
	
	if(action == "unlock")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContentAccount.asp?action=unlock&id="+id+"&page="+page+"&accType="+accType;
		
	if(action == "delete")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContentAccount.asp?action=delete&id="+id+"&page="+page+"&accType="+accType;
	
	if(action == "clear")
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateContentAccount.asp?action=clear&id="+id+"&page="+page+"&accType="+accType;
		
	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block
}

function searchAccount()
{
	kwd = document.getElementById("keyword").value;
	fld = document.getElementById("field").options[document.getElementById("field").selectedIndex].value;
	if(kwd == "")
		alert("Please enter a keyword !");
	else
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/searchAccount.asp?kwd="+kwd+"&fld="+fld;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContent').innerHTML = content;
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'MANAGE CONSOLE' PAGE IN THE ADMINISTRATION SECTION											                                          */
/**********************************************************************************************************************************************************************/
function updateContentConsole(action, id, page)
{
	//action -> What we are asked to do with the data
	//id -> Unique number of a console
	//page -> What page must displayed after updated data
	
	if(action == "")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/console/changePage.asp?page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "displayInfo")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/console/displayInfoConsole.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function

		document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "update")
	{
		n = document.getElementById("console").value;
		b = document.getElementById("repairPrice").value;
		l = document.getElementById("laser").value;
		s = document.getElementById("screen").value;
		w = document.getElementById("wireless").value;
		c = document.getElementById("casing").value;
		h = document.getElementById("hardrive").value;
		o = document.getElementById("other").value;
		p = document.getElementById("pic").value;
		
		if(n == "")
		{
			alert("Fill in the field 'Name' before submitting the request !");	
		}
		else
		{
			if(b == "") b = 0;
			if(l == "") l = 0;
			if(s == "") s = 0;
			if(w == "") w = 0;
			if(c == "") c = 0;
			if(h == "") h = 0;
			if(o == "") o = 0;
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/console/updateConsole.asp?id="+id+"&page="+page;
			url += "&n="+n+"&b="+b+"&l="+l+"&s="+s+"&w="+w+"&c="+c+"&h="+h+"&o="+o+"&p="+p;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/console/resetInfo.asp?&page="+page;
			
			content = file(url);
			document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "create")
	{
		n = document.getElementById("console").value;
		b = document.getElementById("repairPrice").value;
		l = document.getElementById("laser").value;
		s = document.getElementById("screen").value;
		w = document.getElementById("wireless").value;
		c = document.getElementById("casing").value;
		h = document.getElementById("hardrive").value;
		o = document.getElementById("other").value;
		p = document.getElementById("pic").value;
		
		if(n == "")
		{
			alert("Fill in the field 'Name' before submitting the request !");	
		}
		else
		{
			if(b == "") b = 0;
			if(l == "") l = 0;
			if(s == "") s = 0;
			if(w == "") w = 0;
			if(c == "") c = 0;
			if(h == "") h = 0;
			if(o == "") o = 0;
		
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/console/createConsole.asp?page="+page;
			url += "&n="+n+"&b="+b+"&l="+l+"&s="+s+"&w="+w+"&c="+c+"&h="+h+"&o="+o+"&p="+p;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "delete")
	{	
		//remove the associated picture
		url = "http://www.totalconsolerepair.co.uk/images/console/remove.asp?id="+id;
		content = file(url);
		//update content
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/console/deleteConsole.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'MANAGE CONSOLE' PAGE IN THE ADMINISTRATION SECTION											                                          */
/**********************************************************************************************************************************************************************/
function updateContentPeripheral(action, id, page)
{
	//action -> What we are asked to do with the data
	//id -> Unique number of a peripheral
	//page -> What page must displayed after updated data
	
	if(action == "")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/peripheral/changePage.asp?page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "displayInfo")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/peripheral/displayInfoPeripheral.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function

		document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "update")
	{
		periphName = document.getElementById("periphName").value;
		cost = document.getElementById("cost").value;
		console = document.getElementById("console").options[document.getElementById("console").selectedIndex].value;
		
		if(periphName == "")
		{
			alert("Fill in the field 'Peripheral Name' before submitting the request !");	
		}
		else
		{
			if(cost == "") cost = 0;
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/peripheral/updatePeripheral.asp?id="+id+"&page="+page;
			url += "&console="+console+"&periphName="+periphName+"&cost="+cost;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/peripheral/resetInfo.asp?&page="+page;
			
			content = file(url);
			document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
		}
	}

	if(action == "create")
	{
		var periphName = document.getElementById("periphName").value;
		var cost = document.getElementById("cost").value;
		var console = document.getElementById("console").options[document.getElementById("console").selectedIndex].value;
		
		if(periphName == "")
		{
			alert("Fill in the field 'Peripheral Name' before submitting the request !");	
		}
		else
		{
			if(cost == "") cost = 0;
		
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/peripheral/createPeripheral.asp?page="+page;
			url += "&console="+console+"&periphName="+periphName+"&cost="+cost;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "delete")
	{
		//update content
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/peripheral/deletePeripheral.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'MANAGE IPOD' PAGE IN THE ADMINISTRATION SECTION     												                                      */
/**********************************************************************************************************************************************************************/
function updateContentIpod(action, id, page)
{
	//action -> What we are asked to do with the data
	//id -> Unique number of an ipod
	//page -> What page must displayed after updated data
	
	if(action == "")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/ipod/changePage.asp?page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "displayInfo")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/ipod/displayInfoIpod.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function

		document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "update")
	{
		n = document.getElementById("ipod").value;
		b = document.getElementById("repairPrice").value;
		s = document.getElementById("screen").value;
		w = document.getElementById("wireless").value;
		c = document.getElementById("casing").value;
		h = document.getElementById("hardrive").value;
		o = document.getElementById("other").value;
		p = document.getElementById("pic").value;
		
		if(n == "")
		{
			alert("Fill in the field 'Name' before submitting the request !");	
		}
		else
		{
			if(b == "") b = 0;
			if(s == "") s = 0;
			if(w == "") w = 0;
			if(c == "") c = 0;
			if(h == "") h = 0;
			if(o == "") o = 0;
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/ipod/updateIpod.asp?id="+id+"&page="+page;
			url += "&n="+n+"&b="+b+"&s="+s+"&w="+w+"&c="+c+"&h="+h+"&o="+o+"&p="+p;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/ipod/resetInfo.asp?&page="+page;
			
			content = file(url);
			document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "create")
	{
		n = document.getElementById("ipod").value;
		b = document.getElementById("repairPrice").value;
		s = document.getElementById("screen").value;
		w = document.getElementById("wireless").value;
		c = document.getElementById("casing").value;
		h = document.getElementById("hardrive").value;
		o = document.getElementById("other").value;
		p = document.getElementById("pic").value;
		
		if(n == "")
		{
			alert("Fill in the field 'Name' before submitting the request !");	
		}
		else
		{
			if(b == "") b = 0;
			if(s == "") s = 0;
			if(w == "") w = 0;
			if(c == "") c = 0;
			if(h == "") h = 0;
			if(o == "") o = 0;
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/ipod/createIpod.asp?page="+page;
			url += "&n="+n+"&b="+b+"&s="+s+"&w="+w+"&c="+c+"&h="+h+"&o="+o+"&p="+p;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "delete")
	{	
		//remove the associated picture
		url = "http://www.totalconsolerepair.co.uk/images/ipod/remove.asp?id="+id;
		content = file(url);
		//update content
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/ipod/deleteIpod.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'MANAGE VOUCHERS' PAGE IN THE ADMINISTRATION SECTION     	    									                                      */
/**********************************************************************************************************************************************************************/
function updateContentVoucher(action, id, page)
{
	//action -> What we are asked to do with the data
	//id -> Unique number of an voucher
	//page -> What page must displayed after updated data
	
	if(action == "")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/voucher/changePage.asp?page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "displayInfo")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/voucher/displayInfoVoucher.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function

		document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "update")
	{
		n = document.getElementById("voucher").value;
		pr = document.getElementById("price").value;
		p = document.getElementById("pic").value;
		
		if(n == "")
		{
			alert("Fill in the field 'Name' before submitting the request !");	
		}
		else
		{
			if(pr == "") pr = 0;
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/voucher/updateVoucher.asp?id="+id+"&page="+page;
			url += "&n="+n+"&pr="+pr+"&p="+p;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/voucher/resetInfo.asp?&page="+page;
			
			content = file(url);
			document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "create")
	{
		n = document.getElementById("voucher").value;
		pr = document.getElementById("price").value;
		p = document.getElementById("pic").value;
		
		if(n == "")
		{
			alert("Fill in the field 'Name' before submitting the request !");	
		}
		else
		{
			if(pr == "") pr = 0;
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/voucher/createVoucher.asp?page="+page;
			url += "&n="+n+"&pr="+pr+"&p="+p;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "delete")
	{	
		//remove the associated picture
		url = "http://www.totalconsolerepair.co.uk/images/repairVouchers/remove.asp?id="+id;
		content = file(url);
		//update content
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/voucher/deleteVoucher.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'MANAGE CONSOLE' PAGE IN THE ADMINISTRATION SECTION											                                          */
/**********************************************************************************************************************************************************************/
function updateContentJobs(action, id, page)
{
	//action -> What we are asked to do with the data
	//id -> Unique number of a job
	//page -> What page must displayed after updated data
	
	if(action == "")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/job/changePage.asp?page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "displayInfo")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/job/displayInfoJob.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function

		document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
	}
	
	if(action == "update")
	{
		p = document.getElementById("post").value;
		s = document.getElementById("skills").value;
		
		if(p == "" || s == "")
		{
			alert("Fill all the fields before submitting the request !");	
		}
		else
		{			
			s = s.replace(";","");
			p = p.replace(";","");
			s = encodeURIComponent(s);
			p = encodeURIComponent(p);

			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/job/updateJob.asp?id="+id+"&page="+page;
			url += "&p="+p+"&s="+s;

			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/job/resetInfo.asp?&page="+page;
			
			content = file(url);
			document.getElementById('dynamicContentLeft').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "create")
	{
		p = document.getElementById("post").value;
		s = document.getElementById("skills").value;
		
		if(p == "" || s == "")
		{
			alert("Fill in all the required fields before submitting the request !");	
		}
		else
		{
			s = s.replace(";","");
			p = p.replace(";","");
			s = encodeURIComponent(s);
			p = encodeURIComponent(p);
			
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/job/createJob.asp?page="+page;
			url += "&p="+p+"&s="+s;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
		}
	}
	
	if(action == "delete")
	{	
		//update content
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/job/deleteJob.asp?id="+id+"&page="+page;
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContentRight').innerHTML = content; //write the content of the page in a block
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'PICTURE MANAGER' PAGE IN THE ADMINISTRATION SECTION  											                                          */
/**********************************************************************************************************************************************************************/
function updateImgMgr(path)
{
	//path -> path of the image that is going to be deleted
	
	if(path != "")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/updateImgMgr.asp?path="+path;
	
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block	
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AJAX FOR THE USER AREA
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**********************************************************************************************************************************************************************/
/* UPDATE THE PERSONAL IMAGE OF A MEMBER IN THE 'WELCOME' PAGE 												                                                          */
/**********************************************************************************************************************************************************************/
function updateImage(img)
{
	//img -> name of the selected image
	
	url = "http://www.totalconsolerepair.co.uk/login/members/private/ajax/updatePersonalImage.asp?img="+img;
	
	content = file(url); //call the Ajax builder function
	if(content == 1)
		document.location.href = "http://www.totalconsolerepair.co.uk/login/members/private/welcome.asp";
	else
		alert(content);		
}

/**********************************************************************************************************************************************************************/
/* UPDATE TABLE FORUM IN THE PAGE 'FORUM'                                            											                                      */
/**********************************************************************************************************************************************************************/
function updateContentForum(page)
{
	//id -> Unique number of a post
	
	url = "http://www.totalconsolerepair.co.uk/login/members/private/ajax/updateContentForum.asp?page="+page;
	
	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block	
}

/**********************************************************************************************************************************************************************/
/* UPDATE POST CONTENT IN THE FORUM                                                 											                                      */
/**********************************************************************************************************************************************************************/
function updateContentPost(page,id)
{
	//id -> Unique number of a post
	
	url = "http://www.totalconsolerepair.co.uk/login/members/private/ajax/updateContentPost.asp?page="+page+"&id="+id;
	
	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block	
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AJAX FOR EVERYBODY
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**********************************************************************************************************************************************************************/
/* CHANGE PAGE IN THE JOB PAGE  											                                      */
/**********************************************************************************************************************************************************************/
function updateRightBlock(cons)
{
	//page -> What page must displayed after updated data
	
	url = "http://www.totalconsolerepair.co.uk/consoleRepairs/ajax/updateRightBlock.asp?cons="+cons;

	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block	
}

/**********************************************************************************************************************************************************************/
/* CHANGE PAGE IN THE JOB PAGE  											                                      */
/**********************************************************************************************************************************************************************/
function changePageJobs(page)
{
	//page -> What page must displayed after updated data
	
	url = "http://www.totalconsolerepair.co.uk/contactUs/ajax/changePageJob.asp?page="+page;

	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block	
}

/**********************************************************************************************************************************************************************/
/* CHECK IF A LOGIN IS AVAILABLE                     											                                                                      */
/**********************************************************************************************************************************************************************/
function loginOk(login)
{
	//login -> login which is going to be tested
	
	if(login != '')
   	{
		if(login.length<4) //login too short
			writediv('<span style="color:#cc0000"><b>'+login+' :</b> This login is too short</span>', 'false');
		else 
			if(login.length>15) //login too long
		 		writediv('<span style="color:#cc0000"><b>'+login+' :</b> This login is too long</span>', 'false');
			else 
				if(texte = file('http://www.totalconsolerepair.co.uk/login/newAccount/includes/isAvailable.asp?login='+escape(login)))
		 		{
					if(texte == 1) //login unavailable
						writediv('<span style="color:#cc0000"><b>'+login+' :</b> This login is unavailable</span>', 'false');
					else 
						if(texte == 2) //login available
							writediv('<span style="color:#1A7917"><b>'+login+' :</b> This login is available</span>', 'true');
						else
							writediv('', 'false'); //in case of error in isAvailable.asp, nothing will be displayed
		 		}
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'CUSTOMER COMMENT' PAGE 											                                                                      */
/**********************************************************************************************************************************************************************/
function updateComment(page)
{
	//page -> What page must displayed after updated data
	
	url = "http://www.totalconsolerepair.co.uk/contactUs/ajax/updateCustComment.asp?page="+page;
	
	content = file(url); //call the Ajax builder function
	document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE FAULT COMBOBOX IN THE 'REPAIR PRICES' PAGE IN THE CONSOLE REPAIR SECTION 											                      */
/**********************************************************************************************************************************************************************/
function displayFault(console,fault)
{
	//console -> name of the selected console
	//fault -> name of the selected fault
	
	if(console != "none" && fault!="none")
	{
		url = "http://www.totalconsolerepair.co.uk/consoleRepairs/ajax/updateContentPrices.asp?console="+console+"&fault="+fault;
		
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE FAULT COMBOBOX IN THE 'PRICE LIST' PAGE IN THE IPOD REPAIR SECTION  											                          */
/**********************************************************************************************************************************************************************/
function displayFaultIpod(ipod,fault)
{
	//ipod -> name of the selected ipod
	//fault -> name of the selected fault
	
	if(ipod != "none" && fault!="none")
	{
		url = "http://www.totalconsolerepair.co.uk/iPodRepairs/ajax/updateContentPrices.asp?ipod="+ipod+"&fault="+fault;
		
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block
	}
}

/**********************************************************************************************************************************************************************/
/* UPDATE THE CONTENT OF THE 'MANAGE SHOP SUCCESS' PAGE                                          											                          */
/**********************************************************************************************************************************************************************/
function updateContentShopSuccess(id,action,page)
{
	//ipod -> name of the selected ipod
	//fault -> name of the selected fault

	if(action == "")
	{
		url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/shopSuccess/changePage.asp?page="+page;
		
		content = file(url); //call the Ajax builder function
		document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block
	}
	if(action == "update")
	{
		payedConsole = document.getElementById("payedConsole"+id).value;
		if(payedConsole != 0 && payedConsole != "")
		{
			url = "http://www.totalconsolerepair.co.uk/login/admin/ajax/shopSuccess/updatePayedConsole.asp?page="+page+"&id="+id;
			url += "&payedConsole="+payedConsole;
			
			content = file(url); //call the Ajax builder function
			document.getElementById('dynamicContent').innerHTML = content; //write the content of the page in a block
		}
		else
		{
			alert("The Field 'Paid Today' is empty for this console !");	
		}
	}
}