function imposeMaxLength(Object, MaxLen)
{
textVal = MaxLen-(Object.value.length+1);
 $("#currVal").html(textVal);
//alert('textVal='+textVal);
 return (Object.value.length <= MaxLen);
}

function externalTags() {

 }

function hidediv(divId) {
  var arr = document.getElementById(divId);
// alert(arr.innerHTML);
  if ( arr!= null ) {
    arr.style.display = (arr.style.display == 'none')? 'block':'none';
  }
 }

 function downloadShow(str,memberID,showID,type) {
//alert('in downloadShow:'+str+"--"+memberID+"--"+showID+"--"+type);
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) {
   alert ("Browser does not support HTTP Request");
   return;
  }
  var url="remote.php";
  url=url+"?type="+type;
  url=url+"&mid="+memberID;
  url=url+"&sid="+showID;
  //url=url+"?q="+str;
  //url=url+"&type="+type;
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState==4) {
//alert('waiting='+xmlhttp.status);
      if (xmlhttp.status==200) {
//alert('returning from remote download routine='+str);
//alert(xmlhttp.responseText);
//document.getElementById(str).innerHTML=xmlhttp.responseText;
//document.getElementById(str).style.display = "inline";
      } // if (xmlhttp.status==200) {
    } // if (xmlhttp.readyState==4) {
//Else alert('readyState='+xmlhttp.readyState);
  } // xmlhttp.onreadystatechange = function() {
//alert('url string='+url);
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);

 } // function downloadShow(str,memberID,showID,type) {

 function playlistTwitterPost(twitterMsg) {
// alert('I am here');
// alert($("#textarea").val());
  textVal = twitterMsg;
// alert('textVal='+textVal);
// alert('textVal length='+textVal.length);
  $.post("twitterAPI.php",
    { name: textVal,
     	caller: 'playlist' },
    	function(data){
// alert("Data Loaded: " + data);
      }
   );
 } // function playlistTwitterPost(twitterMsg) {
 
 
 function joinMessage(status) {
  arr = document.getElementById("joinMsg");
  if (status==0) arr.style.visibility="visible";
  if (status==1) arr.style.visibility="hidden";
 }

 function processData() {
  output = null;
 	if (document.myForm.memberName.value.length < 1) {
 	 output = "Please fill in the member name field";
 	 document.myForm.memberName.focus();
 	}
 	if (document.myForm.passName.value.length < 1) {
 	 if (output == null) {
 	  output = "Please fill in the password field";
 	  document.myForm.passName.focus();
 	 }
 	 else output += "\n and password field";
 	}

 	if (output == null) return true;
 	 else {
 	  alert(output);
 	 	return false;
 	 }
 }

function calImgOver() {
  $('#message2').fadeIn('slow').addClass('alert').html('Click here to choose a date from the popup calendar.');
  // ### below accesses the document properties to set display properties
  document.getElementById("message2").style.backgroundColor="#FFAA7B";
  document.getElementById("message2").style.width="250px";
 }
// ### below function removes above display on mouse off
 function calImgOut() {
  $('#message2').fadeIn('slow').addClass('alert').html('');
  document.getElementById("message2").style.backgroundColor="";
  document.getElementById("message2").style.display="none";
 }

 function current() {
  document.queryForm.eventDate.value = "";
 // document.queryForm.company_info_end.value = "";
  document.getElementById("custom_start_link").style.visibility = "hidden";
 // document.getElementById("custom_end_link").style.visibility = "hidden";
 }

 function prior() {
  document.queryForm.eventDate.value = "";
 //	document.queryForm.company_info_end.value = "";
  document.getElementById("custom_start_link").style.visibility = "hidden";
 //	document.getElementById("custom_end_link").style.visibility = "hidden";
 }

 function custom() {
  document.getElementById("custom_start_link").style.visibility = "visible";
 //	document.getElementById("custom_end_link").style.visibility = "visible";
 }

 function closeShow(id) {
  divId='pl'+id;
 //alert('divId ='+divId);
  document.getElementById(divId).style.display = "none";
  //document.getElementById(divId).style.backgroundColor="#5A7194";
 }

 function tabOff(theID) {
  document.getElementById(theID).style.backgroundColor="#5A7194";
 }

 function tabOver(theID) {
  document.getElementById(theID).style.backgroundColor="#000063";
 }

 //function imposeMaxLength(Object, MaxLen) {
 // return (Object.value.length <= MaxLen);
