// JavaScript Document
//DREAMWEAVER FUNCTIONS
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_confirmation(theURL) {
var answer = confirm("Are you sure you want to delete this? This is a permanent change...")
if (answer){
	alert("Successfully deleted!")
	window.location = theURL;//"http://www.google.com/"
	}
else{
	alert("Deletion Cancelled.")
	}
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//DREAMWEAVER FUNCTIONS

//PLAYER FUNCTIONS
//open the reverbnation player
function openPlayer(){
	var player = document.getElementById("musicplayer");
	var pArrow = document.getElementById("openclose");
	player.style.visibility = "visible";
	pArrow.src = "images/kc_MusicPlayer_Open_Pic01.png";
}

//close the reverbnation player
function closePlayer(){
	var player = document.getElementById("musicplayer");
	var pArrow = document.getElementById("openclose");
	player.style.visibility = "hidden";
	pArrow.src = "images/kc_MusicPlayer_Closed_Pic01.png";
}

//MENU FUNCTIONS
//set the default id at startup
//var oldId = 1;
//var oldTmp = 2;
//var oldHln = "Home";

//change the menu to the new style when calling data in the div tag
function changeDataNav(hln,tmp,id){
	//set the variables for the id attribute:
	var curMenu = "menu" + id;
	var curOld = "menu" + oldId;
	
	//write the code for the new menu item:
	document.getElementById(curMenu).innerHTML = hln;
	
	//write the code for the old menu item including the link:
	document.getElementById(curOld).innerHTML = "<a href=\"#\" onclick=\"changeDataNav('" + oldHln + "'," + oldTmp + "," + oldId + ");return false;\" >" + oldHln + "</a>";
	
	//set the style of the menu items
	document.getElementById(curMenu).className = "on";
	document.getElementById(curOld).className = "off";
	
	//make the new menu the old menu in memory:
	oldId = id;
	oldTmp = tmp;
	oldHln = hln;
	
	//update the page title
	document.title = "Kim Churchill - " + hln;
	
	//reset the listing value:
	resetOldListingId();
	
	//call the page content in the data div tag:
	callData(tmp,id);
}

//Call the data in a div
function callData(tmp,id)
{
if ((tmp=="") || (id==""))
  {
  document.getElementById("data").innerHTML="Oops! Something went wrong.";
  return;
  }  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("data").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","tmp" + tmp + ".php?id=" + id + "&d=1",true);
xmlhttp.send();
}

//update the metatags with javascript
function updateMetatags(desc,keyw) {
	// First, get the array of meta-tag elements
	metatags = document.getElementsByTagName("meta");
	metatags[6].setAttribute("content", desc);
	metatags[7].setAttribute("content", keyw);
	
	//troubleshooting!
	//document.getElementById("scripts").innerHTML = metatags[6].getAttribute("name") + ": " + desc + "<br />" + metatags[7].getAttribute("name") + ": " + keyw;
}
//MENU FUNCTIONS

//TMP FUNCTIONS
//declare the default old id variable
oldListingId = 0;

//reset the old listing value when the page changes
function resetOldListingId() {
	oldListingId = 0;
}

//reveal or hide listings 
function tmpShowHide(newListingId){
	//get the new ids to change
	var newMoreLessLink = document.getElementById("moreless" + newListingId);
	var newMoreLessArrow = document.getElementById("arrow" + newListingId);
	var newTextShowHide = document.getElementById("text" + newListingId);
	
	//set the new moreless link
	newMoreLessLink.innerHTML = "<a href=\"#\" onclick=\"tmpShowHide(" + newListingId + ");return false;\">[-]less</a>";
	newMoreLessArrow.innerHTML = "<img src=\"/images/kc_img_listingArrow.png\">";
	
	//set the display style of the newTextShowHide box
	newTextShowHide.style.display = "block";
	
	//set the old values
	//check to see if the old value equals zero first:
	//if it does, don't call any DOM objects
	if(oldListingId == 0) {
		//get the old ids to change
		var oldMoreLessLink = oldListingId;
		var oldMoreLessArrow = oldListingId;
		var oldTextShowHide = oldListingId;
	}
	
	else {
		//get the old ids to change
		var oldMoreLessLink = document.getElementById("moreless" + oldListingId);
		var oldMoreLessArrow = document.getElementById("arrow" + oldListingId);
		var oldTextShowHide = document.getElementById("text" + oldListingId);
		
		//set the old moreless link
		oldMoreLessLink.innerHTML = "<a href=\"#\" onclick=\"tmpShowHide(" + newListingId + ");return false;\">[+]more</a>";
		
		//set the old moreless arrow
		oldMoreLessArrow.innerHTML = "";
		
		//set the display style of the newTextShowHide box
		oldTextShowHide.style.display = "none";
	}
	
	//set the new oldListingId value to the newListingId value:
	oldListingId = newListingId;
	
}

//UPDATE THE AddThis CODE TO THE NEW PAGE VALUES
function ReinitializeAddThis() {
    if (window.addthis) {
        window.addthis.ost = 0;
        window.addthis.ready();
    }
}

//ADMIN FUNCTIONS!
//PAGINATE THE USERS PERSONAL OR STICKY IDIOT LISTINGS
function paginate(page,pageCall,column,colVal)
{
if ((page=="") || (pageCall=="") || (column==""))
  {
  document.getElementById("adminContent").innerHTML="Oops! Something went wrong.";
  return;
  }  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("adminContent").innerHTML=xmlhttp.responseText;
    }
  }
if(colVal == ""){
xmlhttp.open("GET",pageCall + "?p=" + page,true);
}
else {
xmlhttp.open("GET",pageCall + "?p=" + page + "&" + column + "=" + colVal,true);	
}
xmlhttp.send();
}

//open the image library list:
function changedisplay(mode,id) {
	var theDivObj = document.getElementById(id);
	
	if(mode == 1) { theDivObj.style.display = "block"; }
	else { theDivObj.style.display = "none"; }
}

//ADMIN FUNCTIONS!
//-->
