function confirm_del() {
  var reply = confirm("This will permanantly delete this record! You can't restore it in future.");

  if (reply) {
     return true;
  } else {
     return false;
  }
}


function popUpImg(url, pageWidth, pageHeight) {
    var args = "width=" + (pageWidth + 20) + ",height=" + (pageHeight + 10) + "";
    var date = new Date();
    var now = date.getTime();
    var name = (now).toString(10);

    _w = window.open('',name,args);
    _w.document.open();
    _w.document.write("<html>\n<head><title>Viewing " + url + "</title>\n");
    _w.document.write("<meta http-equiv='imagetoolbar' content='no'>\n");
    _w.document.write("<link href='screen.css' type='text/css' rel='stylesheet'  media='screen' />\n");
    _w.document.write("<script language='javascript'><!--\n");
    _w.document.write("var i=0;\n");
    _w.document.write("function resize() {\n");
    _w.document.write("if (navigator.appName == 'Netscape') i=40;\n");
    _w.document.write("if (document.images[0]) window.resizeTo(document.images[0].width +30, document.images[0].height+100-i);\n");
    _w.document.write("self.focus();\n");
    _w.document.write("}\n");
    _w.document.write("//--></script></head>\n");
    _w.document.write("<body onload='resize();'>\n");
    _w.document.write("<table width='100%' border='0' cellpadding='0' cellspacing='0' style='height: 100%'>\n");
    _w.document.write("<tr><td><a href='javascript:window.close()' class='popup'>Close window</a></td></tr>\n");
    _w.document.write("<tr>\n<td align='center' valign='middle'>\n");
    _w.document.write("<a href='javascript:window.close()'><img src='" + url + "' alt='Click to close' border='0' /></a>\n");
    _w.document.write("</td></tr></table>\n");
    _w.document.write("</body>\n</html>");
    _w.document.close();
}

opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
ie = (document.all && !opera)? true : false;
dom = (document.getElementById && !ie && !opera)? true : false;

var expiration = new Date();
expiration.setTime(expiration.getTime() + 3600*3600*3600);


function SetMenuCookie() {
    SetCookie('order_cookie', "1", expiration, "", "", "");
    SetCookie('item_setup_cookie', "1", expiration, "", "", "");
    SetCookie('item_fields_setup_cookie', "1", expiration, "", "", "");
    SetCookie('newsletter_setup_cookie', "1", expiration, "", "", "");
    SetCookie('website_setup_cookie', "1", expiration, "", "", "");
    SetCookie('settings_setup_cookie', "1", expiration, "", "", "");
    SetCookie('banners_setup_cookie', "1", expiration, "", "", "");
    SetCookie('charity_setup_cookie', "1", expiration, "", "", "");
    SetCookie('emails_setup_cookie', "1", expiration, "", "", "");
    SetCookie('logs_setup_cookie', "1", expiration, "", "", "");
}


function showtranscript(elemId,displayValue) {

  if (dom) {

      if (displayValue) {
         document.getElementById(elemId).style.display = displayValue;
         return 0;
      }

      if (document.getElementById(elemId).style.display == "none") {
         document.getElementById(elemId).style.display = "block";
      } else if (document.getElementById(elemId).style.display == "block") {
         document.getElementById(elemId).style.display = "none";
      }

  } else if (ie) {


    if (displayValue) {
       window.document.all[elemId].style.display = displayValue;
       return 0;
    }

    if (document.all[elemId].style.display == "block") {
       document.all[elemId].style.display = "none";
    } else if (document.all[elemId].style.display == "none") {
       document.all[elemId].style.display = "block";
    }

  }
}


function display(cookie_name, id, cookie_path, cookie_domain) {
    var template_category_cookie;

    template_category_cookie = GetCookie(cookie_name);
    if (template_category_cookie) {
       SetCookie(cookie_name, "1", expiration, cookie_path, cookie_domain, "")
       showtranscript(id, 'block');
    } else {
       SetCookie(cookie_name, "", expiration, cookie_path, cookie_domain, "")
       showtranscript(id, 'none');
    }

    return true;
}


function onCookieChange(cookie_name, id, cookie_path, cookie_domain) {

  if (dom) {
      if (document.getElementById(id).style.display == "none") {
         SetCookie(cookie_name, "", expiration, cookie_path, cookie_domain, "")
      } else if (document.getElementById(id).style.display == "block") {
         SetCookie(cookie_name, "1", expiration, cookie_path, cookie_domain, "")
      }

  } else if (ie) {

    if (document.all[id].style.display == "block") {
       SetCookie(cookie_name, "1", expiration, cookie_path, cookie_domain, "")
    } else if (document.all[id].style.display == "none") {
       SetCookie(cookie_name, "", expiration, cookie_path, cookie_domain, "")
    }
  }
}


function SetCookie(name, value, expires, path, domain, secure) {

   var mycookie = name + "=" + escape(value);
   var myexpires = new Date();
   myexpires.setTime(myexpires.getTime() + 5000);
   mycookie = mycookie + "; myexpires=" + myexpires.toGMTString();

   if (path) {
     mycookie = mycookie + "; path=" + path;
   }

   if (domain) {
     mycookie = mycookie + "; domain=" + domain;
   }

   document.cookie = mycookie;
}


