function checkUncheckAll(theElement)
{
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
     if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
        }
}

function wgui_add_event_listener(event_type, listener_func)
{
   if (window.addEventListener)
      window.addEventListener(event_type, listener_func, false);
   else if (window.attachEvent)
      window.attachEvent("on" + event_type, listener_func);
}


function wgui_replace_code(element_id, repl)
{
   if (!repl)
      return;
   var element       = document.getElementById('wgui_' + element_id);
   element.innerHTML = eval('wgui_' + repl);
}


function wgui_save_checkbox_state(parent_id, cb)
{
   element = document.getElementById('wgui_' + parent_id);
   if (cb.checked)
      element.value++;
   else
      {
         element.value--;
         if (element.value == 0)
            element.value = '';
      }
}


function wgui_trim(st)
{
   re_start = /^\s+/;
   re_end   = /\s+$/;

   st = st.replace(re_start, '');
   st = st.replace(re_end,   '');

   return st;
}


function wgui_check_required_fields(form_name, required, message)
{
   var stop_submit;
   var required   = required.split(',');
   var num_fields = required.length;

   for (var i = 0; i < num_fields; i++)
      {
         var field_name = wgui_trim(required[i]);
         var field_id   = document.getElementById('wgui_' + field_name);
         field_id.style.backgroundColor = '';

         if (wgui_trim(eval('document.' + form_name + '.' + field_name + '.value')) == '')
            {
               field_id.style.backgroundColor = '#FFAAAA';
               stop_submit = 1;
            }
      }

   if (stop_submit == 1)
      {
         document.getElementById('wgui_' + form_name + '_status').innerHTML = message;
         window.location = '#';
         return false;
      }
}


function wgui_enable_disable_controls(enable, controls)
{
   var controls   = controls.split(',');
   var num_fields = controls.length;

   for (var i = 0; i < num_fields; i++)
      {
         var field_name = wgui_trim(controls[i]);
         var field_id   = document.getElementById('wgui_' + field_name);
            field_id.disabled = !enable;
      }
}

function toggle_visibility(id) 
{
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
}

function getScrollY(){var scrOfX = 0,scrOfY=0;if(typeof(window.pageYOffset)=='number')
{scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}

else if(document.body&&(document.body.scrollLeft||document.body.scrollTop))
{scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}

else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop))
{scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}return scrOfY;}

