var featureTimerId = 0;

function fn_setbtnfocus (vObjID)
	{
	document.getElementById('feature1').className = "sectionbtn mouse";
	document.getElementById('feature2').className = "sectionbtn mouse";
	document.getElementById('feature3').className = "sectionbtn mouse";
	document.getElementById('feature4').className = "sectionbtn mouse";
	document.getElementById('feature5').className = "sectionbtn mouse";
	
	document.getElementById('feature'+vObjID).className = "sectionbtnfocus mouse";
	
	document.getElementById('img1').style.visibility = "hidden";
	document.getElementById('img2').style.visibility = "hidden";
	document.getElementById('img3').style.visibility = "hidden";
	document.getElementById('img4').style.visibility = "hidden";
	document.getElementById('img5').style.visibility = "hidden";
		
	document.getElementById('img'+vObjID).style.visibility = "visible";

	document.getElementById('text1').style.visibility = "hidden";
	document.getElementById('text2').style.visibility = "hidden";
	document.getElementById('text3').style.visibility = "hidden";
	document.getElementById('text4').style.visibility = "hidden";
	document.getElementById('text5').style.visibility = "hidden";
		
	document.getElementById('text'+vObjID).style.visibility = "visible";

	}
	
	
function fn_flipfeature (vObjID)
	{
	fn_setbtnfocus(vObjID);
	vInt = (parseInt(vObjID)+1);
	if (vInt > 5) { vInt = 1 };
	featureTimerId = setTimeout('fn_flipfeature('+vInt+')', 5000 );
	}
	
	
function ajaxsetshootdata(vInt)
	{
	var xmlHttp;
	var params = '';
	
	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;
	      }
	    }
	  }
	  xmlHttp.onreadystatechange=function()
	    {
	    if(xmlHttp.readyState==4)
	      {
	      document.getElementById("divshootupdate"+vInt).innerHTML='[done]';
	      }
	    }
	    
	    params = "title=" + encodeURI(document.getElementById("txt_dir_title"+vInt).value)+
	    	"&subject=" + encodeURI(document.getElementById("subjectselect"+vInt).value)+
	    	"&mua=" + encodeURI(document.getElementById("muaselect"+vInt).value)+
	    	"&location=" + encodeURI(document.getElementById("locationselect"+vInt).value)+
	    	"&event=" + encodeURI(document.getElementById("eventselect"+vInt).value)+
    		"&id=" + encodeURI(vInt);
//alert(params);
		xmlHttp.open("POST","../include/ajax_shootdata_server.php",true);
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
		}
		
function ajaxsetphotodata(vInt)
	{
	var xmlHttp;
	var params = '';
	
	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;
	      }
	    }
	  }
	  xmlHttp.onreadystatechange=function()
	    {
	    if(xmlHttp.readyState==4)
	      {
	      document.getElementById("divphotoupdate"+vInt).innerHTML='[done]';
	      }
	    }
	    
	    params = "title=" + encodeURI(document.getElementById("txt_photo_title_"+vInt).value)+
    		"&is_nsfw=" + encodeURI(document.getElementById("chkNSFW_"+vInt).checked)+
    		"&is_portfolio=" + encodeURI(document.getElementById("chkPortfolio_"+vInt).checked)+
    		"&is_online=" + encodeURI(document.getElementById("chkonline_"+vInt).checked)+
    		"&is_public=" + encodeURI(document.getElementById("chkpublic_"+vInt).checked)+
    		"&active=" + encodeURI(document.getElementById("active_"+vInt).checked)+
    		"&id=" + encodeURI(vInt);
//alert(params);
		xmlHttp.open("POST","../include/ajax_photodata_server.php",true);
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
		}

		
		
function fn_setkeywordfocus (vPhoto_id, vObjID)
	{
	document.getElementById('divkeyword1-'+vPhoto_id).className = "keywordbtn mouse";
	document.getElementById('divkeyword2-'+vPhoto_id).className = "keywordbtn mouse";
	document.getElementById('divkeyword3-'+vPhoto_id).className = "keywordbtn mouse";
	document.getElementById('divkeyword4-'+vPhoto_id).className = "keywordbtn mouse";
	document.getElementById('divkeyword5-'+vPhoto_id).className = "keywordbtn mouse";
	document.getElementById('divkeyword6-'+vPhoto_id).className = "keywordbtn mouse";
	
	document.getElementById('divkeyword'+vObjID+'-'+vPhoto_id).className = "keywordbtnfocus mouse";
	
	document.getElementById('divkeywordlist1-'+vPhoto_id).style.visibility = "hidden";
	document.getElementById('divkeywordlist2-'+vPhoto_id).style.visibility = "hidden";
	document.getElementById('divkeywordlist3-'+vPhoto_id).style.visibility = "hidden";
	document.getElementById('divkeywordlist4-'+vPhoto_id).style.visibility = "hidden";
	document.getElementById('divkeywordlist5-'+vPhoto_id).style.visibility = "hidden";
	document.getElementById('divkeywordlist6-'+vPhoto_id).style.visibility = "hidden";
		
	document.getElementById('divkeywordlist'+vObjID+'-'+vPhoto_id).style.visibility = "visible";

	}