// }

 var xmlhttp;
 function dshows(str) {
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) {
   alert ("Browser does not support HTTP Request");
   return;
  }
  var url="remote.php";
  url=url+"?type="+str;
  //url=url+"?q="+str;
  //url=url+"&type="+type;
  xmlhttp.onreadystatechange=DstateChanged;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
 }

 function sendRequest() {
  alert('starting sendRequest');
  new Ajax.Request("test.php",
    {
    method: 'post',
    postBody: 'name='+ $F('twitter'),
    onComplete: showResponse
    });
    alert('returning from sendRequest');
  }

 function showResponse(req){
 	$('show').innerHTML= req.responseText;
 }

 function PrTwitterMsg() {
//   alert('I am here');
//   alert($("#textarea").val());
   textVal =$("#textarea").val();
//   alert('textVal='+textVal);
   $.post("twitterAPI.php",
     { name: textVal },
    	 function(data){
//    	 	alert("Data Loaded: " + data);
    	 	$("#showmsg").html(data);
       }
   );
   $("#textarea").val("");
} // function PrTwitterMsg()

 function twitterhideMsg() {
 $("#twittermsg").hide();
// $("#twittermsg").hide("slow");
} // function twitterMsg()

 function picHideMsg() {
document.getElementById('picDisplay').style.visibility="hidden";
} // function picHideMsg()

 function twitterMsg() {
   textVal =$("#twittermsg").html();
// alert('textVal='+textVal);
   $.post("twitterMsg.php",
    	 function(data){
// alert("Data Loaded: " + data);
    	 	$("#twittermsg").html(data);
    	 	$("#twittermsg").show();
       }
   );
} // function twitterMsg()

 function membernamehideMsg() {
 $("#membernameMsg").hide();
// $("#twittermsg").hide("slow");
} // function membernamehideMsg()


 function membernameMsg() {
//alert('in membernameMsg');
   textVal =$("#membernameMsg").html();
// alert(textVal);
// alert('textVal='+textVal);
   $.post("membernameMsg.php",
    	 function(data){
// alert("Data Loaded: " + data);
    	 	$("#membernameMsg").html(data);
    	 	$("#membernameMsg").show();
       }
   );
} // function membernameMsg()

 function emailhideMsg() {
 $("#emailMsg").hide();
// $("#twittermsg").hide("slow");
} // function membernamehideMsg()


 function emailMsg() {
//alert('in membernameMsg');
   textVal =$("#emailMsg").html();
// alert(textVal);
// alert('textVal='+textVal);
   $.post("emailMsg.php",
    	 function(data){
// alert("Data Loaded: " + data);
    	 	$("#emailMsg").html(data);
    	 	$("#emailMsg").show();
       }
   );
} // function membernameMsg()
// function displayPicture() {
//   textVal =$("#picDisplay").html();
// alert('textVal='+textVal);
//   $.post("picdisplay.php",
//    	 function(data){
//  	 	alert("Data Loaded: " + data);
//    	 	$("#picDisplay").html(data);
//    	 	$("#picDisplay").show();
//       }
//   );
//}
//
 function displayPicture(picName) {
//alert('in displayPicture');
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) {
//alert ("Browser does not support HTTP Request");
   return;
  }
  var url="picdisplay.php";
  url=url+"?q="+picName;
  //alert(url);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState==4) {
      if (xmlhttp.status==200) {
//alert(xmlhttp.responseText);
    	 document.getElementById('picDisplay').innerHTML=xmlhttp.responseText;
    	 document.getElementById('picDisplay').style.visibility="visible";
      }
    }
  }
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
} // function displayPicture(picName) {

 function adjustPage(adjust,EID,SIZE,attrib)  {
//alert('adjustment ='+adjust+'-EID ='+EID+'-SIZE ='+SIZE+'-attrib ='+attrib);
  EIDHeight=document.getElementById(EID).style.height;
  newLen= SIZE+"px"; // set as default. If appropriate this will be reset.
//alert('incoming new page length='+newLen);
  if (EIDHeight=="") {
//alert("empty string");
   if (EID=='page')	newLen="4500px";
// else             newLen= SIZE+"px";
//alert('newLen='+newLen);
 }
  else {
   if (EID != 'yahooPipes' && EID != 'amazonWidget') {
//alert('EIDHeight='+EIDHeight);
   ph=EIDHeight.search(/px/i);
//alert('ph='+ph);
   if (adjust=="smaller") EIDHeight=Number(EIDHeight.substr(0,ph))- SIZE;
   if (adjust=="larger")  EIDHeight=Number(EIDHeight.substr(0,ph))+ SIZE;
//alert('new EIDHeight='+EIDHeight);
   newLen=String(EIDHeight)+"px";
   } // if (EID != 'yahooPipes') {
  } // else {
//alert('updating new page length='+newLen);
//alert(EID+' height ='+newLen);
  if (attrib=='height') document.getElementById(EID).style.height=newLen;
  if (attrib=='top')    document.getElementById(EID).style.top=newLen;
  if (attrib=='bottom') {
//alert(EID+' bottom ='+newLen);
//alert('old bottom ='+document.getElementById(EID).style.bottom);
      document.getElementById(EID).style.bottom=newLen;
//alert('new bottom ='+document.getElementById(EID).style.bottom);
  } // if (attrib=='bottom') {
 }

 function swapImage(type,id) {
 x   = false;
 str = type+id;
 //alert('swapImage-str='+str);
 if (type=='itimg') {
  divId     = 'itunes'+id;
 }
 else divId     = id;
 //alert('swapImage-divId='+divId);
  var minus = '../proxyfiles/images/minus.gif';
  var plus  = '../proxyfiles/images/plus.gif';
  if (document.getElementById(divId).style.display=="inline") {
//  alert("inline");
   var img = document.getElementById(str);
   img.setAttribute("src",plus);
   document.getElementById(divId).style.display = "none";
   adjustSize="smaller";
  }
  else {
   x = true;
   var img = document.getElementById(str);
   img.setAttribute("src",minus);
 	 document.getElementById(divId).style.display = "inline";
 	 adjustSize="larger";
  }
 // adjustPage=larger/smaller, EID=ID to find and alter, SIZE=How much to alter;
  EID="page";
  SIZE=2500; // adjustSize only handles pixel increase/decrease for now.
  adjustPage(adjustSize,EID,SIZE,'height');
  return(x);
 }

 function PLshows(str,type) {
 	x=swapImage('plimg',str);
 	// only call when +  clicked [not on -]
 	if (!x) return;
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) {
   alert ("Browser does not support HTTP Request");
   return;
  }
  var url="remote.php";
  url=url+"?q="+str;
  url=url+"&type="+type;
