/*******************************************************************
 Zenith Picture Gallery

 Written by and copyright (c) Ali Almossawi
 http://cyberiapc.com

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License, a copy of 
 which is made available to you with this package.

 This program is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A  PARTICULAR PURPOSE.
*******************************************************************/

//--------------------------------------------
// hidify_showify()
//--------------------------------------------
function hidify_showify(e_table, e_img, img_path, alt_less, alt_more) {
   if(document.getElementById) {
	  //document.getElementById(e_table).style.display='';
      var id_table = document.getElementById(e_table).style;
	  var id_img = document.getElementById(e_img);
	  
	  //damn you IE!  This is to set the object to table-cell if the browser
	  //is firefox (and I think Netscape, but I don't want to install NS) and
	  //block if it's anything else.
	  if(navigator.userAgent.indexOf("Firefox")!=-1){
		  	if(id_table.display == "table-cell") {
			 id_table.display = "none";
			 id_img.src = img_path+"/arrow_down.gif";
			 id_img.alt = alt_more;
		  }
		  else {
			 id_table.display = "table-cell";
			 //alert(id_table.display);
			 id_img.src = img_path+"/arrow_up.gif";
			 id_img.alt = alt_less;
		  }
	  }
	  else {
		  if(id_table.display == "block") {
			 id_table.display = "none";
			 id_img.src = img_path+"/arrow_down.gif";
			 id_img.alt = alt_more;
		  }
		  else {
			 id_table.display = "block";
			 //alert(id_table.display);
			 id_img.src = img_path+"/arrow_up.gif";
			 id_img.alt = alt_less;
		  }
	  }
	  return false;
   }
   else {
      return true;
   }
}

//--------------------------------------------
// hidify_showify_skinny()
//--------------------------------------------
function hidify_showify_skinny(id_loader) {
   if(document.getElementById) {
      var e_loader = document.getElementById(id_loader).style;
	
	  if(navigator.userAgent.indexOf("Firefox")!=-1){
			if(e_loader.display == "none") {
			 e_loader.display = "table-cell";
			}
			else {
			 e_loader.display = "table-cell";
		  }
	  }
	  else {
		  if(e_loader.display == "block") {
			 e_loader.display = "none";
		  }
		  else {
			 e_loader.display = "block";
		  }
	  }
	  return false;
   }
   else {
      return true;
   }
}

//--------------------------------------------
// filler(): used in add.php
//--------------------------------------------
function filler(box) {
   if (box == "")   return document.frmAdd.title.value;
   else   return box;
}

//--------------------------------------------
// genPass(): generates random string (used in admincp.php)
//--------------------------------------------
function genPass() {
	var words = new Array(16);
	words[0] = "free"; words[1] = "base"; words[2] = "mac"; words[3] = "pose";
	words[4] = "high"; words[5] = "flag"; words[6] = "day"; words[7] = "book";
	words[8] = "do"; words[9] = "hem"; words[10] = "prop"; words[11] = "cap";
	words[12] = "yob"; words[13] = "tell"; words[14] = "spec"; words[15] = "rib";
	var rand1 = Math.floor(Math.random()*16);						
	var rand2 = Math.floor(Math.random()*16);
	return words[rand1]+Math.floor(Math.random()*1000)+words[rand2]+Math.floor(Math.random()*10);
}

//--------------------------------------------
// getShowValue()
//--------------------------------------------
function getShowValue() {
	var n = prompt("","10");
	if(n != null)   document.location.href = "admincp.php?do=batch-add&show=" + n;
}

//--------------------------------------------
// toggleRegisterButton()
//--------------------------------------------
function toggleRegisterButton() {
	if(document.frmRegister.agree.checked == true) document.frmRegister.submit.disabled = false;
	else document.frmRegister.submit.disabled = true;
}

//--------------------------------------------
// gotoPage()
//--------------------------------------------
function gotoPage(arg_name, arg_value, page) {
	var url = page+"?"+arg_name+"="+arg_value;
	window.open(url,'picman','width=600,height=150,resizable=yes');
}




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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


