function GetPage(page){
	var command = "";
		var ajaxRequest;  // The variable that makes Ajax possible!
		
		if (!document.getElementById('my_content')) {
			window.location.href = "http://www.iknowgo.com/my";
			return false;
		}
		
		if (document.getElementById("tab_"+page)) {
			DoTab(page);
		}
		
		document.getElementById("my_content").innerHTML = "<table width='100%'><tr><td align='center'><img src='/images/iknowgo_page_load.gif' alt='loading...' border=0 title='' /></td></tr></table>";
		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("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				//document.myForm.time.value = ajaxRequest.responseText;
				
				var ajaxDisplay = document.getElementById('my_content');
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
				switch(page) {
					case "my_command_add":
						document.getElementById("command").focus();
					break;
				}
			}
		}
		var queryString = "?action=" + command;
		ajaxRequest.open("GET", "/includes/"+page+".php" + queryString, true);
		ajaxRequest.send(null); 
	
}

function DoTab(tab_name) {
	
	document.getElementById("tab_my_command_add").className = "mytab_off";
	//document.getElementById("tab_my_albums").className = "mytab_off";
	//document.getElementById("tab_my_group").className = "mytab_off";
	document.getElementById("tab_my_commands").className = "mytab_off";
	//document.getElementById("tab_my_homepage").className = "mytab_off";

	document.getElementById("tab_"+tab_name).className = "mytab_on";
}


function CommandAdd() {
	var ajaxRequest;  // The variable that makes Ajax possible!
	var command = document.getElementById("command").value;
	var command_url =  document.getElementById("command_url").value;
	var command_type = document.getElementById("command_type").value;
	var command_url = document.getElementById("command_url").value;
	var command_use = document.getElementById("command_use").value;
	var user_id = document.getElementById("user_id").value;
	var values = "";
	
		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("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				//document.myForm.time.value = ajaxRequest.responseText;
				DoTab(page);
				var ajaxDisplay = document.getElementById('my_content');
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
			}
		}
		
		if (command=="" || command_url=="" || command_type=="" || command_url=="") {
			document.getElementById("error").innerHTML = "<span class='small'><img src='/images/iknowgo_icon_caution.gif' align='absbottom' border='0' alt='All fields are required' />&nbsp; All fields are required</span>";
			return;
		}
		var queryString = "?action=" + command;
		
			ajaxRequest.open("GET", "includes/"+page+".php" + queryString, true);
			ajaxRequest.send(null); 
	
}

var command = "";
var command_url = "";
var command_type = "";
var command_desc = "";
var command_use = "";
var user_id = "";


function CheckAdd() {
	command = document.getElementById("command").value;
	if (command=='') {
		command = document.command_add.command.value;
	}
	command = command.replace(/&/g,"%^*");

	command_url = document.getElementById("command_url").value;
	command_url = command_url.replace(/&/g,"%^*");
	command_url = command_url.replace(/#/g,"**5^");
	command_type = document.getElementById("command_type").value;
	command_type = command_type.replace(/&/g,"%^*");
	command_desc = document.getElementById("command_desc").value;
	command_desc = command_desc.replace(/&/g,"%^*");
	command_use = document.getElementById("command_use").value;
	user_id = document.getElementById("user_id").value;
	//if (user_id=='1') {
		//alert("url="+command_url+", type="+command_type+", desc="+command_desc+", command="+command);
		//alert(document.command_add.command.value);
	//}
	var err = "";
	if (command==""|| command_url=="" || command_type=="" || command_desc=="") {
		err = "<span class='small'><img src='/images/iknowgo_icon_caution.gif' align='absbottom' border='0' alt='' />&nbsp;All fields are required</span> ";
		document.getElementById("error").innerHTML = err;
		return false;
	} else {
		AddCommand();
		return false;
	}
	
}



function AddCommand() {
	var ajaxRequest;  // The variable that makes Ajax possible!
	var values = "";
	
		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("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
			
				var ajaxDisplay = document.getElementById('command_content');
				var theresponse = ajaxRequest.responseText;
				
				if (theresponse.indexOf("***crs2007***invalid_url")>-1) {
					document.getElementById("command_url").value = "";
					document.getElementById("command_url").focus();
					document.getElementById("error").innerHTML = "<span class='small'><img src='/images/iknowgo_icon_caution.gif' align='absmiddle' border='0' alt='All fields are required' />&nbsp;Invalid URL<br />must start with http://, https://, ftp://, etc...</span>";
				}else if(theresponse.indexOf("***crs2007***invalid_command")>-1) {
					document.getElementById("command").value = "";
					document.getElementById("command").focus();
					document.getElementById("error").innerHTML = "<span class='small'><img src='/images/iknowgo_icon_caution.gif' align='absmiddle' border='0' alt='All fields are required' />&nbsp;Invalid command<br />only numbers, letters and _ are allowed.</span>";
				} else {
					ajaxDisplay.innerHTML = theresponse;
				}
			}
		}
		
		if (command=="" || command_url=="" || command_type=="" || command_desc=="") {
			document.getElementById("error").innerHTML = "<span class='small'><img src='/images/iknowgo_icon_caution.gif' align='absmiddle' border='0' alt='All fields are required' />&nbsp;All fields are required</span>";
			return;
		}
		
		var q = "?action=add_command&command="+command+"&command_url="+command_url+"&command_type="+command_type+"&command_desc="+command_desc+"&command_use="+command_use;
		if (user_id!="") {
			ajaxRequest.open("GET", "/includes/my_command_add_submit.php" + q, true);
			ajaxRequest.send(null); 
		} else {
			window.location.href = "/includes/set_backurl.php"+q;
		}
}