//alert(url);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState==4) {
      if (xmlhttp.status==200) {
//alert('returning from remote download routine='+str);
//alert(xmlhttp.responseText);
    	 document.getElementById(str).innerHTML=xmlhttp.responseText;
      }
    }
  }
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

 function iTunesPr(id,song,artist) {
//alert('in iTunesPr='+song+' and '+artist);
  divId='itunes'+id;
  x=swapImage('itimg',id);
  // only call when +  clicked [not on -]
  if (!x) return;
//  alert('called swapImage');
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) {
//   alert ("Browser does not support HTTP Request");
   return;
  }
  var url="iTunesproxy.php";
  url=url+"?song="+song;
  url=url+"&artist="+artist;
// alert('url='+url);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState==4) {
    	if (xmlhttp.status==200) {
//alert('divId='+divId);
//alert('xmlhttp.responseText='+xmlhttp.responseText);
    	 document.getElementById(divId).innerHTML=xmlhttp.responseText;
      }
    }
  }
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

 function DstateChanged() {
  if (xmlhttp.readyState==4) {
// alert(xmlhttp.responseText);
   document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
  }
 }

 function GetXmlHttpObject() {
  if (window.XMLHttpRequest) {
   // code for IE7+, Firefox, Chrome, Opera, Safari
   return new XMLHttpRequest();
  }
  if (window.ActiveXObject) {
   // code for IE6, IE5
   return new ActiveXObject("Microsoft.XMLHTTP");
  }
  return null;
 }

 function showVal(name,value) {
  alert(name+'='+value);
 }