function GetCookie(name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;

   while (i < clen) {
     var j = i + alen;
     if (document.cookie.substring(i, j) == arg)  return getCookieVal (j);
     i = document.cookie.indexOf(" ", i) + 1;
     if (i == 0) break;
   }

   return null;
}


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}


function SelectAllRecords(form_id, chck_name, mark) {
  for (i = 0; i < document.forms[form_id].elements.length; i++) {
    var item = document.forms[form_id].elements[i];
      if (item.name == chck_name) {
        item.checked = mark;
      };
   }
}


function select_check(form_id, chck_name) {
   var  item_count = 0;

   for (i = 0; i < document.forms[form_id].elements.length; i++) {
      var item = document.forms[form_id].elements[i];
      if (item.name == chck_name) {

         if (item.checked) {
            item_count ++;
         }

       };
   }

   if (item_count == 0) {
     document.forms[form_id].select_all.checked = false;
   }
}


function viewform(m, w, h) {
   var scroll = 'yes';
   var settings;
   var LeftPosition;
   var TopPosition;
   var win;

   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
//   TopPosition = 0;

   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;
   settings = settings + ',resizable=yes,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no';

   win = window.open(m, 'pre', settings);
   win.name = 'name';
   win.focus();
}


function hideloadingpage() {
   if (document.getElementById) { // DOM3 = IE5, NS6
      document.getElementById('hidepage').style.visibility = 'hidden';
   } else {
      if (document.layers) { // Netscape 4
         document.hidepage.visibility = 'hidden';
      } else { // IE 4
         document.all.hidepage.style.visibility = 'hidden';
      }
   }
}


function showloadingpage() {
   if (document.getElementById) { // DOM3 = IE5, NS6
      document.getElementById('hidepage').style.visibility = 'visible';
   } else {
      if (document.layers) { // Netscape 4
         document.hidepage.visibility = 'show';
      } else { // IE 4
         document.all.hidepage.style.visibility = 'visible';
      }
   }
}


function resize() {
var i=0;
var LeftPosition;
var TopPosition;
var w;
var h;
  if (navigator.appName == 'Netscape') i=40;
  if (document.images[0])
  {
    w = document.images[0].width+100;
    h = document.images[0].height+130-i;
    window.resizeTo(w, h);
//    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
//    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
//    window.moveTo(LeftPosition, TopPosition);
  }
  self.focus();
}



// Load Pic into iFrame
function editPic(i,a)
{
	var e = document.getElementById('pic-holder');
	e.src = 'admin.php?act=item_mod_form&id='+i;
        e.width = "100%";
        e.height = "600px";

	clearClasses();
	document.getElementById(i).className += ' selected';
}

function clearClasses ()
{
	var elem = document.getElementById('pic-spread');
	var a = elem.getElementsByTagName('IMG');
	var b = elem.getElementsByTagName('DIV');

	for (i=0; i < a.length; i++)
	{
		a[i].className = '';
	}

	for (i=0; i < b.length; i++)
	{
		myString = new String(b[i].className)
		rExp = /selected/gi;
		newString = new String ("")
		results = myString.replace(rExp, newString)
		b[i].className = results;
	}
}

function saveOrderDB(ai) {
	var elem = document.getElementById('pic-spread');
	var a = document.getElementsByTagName('LI');
	var qStr = '';
	for (var i=0; i < a.length; i++)
	{
		qStr += (i+1)+','+a[i].id+'|';
	}
	location.href = 'admin.php?act=save_gallery_order&q='+qStr+'&id='+ai;
}

/*
var cssmenuids=["cssmenu1"] //Enter id(s) of CSS Horizontal UL menus, separated by commas
var csssubmenuoffset=-1 //Offset of submenus from main menu. Default is 0 pixels.

function createcssmenu2(){
for (var i=0; i<cssmenuids.length; i++){
  var ultags=document.getElementById(cssmenuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+csssubmenuoffset+"px"
    	var spanref=document.createElement("span")
			spanref.className="arrowdiv"
			spanref.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;"
			ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
    	ultags[t].parentNode.onmouseover=function(){
					this.style.zIndex=100
    	this.getElementsByTagName("ul")[0].style.visibility="visible"
					this.getElementsByTagName("ul")[0].style.zIndex=0
    	}
    	ultags[t].parentNode.onmouseout=function(){
					this.style.zIndex=0
					this.getElementsByTagName("ul")[0].style.visibility="hidden"
					this.getElementsByTagName("ul")[0].style.zIndex=100
    	}
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", createcssmenu2, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu2)
      */
function viewform(m, w, h) {
   var scroll = 'yes';
   var settings;
   var LeftPosition;
   var TopPosition;
   var win;

   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
//   TopPosition = 0;

   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;
   settings = settings + ',resizable=yes,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no';

   win = window.open(m, 'pre', settings);
   win.name = 'name';
   win.focus();
} 