//Ajax
//Browser Support Code
function ajaxContentBlock(cid){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Ajax Error. Please use Firefox or Internet Explorer!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//Response text could go here (ie Content Block is now Live)
		}
	}
	
	//Update Content block Status to Active
	if (document.getElementById('status' + cid).checked){
		var status = "check";
		var queryString = "?action=" + status + "&cid=" + cid;
	}
	//Update Content block Status to Inactive
	else {
		var status = "uncheck";
		var queryString = "?action=" + status + "&cid=" + cid;
	}
	
	ajaxRequest.open("GET", "/admin/javascript/ajax.php" + queryString, true);
	ajaxRequest.send(null); 
	
}


//Delete Page
function confirmationpage(PageID,AdminSiteFolder) {
	var answer = confirm("Are you sure you want to DELETE this Page? All content on this page will be deleted too.\n\nThis action CANNOT BE UNDONE!")
	if (answer){
		window.location = AdminSiteFolder+"edit-page.php?pid="+PageID+"&prev=/&action=delete";
	}
}

//Delete Content Block
function confirmationcontent(ContentID,AdminSiteFolder,Path) {
	var answer = confirm("Are you sure you want to DELETE this Content Block?\n\nThis action CANNOT BE UNDONE!")
	if (answer){
		window.location = AdminSiteFolder+"edit-contentblock.php?cid="+ContentID+"&prev="+Path+"&action=delete";
	}
}