function $m(id){return document.getElementById(id);}
function imgHeight(){
	var h = $m('bigImg').height;
	var c = $m('content').style.height;
		//if(c>h){
			$m('img_holder').style.height = h+"px";
		//}
	}
///////////////////////////////////////////////////////////////////////////
//<!-- /AJAX STUFF 
//Browser Support Code
function ajaxFunction(funct,username){
	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("Your browser broke!");
				return false;
			}
		}
	}
if(funct == "changePass"){
//alert(funct);
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var update_return = document.getElementById('changed_pass').innerHTML = "Password changed | ";
			var close_update = document.getElementById('pass_change');
			close_update.style.display = "none";
		}
	}
	var newPass = document.getElementById('newPass').value;
	var queryString = "?newPass=" + newPass + "&username=" + username;
	ajaxRequest.open("GET", "ajaxFunct.php" + queryString, true);
	ajaxRequest.send(null); 
}
if(funct == "save"){
//alert(funct);
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var previewUpdate = document.getElementById('preview').innerHTML = dataToUpdate;
			var editUpdate = document.getElementById('mce').innerHTML = dataToUpdate;
alert("4");
		}
	}
	var dataToUpdate = document.getElementById('mce').value
	var queryString = "?change_content=" + dataToUpdate + "&page=" + page;
	ajaxRequest.open("GET", "ajaxFunct.php" + queryString, true);
	ajaxRequest.send(null);
}
if(funct == "comments"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
//close it
	document.getElementById('cPost'+username).style.display="none";
//clear it
	var Na_blank = document.getElementById("n" + username);
	var Co_blank = document.getElementById("c" + username);
	var Em_blank = document.getElementById("e" + username);
		Na_blank.value="Name";		
		Co_blank.value="Your comments";
		Em_blank.value="E-mail (only visible to author)";
		Na_blank.style.color="grey";
		Co_blank.style.color="grey";
		Em_blank.style.color="grey";
		Na_blank.style.fontStyle="italic";
		Co_blank.style.fontStyle="italic";
		Em_blank.style.fontStyle="italic";
//put the new stuff in
	document.getElementById('newComments'+username).innerHTML=ajaxRequest.responseText;
		}
	}
	var Na = document.getElementById("n" + username).value;
	var Co = document.getElementById("c" + username).value;
	var Em = document.getElementById("e" + username).value;
var CqueryString = "?cid="+username+"&n="+Na+"&c="+Co+"&e="+Em;
	ajaxRequest.open("GET", "ajaxFunct.php" + CqueryString, true);
	ajaxRequest.send(null);
}//end pubed
if(funct == "c_delete"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById("cid_"+username).style.display="none";
		}
	}
	var con = confirm('Are you sure you want to delete this comment?');
		if(con==true){
	ajaxRequest.open("GET", "ajaxFunct.php?c_delete=" + username, true);
	ajaxRequest.send(null); 
		}
}//end c_delete
if(funct == "viewer"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		Effect.toggle('viewer', 'blind', {duration: 0.5 });
			var dVid = document.getElementById('Vholder');
			dVid.innerHTML=ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "ajaxFunct.php?viewer=1&id="+username, true);
	ajaxRequest.send(null); 
}//viewer
if(funct == "notAdminViewer"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		Effect.toggle('viewer', 'blind', {duration: 0.5 });
			var dVid = document.getElementById('Vholder');
			dVid.innerHTML=ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "login/ajaxFunct.php?notAdmin=1&viewer=1&id="+username, true);
	ajaxRequest.send(null); 
}//notAdminViewer
if(funct == "cycleAdmin"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var dVid = document.getElementById('Vholder');
			dVid.innerHTML=ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "login/ajaxFunct.php?notAdmin=1&viewer=1&id="+username, true);
	ajaxRequest.send(null); 
		
}//cycleadmin
if(funct == "cycle"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var dVid = document.getElementById('Vholder');
			dVid.innerHTML=ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "ajaxFunct.php?viewer=1&id="+username, true);
	ajaxRequest.send(null); 
		
}//cycle
if(funct == "updateViewer"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('titleUpdate'+username).innerHTML=Tinput;
		}
	}
	var Tinput = document.getElementById('Tinput'+username).value;
	var Dinput = document.getElementById('Dinput'+username).value;
	ajaxRequest.open("GET", "ajaxFunct.php?updateViewer=1&Tinput="+Tinput+"&Dinput="+Dinput+"&id="+username, true);
	ajaxRequest.send(null); 
		
}//updateViewer
if(funct == "viewerDelete"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('viewerThumb'+username).style.display="none";
		}
	}
