function pickImage(catid){
	var openWindow = window.open('pick_default_image.php?catid='+catid,'title','width=1000, height=500, resizeable=yes, scrollbars=yes,top=200,left=350');
}

function imgpath(c){
	var thedoc = (arguments.length>1)?arguments[1]:window.document;
	var d = thedoc.getElementById("img");
	d.value = c;
}

function pickHeaderImage(){
	var openWindow = window.open('pick_header_image.php','title','width=1000, height=500, resizeable=yes, scrollbars=yes,top=200,left=350');
}

function check(d){

	var checked = false;
	
	for(var i=0;i<d.length;++i) { 
	 if(d.elements[i].type=='checkbox') { 
	  if(d.elements[i].checked){
	  	checked = true;
	  } 
	 } 
	}


	if(checked){
		var option = confirm("Are you sure you want to delete the selected files?  The file(s) will be physically removed from the server and won't be able to be retrieved.");
		if(option){
			return true;
		}
		else{
			return false;
		}
	}
	else{
		return true;
	}
}

function toggle(div1,div2,text,textArea,orgDescription,changeCat,orgCatID){
	var style1 = document.getElementById(div1);
	var style2 = document.getElementById(div2);
	var text = document.getElementById(text);
	var txtArea = document.getElementById(textArea);
	var chgCat = document.getElementById(changeCat);

	
	if(style2.style.display == "none"){
		style1.style.display = "none";		
		style2.style.display = "block";
		text.innerHTML = "Undo";
	}
	else{
		style1.style.display = "block";		
		style2.style.display = "none";
		text.innerHTML = "Edit";
		
		// Put the orignal description back		
		txtArea.value = orgDescription;		

		// Put the original catID back in the Change Category select box		
		chgCat.value = orgCatID;
		
	}
}


var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;
 
$(document).ready(function(){
  headline_count = $("div.headline").size();
  $("div.headline:eq("+current_headline+")").css('top','5px');
  
  headline_interval = setInterval(headline_rotate,10000); //time in milliseconds
  $('#scrollup').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,10000); //time in milliseconds
    headline_rotate();
  });
});
 
function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count; 
  $("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
    $(this).css('top','210px');
    });
  $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
  old_headline = current_headline;
}