function ModifyCommand() {
	var ajaxRequest;  // The variable that makes Ajax possible!
	var values = "";
	
	command_url = document.getElementById("m_command_url").value;
	command_type = document.getElementById("m_command_type").value;
	command_desc = document.getElementById("m_command_desc").value;
	command = document.getElementById("m_command").value;
	command_use = document.getElementById("m_command_use").value;
	
		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("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
			
				var ajaxDisplay = document.getElementById('command_content');
				var theresponse = ajaxRequest.responseText;
					ajaxDisplay.innerHTML = theresponse;
					document.getElementById("command").focus();
			}
		}
		
		
		
		var q = "?action=add_command&command="+command+"&command_url="+command_url+"&command_type="+command_type+"&command_desc="+command_desc+"&command_use="+command_use
		
		ajaxRequest.open("GET", "/includes/my_command_add.php" + q, true);
		ajaxRequest.send(null); 
}



function UpdateCommand(cid,saction) {
	var ajaxRequest;  // The variable that makes Ajax possible!
	var values = "";
	
	
		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("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				var ajaxDisplay = document.getElementById('command_options_'+cid);
				var theresponse = ajaxRequest.responseText;
					ajaxDisplay.innerHTML = theresponse;
			}
		}
		
		
		var q = "?action="+saction+"&command_id="+cid;
		//alert(q);
		
		ajaxRequest.open("GET", "/includes/my_command_edit.php" + q, true);
		ajaxRequest.send(null); 
}

function UpdateCommandSave(cid) {
	var ajaxRequest;  // The variable that makes Ajax possible!
	var values = "";
	
	var new_url = document.getElementById("update_command_url_"+cid).value;
	var new_desc = document.getElementById("update_command_desc_"+cid).value;
	var new_use = document.getElementById("update_command_use_"+cid).value;
	new_url = new_url.replace(/&/g,"%^*");
	new_url = new_url.replace(/#/g,"**5^");
	new_desc = new_desc.replace(/&/g,"%^*");
	
	if (new_url == "") {
		document.getElementById("update_command_url_"+cid).className = 'command_edit_error';
	}
	
	if (new_desc == "") {
		document.getElementById("update_command_desc_"+cid).className = 'command_edit_error';
	}
	
	
	if (new_desc=="" || new_url=="") {
		return;
	} else {
	
		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("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				var ajaxDisplay = document.getElementById('command_options_'+cid);
				var theresponse = ajaxRequest.responseText;
					ajaxDisplay.innerHTML = theresponse;
			}
		}
		
		
		var q = "?action=save&command_id="+cid+"&new_url="+new_url+"&new_desc="+new_desc+"&new_use="+new_use;
		
		
		ajaxRequest.open("GET", "/includes/my_command_edit.php" + q, true);
		ajaxRequest.send(null); 
	}
}




function CloseUpdateCommand(cid) {
	var ajaxRequest;  // The variable that makes Ajax possible!
	var values = "";
	
	
		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("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
			
				var ajaxDisplay = document.getElementById('command_options_'+cid);
				var theresponse = ajaxRequest.responseText;
					ajaxDisplay.innerHTML = theresponse;
			}
		}
		
		
		
		var q = "?action=view&command_id="+cid;
		
		ajaxRequest.open("GET", "/includes/my_command_edit.php" + q, true);
		ajaxRequest.send(null); 
}


function ToggleEdit(oele) {
	var ele = document.getElementById(oele);
	var result_class = (ele.className=='command_regular') ? 'command_over' : 'command_regular';
	ele.className = result_class;
}






// ALBUM FUNCTIONS
var album_name = "";
var album_id = "";

function CheckAlbumAdd() {
	album_name = document.getElementById("album_name").value;
	album_name = album_name.replace(/&/g,"%^*");
	
	var err = "";
	
	if (album_name =="") {
		err = "<span class='small'><img src='/images/iknowgo_icon_caution.gif' align='absbottom' border='0' alt='' />&nbsp;All fields are required</span> ";
		document.getElementById("error").innerHTML = err;
		return false;
	} else {
		UpdateAlbum();
		return false;
	}
}


function AddAlbum() {
	var ajaxRequest;  // The variable that makes Ajax possible!
	var values = "";
	document.getElementById("my_content").innerHTML = "<table width='100%'><tr><td align='center'><img src='/images/iknowgo_page_load.gif' alt='loading...' border=0 title='' /></td></tr></table>";
		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("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
			
				var ajaxDisplay = document.getElementById('my_content');
				var theresponse = ajaxRequest.responseText;
				
				ajaxDisplay.innerHTML = theresponse;
			}
		}
		
		
		ajaxRequest.open("GET", "/includes/my_album_add.php", true);
		ajaxRequest.send(null); 
}


function UpdateAlbum() {
	var ajaxRequest;  // The variable that makes Ajax possible!
	var values = "";
	var album_name = "";
	var user_id = "";
	var q = "";
	
		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("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
			
				var ajaxDisplay = document.getElementById('my_content');
				var theresponse = ajaxRequest.responseText;
				
				ajaxDisplay.innerHTML = theresponse;
			}
		}
		
		album_name = document.getElementById("album_name").value;
		album_name = album_name.replace(/&/g,"%^*");
		
		user_id = document.getElementById("user_id").value;
		q = "?album_name="+album_name+"&user_id="+user_id+"&action=album_add";
		ajaxRequest.open("GET", "/includes/my_album_add_submit.php"+q, true);
		ajaxRequest.send(null); 
}