function ajaxsetcomment(vInt)
{

var xmlHttp;
var params = '';

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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("commentdisplay").innerHTML=xmlHttp.responseText;
      document.getElementById("txtComment").value = '';
      document.getElementById("commententry").innerHTML='Thank you for your comment!<br>All comments are moderated, and will be posted after review.<br><span class="mouse link" onclick="fnToggleComments();"> click to hide this section.</span>';
      }
    }
    
    params = "comment=" + encodeURI(document.getElementById("txtComment").value)+
    		"&user_id=" + encodeURI(document.getElementById("txtuser_id").value)+
    		"&photo_id=" + encodeURI(vInt);

	xmlHttp.open("POST","include/ajax_comment_server.php",true);
	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	}

	
function fnSetAttribute(vAttribute_id, vPhoto_id, vChecked)
	{
	var xmlHttp;
	var params = '';
	
	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;
	      }
	    }
	  }
	  xmlHttp.onreadystatechange=function()
	    {
	    if(xmlHttp.readyState==4)
	      {
	      document.getElementById("divphotoupdate"+vInt).innerHTML='[done]';
	      }
	    }
	    
	    params = "photo_id=" + encodeURI(vPhoto_id)+
    		"&attribute_id=" + encodeURI(vAttribute_id)+
    		"&checked=" + encodeURI(vChecked);
//alert(params);
		xmlHttp.open("POST","../include/ajax_setattribute_server.php",true);
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
		}	


function ajaxContact()
{


var xmlHttp;
var params = '';

//fnValidateContactForm();

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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("ajaxcontact").innerHTML=xmlHttp.responseText;
      }
    }
    
    params = "name=" + encodeURI(document.getElementById("name").value)+
    		"&email=" + encodeURI(document.getElementById("email").value)+
    		"&phone=" + encodeURI(document.getElementById("phone").value)+
    		"&body=" + encodeURI(document.getElementById("body").value);

	xmlHttp.open("POST","include/ajax_contact_server.php",true);
	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	}		
	
function fnToggleDiv(objname){
	var aDivs = document.getElementsByTagName("div");
	
	if(document.getElementById(objname).style.visibility == 'hidden'){
		
		//hideem();
		// div is hidden, so let's show it
		if (objname == 'photodetails') {
		
			document.getElementById('spPhotoDetails').innerHTML = 'Hide';
			}
		if (objname == 'commentdetails') {
			document.getElementById('spCommentDetails').innerHTML = 'Hide';
			}
		//hide everything thats visible...
		
		
		//Show the div
		document.getElementById(objname).style.visibility='visible';
		
	} else {
		// div is not hidden, so hide it
		if (objname == 'photodetails') {
			document.getElementById('spPhotoDetails').innerHTML = 'Show';
			}
		if (objname == 'commentdetails') {
			document.getElementById('spCommentDetails').innerHTML = 'Show';
			}
		document.getElementById(objname).style.visibility='hidden';
		}
	}
	
function fnToggleMoveDiv(objname, vtop, vleft){
	var aDivs = document.getElementsByTagName("div");
	vtop = vtop + 25;
	vleft = vleft + 2;
	
	if(document.getElementById(objname).style.visibility == 'hidden'){
		// div is hidden, so let's show it
		//Show the div
		document.getElementById(objname).style.visibility='visible';
		document.getElementById(objname).style.left=vleft+'px';
		document.getElementById(objname).style.top=vtop+'px';
		
	} else {
		// div is not hidden, so hide it
		//hide the div	
		document.getElementById(objname).style.visibility='hidden';
		}
	}	

function fnToggleComments(){
	
	if(document.getElementById('commentshell').style.height == '20px'){
		// div is hidden, so let's show it
		//Show the div
		document.getElementById('commentshell').style.height='420px';
		document.getElementById('commentlabel').innerHTML = 'Hide';
		
	} else {
		// div is not hidden, so hide it
		//hide the div	
		document.getElementById('commentshell').style.height='20px';
		document.getElementById('commentlabel').innerHTML = 'Show';
		}
	}	
	
function fn_keybang(e)
	{
	var keycode;
	if (window.event) { 
		keycode = window.event.keyCode;
		} else if (e) {
		keycode = e.which;
		} else {
		return true;
		}
	if (keycode == 13) {
		keywordsubmit();
		return false;
		} else {
		return true;
		}
	}

function textCounter( field, countfield, maxlimit ) 
	{
	if ( field.value.length > maxlimit )
		{
		field.value = field.value.substring( 0, maxlimit );
		alert( 'Text entry can only be ' + maxlimit + ' characters in length.' );
		countfield.style.color = 'red';
		countfield.innerHTML = maxlimit - field.value.length;
		return false;
		}
	else
		{
		if ((maxlimit - field.value.length) < 100)
			{
			countfield.style.color = 'red';
			countfield.innerHTML = maxlimit - field.value.length;
			}
		else
			{
			countfield.style.color = 'green';
			countfield.innerHTML = maxlimit - field.value.length;
			}
		}	
	}
	
function fn_clearsearch(vObj) {
	if (vObj.value == vObj.defaultValue) {
		vObj.style.color = '#000';
       	vObj.value = '';
       	vObj.maxLength = 50;
    	}
	}

function fn_resetsearch(vObj) {
	if (vObj.value == "") {
		vObj.style.color = '#aaa';
		vObj.maxLength = '';
       	vObj.value = 'Search';
    	}
	}
	
function keywordsubmit() {
	if ((document.getElementById('txtsearch').value != 'enter keyword') && (document.getElementById('txtsearch').value.length > 2)) {
		document.location.href='searchresults.php?att='+document.getElementById('txtsearch').value;
		} else {
		alert("Please enter a keyword that is at least 3 letters long.");
		}
	
	}
	
	
	