document.write("<style type='text/css'>.colorpicker{visibility:hidden;display:none;position:absolute;background:#FFF;border:solid 1px #CCC;padding:4px;z-index:999;filter:progid:DXImageTransform.Microsoft.Shadow(color=#D0D0D0,direction=135);}.o5582brd{padding:0;width:12px;height:14px;border-bottom:solid 1px #DFDFDF;border-right:solid 1px #DFDFDF;}a.o5582n66,.o5582n66,.o5582n66a{font-family:arial,tahoma,sans-serif;text-decoration:underline;font-size:9px;color:#666;border:none;}.o5582n66,.o5582n66a{text-align:center;text-decoration:none;}a:hover.o5582n66{text-decoration:none;color:#FFA500;cursor:pointer;}.a01p3{padding:1px 4px 1px 2px;background:whitesmoke;border:solid 1px #DFDFDF;}</style>");
function getTop2(){csBrHt=0;if(typeof(window.innerWidth)=='number'){csBrHt=window.innerHeight;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
{csBrHt=document.documentElement.clientHeight;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
{csBrHt=document.body.clientHeight;}ctop=((csBrHt/2)-115)+getScrollY();return ctop;}
var nocol1="&#78;&#79;&#32;&#67;&#79;&#76;&#79;&#82;",clos1="&#67;&#76;&#79;&#83;&#69;",tt2="",hm2="";hm2+=tt2;tt2="";
function getLeft2(){var csBrWt=0;if(typeof(window.innerWidth)=='number'){csBrWt=window.innerWidth;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
{csBrWt=document.documentElement.clientWidth;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){csBrWt=document.body.clientWidth;}cleft=(csBrWt/2)-125;return cleft;}
function setCCbldID2(objID,val){document.getElementById(objID).value=val;}function setCCbldSty2(objID,prop,val){switch(prop){case "bc":if(objID!='none'){document.getElementById(objID).style.backgroundColor=val;};break;case "vs":document.getElementById(objID).style.visibility=val;break;case "ds":document.getElementById(objID).style.display=val;break;case "tp":document.getElementById(objID).style.top=val;break;case "lf":document.getElementById(objID).style.left=val;break;}}function putOBJxColor2(OBjElem,Samp,pigMent){if(pigMent!='x'){setCCbldID2(OBjElem,pigMent);setCCbldSty2(Samp,'bc',pigMent);}setCCbldSty2('colorpicker','vs','hidden');setCCbldSty2('colorpicker','ds','none');}

function showpicker(OBjElem,Sam){var objX=new Array('00','33','66','99','CC','FF');var c=0;var z='"'+OBjElem+'","'+Sam+'",""';var xl='"'+OBjElem+'","'+Sam+'","x"';var mid='';mid+='<table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0" style="border:solid 0px #F0F0F0;padding:2px;"><tr>';mid+="<td colspan='18' align='center' style='font-size:10px;background:#6666CC;color:#FFF;font-family:arial;'>&nbsp;Select any color</td></tr><tr><td colspan='18' align='center' style='margin:0;padding:2px;height:12px;' ><input class='o5582n66' type='text' size='12' id='o5582n66' value='#FFFFFF'><input class='o5582n66a' type='text' size='2' style='width:14px;' id='o5582n66a' onclick='javascript:alert(\"click on selected swatch below...\");' value='' style='border:solid 1px #666;'>&nbsp;|&nbsp;<a class='o5582n66' href='javascript:onclick=putOBJxColor2("+z+")'><span class='a01p3'>"+nocol1+"</span></a>&nbsp;&nbsp;&nbsp;&nbsp;<a class='o5582n66' href='javascript:onclick=putOBJxColor2("+xl+")'><span class='a01p3'>"+clos1+"</span></a></td></tr><tr>";var br=1;for(o=0;o<6;o++){mid+='</tr><tr>';for(y=0;y<6;y++){if(y==3){mid+='</tr><tr>';}for(x=0;x<6;x++){var grid='';grid=objX[o]+objX[y]+objX[x];var b="'"+OBjElem+"', '"+Sam+"','"+grid+"'";mid+='<td class="o5582brd" style="background-color:#'+grid+'"><a class="o5582n66"  href="javascript:onclick=putOBJxColor2('+b+');" onmouseover=javascript:document.getElementById("o5582n66").value="#'+grid+'"; javascript:document.getElementById("o5582n66a").style.backgroundColor="#'+grid+'";  title="#'+grid+'"><div style="width:12px;height:14px;"></div></a></td>';c++;}}}mid+="</tr><tr><td colspan='18' align='right' style='padding:2px;border:solid 1px #FFF;background:#FFF;'><a href='"+hm2+"' style='color:#666;font-size:8px;font-family:arial;text-decoration:none;letter-spacing:1px;'>"+tt2+"</a></td></tr></table>";var ttop=getTop2();setCCbldSty2('colorpicker','tp',ttop);document.getElementById('colorpicker').style.left=getLeft2();setCCbldSty2('colorpicker','vs','visible');setCCbldSty2('colorpicker','ds','block');document.getElementById('colorpicker').innerHTML=mid;}

function toggle_category(id)
{      var c = 'mm';
       var d = 'nn';
       var e = document.getElementById(c + id);
       var f = document.getElementById(d + id);
       if(e.style.display == 'block')
       {
          e.style.display = 'none';
          f.className = "dn";
          get_cookie();
          var col_ids = cookie_params[6];
          cookie_params[6] = col_ids + "-" + id;
          set_cookie();
       }

       else
       {
          e.style.display = 'block';
          f.className = "up";
          get_cookie();
          var col_ids = cookie_params[6];
          cookie_params[6] = col_ids.replace(-id, "");
          set_cookie();
       }
}

function toggle_table(id)
{      var c = 'mm';
       var d = 'nn';
       var e = document.getElementById(c + id);
       var f = document.getElementById(d + id);
       if(e.style.display == 'block')
       {
          e.style.display = 'none';
          f.className = "dn2";
          get_cookie();
          var col_ids = cookie_params[6];
          cookie_params[6] = col_ids + "-" + id;
          set_cookie();
       }

       else
       {
          e.style.display = 'block';
          f.className = "up2";
          get_cookie();
          var col_ids = cookie_params[6];
          cookie_params[6] = col_ids.replace(-id, "");
          set_cookie();
       }
}

function on(id)
{
var e = document.getElementById(id);
e.className = "on";
}

function off(id)
{
var e = document.getElementById(id);
e.className = "off";
}

function confirm_entry(box)
{
zap = box.substring(0, 4);
end = box.substring(4, 7);
obj = box.substring(7);
url = "pm.php?" + zap + "=1&ref=" + end;
input_box=confirm("Empty The " + obj + "?");
if (input_box==true)

{
window.location=url;
}

else
{
}
}


//drw


var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
    	if(xmlhttp.responseText != "")
    	{
    		alert(xmlhttp.responseText);
    	}
    	
    	
    	//document.getElementById('content').innerHTML=xmlhttp.responseText;
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}


function update_gallery_database(val, url)
{
	
	var comment = document.getElementById(val).value;
	var new_url = url + "&comment=" + comment;
	loadXMLDoc(new_url);
}

function num_gallery_images()
{
	var url = document.location.href;
	var val = document.getElementById('numperpage').value;
	
	if(url.indexOf('?') > -1)
	{
		if(url.indexOf('numperpage') > -1)
		{
			var start_at = url.lastIndexOf('numperpage');
			var end_at = url.length;
			
			var s_str = url.substring(start_at, end_at);
			
			var r = new RegExp(s_str);
			
			url = url.replace(r, "numperpage=" + val);
		}
		else
		{
			url += "&numperpage=" + val; 
		}
	}
	else
	{
		url += "?numperpage=" + val; 
	}
	
	
	window.location = url;
	

}


function open_gallery_insert()
{
	if (window.showModalDialog) 
	{
		open_window=window.showModalDialog("gallery_myimages.php",window,"dialogWidth:700px;dialogHeight:600px");
		update(open_window);
	} 
	else 
	{
		document.write("Sorry, your Browser does not support this Operation.");
	}
}


function update(image_name)
{
	var browser = navigator.appName;
	if(browser == "Netscape")
	{
		editor.contentWindow.focus();
		var e = document.createElement("img");
		e.setAttribute("src", image_name);
		e.setAttribute("alt", "");
		paste_HTML(e);
		var b = document.createElement("<br />");
		paste_HTML(b);
	}
	else
	{
		text_editor.focus();
		cursor_pos.pasteHTML('<img src="' + image_name + '" alt=""><br />');
	}
}

function checkFolder(field)
{
	
	
	if(document.getElementById(field).value != '')
	{
		try{
		document.forms['gallery_folder'].submit();
		}
		catch (er){
			alert(er);
		}
	}
	else
	{
		alert('You must specify a name for a new folder.');
	}

}

