/* ------------------------------------------------------
------------------Form Functions         ----------------
-------------------------------------------------------*/

function checkCat(formName) {
//checks values of various form fields
var illegalChars= /[\\\/\<\>\,\;\:\"\[\]\?\*\'\&\(\)]/;
	if (formName.cat_description.value == "") {
		alert("Please Enter a Gallery Name!")
		formName.cat_description.focus();
		return false;
	}
	if (formName.cat_description.value.match(illegalChars)){
		alert("Gallery Names cannot contain any of these characters: \ / < > , ; : [ ] ? * \'& ( )")
		formName.cat_description.focus();
		return false;
	}
return true;
}//end function CheckForm

function MoveFiletoGallery(cat_value){
	if (cat_value == "none"){
		alert("You cannot move this file to this Gallery.  It contains other Gallerys. \n Select another Gallery that contains only photos.")
		document.getElementById("categorysel").selectedIndex = "0"
	}
}

function MoveGallery(cat_value){
	if (cat_value == "none"){
		alert("You cannot move this Gallery to the Selected Gallery.  It contains only photos. \n Select another gallery that contains other gallerys or create a new gallery.")
		document.getElementById("categorysel").selectedIndex = "0"
	}
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


function checkSearch(formName){

   return true;
}

function galdelete(url){
	var answer=confirm("Are you sure you want to delete this Gallery? \n It will also delete all the files!")
		if(answer){
			window.location.href = url;
		}
}

function photodelete(url){
	var answer=confirm("Are you sure you want to delete this Photo?")
		if(answer){
			window.location.href = url;
		}
}


function ChangeGallery(cat_id){
	window.location.href = "default.asp?cat_id=" + cat_id;
}

/* ------------------------------------------------------
------------------Misc Functions         ----------------
-------------------------------------------------------*/

function Upload_Resize(pcat_id)
{
	var url = "aspupload.asp?cat_id=" + pcat_id
	//alert(url)
	popupWin = window.open(url, 'Image_Upload', 'scrollbars=yes,width=640,height=480')
}


function BumpUp(abox)
				{
					//alert(abox)
					for(var i = 0; i < abox.options.length; i++)
					{
						if(abox.options[i].value == "")  
						{
							for(var j = i; j < abox.options.length - 1; j++)  
							{
								abox.options[j].value = abox.options[j + 1].value;
								abox.options[j].text = abox.options[j + 1].text;
							}
							var ln = i;
							break;
						}
					}
					if(ln < abox.options.length)
					{
						abox.options.length -= 1;
						BumpUp(abox);
					}
			}

function Moveup(dbox)
				{
					//alert("moving up");
					for(var i = 0; i < dbox.options.length; i++) 
					{
						if (dbox.options[i].selected && dbox.options[i] != "" && dbox.options[i] != dbox.options[0]) 
						{
							var selected = dbox.options[i].selected;
							var tmpval = dbox.options[i].value;
							var tmpval2 = dbox.options[i].text;
							dbox.options[i].value = dbox.options[i - 1].value;
							dbox.options[i].text = dbox.options[i - 1].text
							dbox.options[i-1].value = tmpval;
							dbox.options[i-1].text = tmpval2;
							if(selected)
							{
								dbox.options[i-1].selected = true;
							}
							else
							{
								dbox.options[i-1].selected = false;
							}
							dbox.options[i].selected = false;
						}
					}
				}

function Movedown(ebox)
				{
					if(ebox != null) 
					{
						var size =ebox.options.length;
						if(size > 0)
						{
							for(i=(size-1); i>=0; i--)
							{
								var obj1 = ebox.options[i];
								if((obj1 != null) && (obj1.selected==true))
								if((i+1) < size) 
								{
									// Swap the elements.
									var tempVal = ebox[i].value;
									var tempTxt = ebox[i].text;
									ebox[i].value = ebox[i+1].value;
									ebox[i].text  =ebox[i+1].text;
									ebox[i+1].value = tempVal;
									ebox[i+1].text  = tempTxt;
									ebox[i].selected = false;
									ebox[i+1].selected = true;
								}
							}
						}
					}
				}
                
function selectAll(cbList) {
  for (var i=0; i<cbList.length; i++) 
    cbList[i].selected = cbList[i].checked = "true"
return true;    
}
