//root="http://localhost/sites/edeyfx";
//root="http://bluenorth.no-ip.info/edeyfx";
root="http://www.edeyfx.com";
// JavaScript Document
function side_collapse(option,flag) {
    var dstr=option+"="+flag;
    document.cookie=dstr+"; path=/";
    window.location.reload(false);
}
function hl_image (id, flag) {
	if (flag==1) { 
		//document.getElementById(id).style.backgroundColor = '#FFFDc0'; 
		document.getElementById(id).style.borderColor = '#555599'; 
	}
	else { 
		//document.getElementById(id).style.backgroundColor = '#FFFFFF';
		document.getElementById(id).style.borderColor = '#CCCCCC'; 
	}
}
function get_content_list(cat,subcat,m,id,page)
{  
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) { document.getElementById("contentlist").innerHTML=xmlHttp.responseText; }
    }
	controlstr = "control/getcontent.php?c="+cat+"&s="+subcat+"&m="+m+"&id="+id+"&page="+page;
    xmlHttp.open("GET",controlstr,true);
    xmlHttp.send(null);
}
// Function to delete a body from the database
function delete_body (id) {
	string = "Are you sure you want to delete?";
	if (window.confirm(string)) {
		idstring = "control/addbody.php?id="+id;
		window.location.href=idstring;		
	}
}
// Function to delete a listing from the database
function delete_listing (id, path) {
	string = "Are you sure you want to delete this entry?";
	if (window.confirm(string)) {
		idstring = "control/delete.php?id="+id+"&path="+path;
		window.location.href=idstring;		
	}
}

function delete_subcategory(cat,subcat,usergroup) {
	string = "Are you sure? All items in this subcategory will be lost.";
	if (window.confirm(string)) {
		idstring = "control/addsubcat.php?cat="+cat+"&subcat="+subcat+"&usergroup="+usergroup+"&mode=delete";
		window.location.href=idstring;
	}
}
function edit_subcategory(subcat,category,usergroup) {
	var newcat;	
	if (newcat=window.prompt("Old Subcategory: "+subcat, "Enter the name for the new subcategory")) {
		idstring = "control/addsubcat.php?cat="+category+"&subcat="+subcat+"&new="+newcat+"&usergroup="+usergroup;
		window.location.href=idstring;
	}
}

function check_username (username) {
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) { document.getElementById("unerror").innerHTML=xmlHttp.responseText; }
	}
	controlstr = "control/checkusername.php?un="+username;
	xmlHttp.open("GET",controlstr,true);
	xmlHttp.send(null);	
}

function get_member_list(sortmethod,toggle,checkall)
{  
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) { document.getElementById("memberlist").innerHTML=xmlHttp.responseText; }
    }
	controlstr = "control/getmemberlist.php?sort="+sortmethod+"&toggle="+toggle+"&checkall="+checkall;
    xmlHttp.open("GET",controlstr,true);
    xmlHttp.send(null);
}

function get_member(id)
{  
  var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) {
		document.getElementById("memberview").innerHTML=xmlHttp.responseText;
      }
    }
	controlstr = "control/getmember.php?id="+id;
    xmlHttp.open("GET",controlstr,true);
    xmlHttp.send(null);
}
function change_body(project,item,slide) {
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) {
		document.getElementById("showdescription").innerHTML=xmlHttp.responseText;
      }
    }
	controlstr = root+"/control/getimage.php?mode=description&project="+project+"&item="+item+"&slide="+slide;
    xmlHttp.open("GET",controlstr,true);
    xmlHttp.send(null);
}
function change_bodynav(project,item,slide) {
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) {
		document.getElementById("showdescriptionnav").innerHTML=xmlHttp.responseText;
      }
    }
	controlstr = root+"/control/getimage.php?mode=descriptionnav&project="+project+"&item="+item+"&slide="+slide;
    xmlHttp.open("GET",controlstr,true);
    xmlHttp.send(null);
}
function change_projectname(project,item,slide) {
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) {
		document.getElementById("projectname").innerHTML=xmlHttp.responseText;
      }
    }
	controlstr = root+"/control/getimage.php?mode=projectname&project="+project+"&item="+item+"&slide="+slide;
    xmlHttp.open("GET",controlstr,true);
    xmlHttp.send(null);
}
function change_slidemarker(project,item,slide) {
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) {
		document.getElementById("slidemarker").innerHTML=xmlHttp.responseText;
      }
    }
	controlstr = root+"/control/getimage.php?mode=slidemarker&project="+project+"&item="+item+"&slide="+slide;
    xmlHttp.open("GET",controlstr,true);
    xmlHttp.send(null);
}
// Edey FX - load image
function get_image(project,item,slide)
{
	change_body(project,item,slide);
	change_bodynav(project,item,slide);
    change_projectname(project,item,slide);
    change_slidemarker(project,item,slide);
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) {
		document.getElementById("showimage").innerHTML=xmlHttp.responseText;
      }
    }
	controlstr = root+"/control/getimage.php?mode=image&project="+project+"&item="+item+"&slide="+slide;
    xmlHttp.open("GET",controlstr,true);
    xmlHttp.send(null);
}

// This function will return a XMLHttp connection
function get_xmlHttp () {
  var xmlHttp;
  try { // Firefox, Opera 8.0+, Safari   
		xmlHttp=new XMLHttpRequest(); }
  catch (e) { // Internet Explorer    
	try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {
		try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    catch (e) { 
		alert("Your browser does not support AJAX!");
		return false;  
	}}}
	return xmlHttp;
}

// Form Verification
function check_for_empty(value,divid,message) {
	if (value == "") return_message = message;	
	else return_message = "";
	document.getElementById(divid).innerHTML=return_message;
}