var con = confirm('are you sure you want to delete this entry?');
		if(con==true){
	ajaxRequest.open("GET", "ajaxFunct.php?viewerDelete=1&id="+username, true);
	ajaxRequest.send(null); 
}		
}//updateViewer
if(funct == "send"){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if(ajaxRequest.responseText!=""){
				document.getElementById('errorSpan').innerHTML=ajaxRequest.responseText;
				new Effect.Morph('errorSpan', {
					style: 'background:#980000; color:#fff;', // CSS Properties
					duration: 0.3 // Core Effect properties
				});
				new Effect.Morph('errorSpan', {
					style: 'background:#fff;color:#000;', // CSS Properties
					duration: 0.3, delay: 0.5 // Core Effect properties
				});
			} else {
			document.getElementById('contact').style.display="none";
			document.getElementById('errorSpan').style.display="none";
			document.getElementById('thanks').style.display="";
		}//validation
		}
	}
	var n = document.getElementById('name').value;
	var p = document.getElementById('phone').value;
	var e = document.getElementById('email').value;
	var c = document.getElementById('comments').value;
	var query = "?send=1&n="+n+"&p="+p+"&e="+e+"&c="+c;
	ajaxRequest.open("GET", "login/ajaxFunct.php"+query, true);
	ajaxRequest.send(null); 
		
}//send
}//end master ajaxFunction

// END AJAX-->

/////////////////////
function showImage_________old(){
	var theDiv = $m('img_holder');
//width and height;
	var Dheight = $m('bigImg').height;
//hide the content
	tSlide('content');
//make the div big
	$('img_holder').morph('height:'+Dheight+'px;');
//	theDiv.style.height=Dheight+'px';
//img/text swap
	setTimeout("self.scrollTo(0,"+ Dheight +")",320);
	t('seeFullImg');
	t('backToText');
}
function showImage(){
	tSlide('content');
	tSlide('contentHeader');
	tSlide('contentFooter');
	//img/text swap
	//setTimeout("self.scrollTo(0,"+ Dheight +")",320);
	t('seeFullImg');
	t('backToText');
}
function toText(){
	var cHeight = $m('content').style.height;
	tSlide('content');
	tSlide('contentHeader');
	tSlide('contentFooter');
	setTimeout("returnText()",300);
	t('seeFullImg');
	t('backToText');
}
function returnText(){
	var cHeight = $m('content').offsetHeight + 20;
	$('img_holder').morph('height:'+cHeight+'px;');
//$('img_holder').morph('height:500px;');
}
///////////////////////////////////////////////////////////////////////////
function OpenComments (c){
   window.open(c,'comments','width=550,height=510,scrollbars=yes,status=yes,resizable=yes');
}
///////////////////////////////////////////////////////////////////////////
function toggle_sub(id, opt){
	var Element = document.getElementById(id);
	if(opt == 'open')
		Element.style.display = "";
	else if(opt == 'close')
		Element.style.display = "none";
}
///////////////////////////////////////////////////////////////////////////
function tSlide(id){
		Effect.toggle(id, 'appear', {duration: 0.3 });
}

///////////////////////////////////////////////////////////////////////////
function t(id){
	var i = document.getElementById(id);
		if(i.style.display==""){
			i.style.display="none";
		}else if(i.style.display=="none"){
			i.style.display="";
		}
}
///////////////////////////////////////////////////////////////////////////
shortcut.add("Ctrl+shift+l",function() {
	var l_login = document.getElementById('l_login');
		l_login.style.display = "";
		//get the focus
		document.getElementById('myusername').focus();
},{
	'type':'keydown',
	'propagate':true,
	'target':document
});
///////////////////////////////////////////////////////////////////////////
function preview(io){
	if (io=="ON"){
	var p = document.getElementById('preview');
	var c = document.getElementById('content');
		c.style.display = "none";
		p.style.display = "";
	//open the "you need to save box"
	var s = document.getElementById('l_needToSave');
		s.style.display = "";
		document.getElementById('switch').innerHTML = "<a class=\"l_options\" onclick=\"preview('OFF')\" href='#'>Return to edit</a> |" 
	}else if (io=="OFF"){
	var p = document.getElementById('preview');
	var c = document.getElementById('content');
		c.style.display = "";
		p.style.display = "none";
		document.getElementById('switch').innerHTML = "<a class=\"l_options\" onclick=\"preview('ON')\" href='#'>Preview this page</a> |" 
	}
}
///////////////////////////////////////////////////////////////////////////
function searchfield_focus(obj)
{
obj.style.color=""
obj.style.fontStyle=""
if (obj.value=="New Password"){
	obj.value=""
	}
}
///////////////////////////////////////////////////////////////////////////
function clear_focused(id){
	var clear_it_out = document.getElementById(id);
	if(clear_it_out.value=="Name"||clear_it_out.value=="Your comments"||clear_it_out.value=="E-mail (only visible to author)"||clear_it_out.value=="New Title"){
		clear_it_out.value="";
		clear_it_out.style.color = "grey";
		clear_it_out.style.fontStyle= "italic";
		}
		clear_it_out.style.color = "";
		clear_it_out.style.fontStyle= "";
}
//////////
function newCat(){
	if($m('newCat').innerHTML==""){
		t('listCat');
		$m('newCat').innerHTML="<input type='text' id='newCatName' name='cat' class='rt' />"
		$m('switchCat').innerHTML="select a category";
		$m('listCat').value='';
	}else{
		t('listCat');
		$m('newCat').innerHTML=""
		$m('switchCat').innerHTML="create a category";
		$m('newCatName').value='';
	}
}

