function loadpics()
{
 $("[id=popup]").remove();
 $("body").prepend("<div id='popup' class='popup' style='display: none;'><img src='images/loading.gif' alt='Loading...' /></div>");
 $.ajax({url: "getpics.cgi", dataType: "xml", complete: function(data) {
  var xml = $.xmlToJSON(data.responseXML);
  var html="<div style='height: 450px; width: 490px; overflow: auto;'>";
  if ( xml.total[0].Text != "0" ) {
   for ( var i = 0; i < xml.pic.length; i++ ) {
    html+="<img src='small.cgi/"+xml.pic[i]._filename+"' alt='"+xml.pic[0].Text+"' title='"+xml.pic[i].Text+"' class='smallpic' type='insertpic' filename='"+xml.pic[i]._filename+"' />&nbsp;";
   }
  }
  html+="</div><br /><div class='center'><input type='button' value='Upload' id='upload' />&nbsp;<input type='button' value='Close' popdown='true' /></div>";
  $("#popup").html(html).css({left: eval($(document).width()-$("#popup").width())/2+"px"}).fadeIn(500);
  $("[popdown=true]").click(function() { $("#popup").fadeOut(500, function() { $(this).remove(); }); });
  $("img[type=insertpic]").unbind("click").click(function() {
   var filename=$(this).attr("filename");
   var title=$(this).attr("title");
   addcode("<img src='"+filename+"' alt='"+title+"' class='smallimg' />");
   $("#popup").fadeOut(500, function() { $(this).remove(); });
  });
  $("#upload").click(function() {
   window.open( "uploadpage.cgi", "upload", "status = 1, height = 600, width = 900, resizable = 0" )
  });
 }});
}
function done(done)
{
 if ( done == "" ) { done="Thank you, your request was successfully processed"; }
 $("body").prepend("<div id='done' style='background-color: #63001f; position: absolute; top: 30px; left: 100px; height: 30px; width: 900px; z-index: 100; color: #fff; padding-top: 12px; text-align: center; font-weight: bold; vertical-align: middle; display: none;'>"+done+"</div>");
 $("#done").css({left: eval($(document).width()-$("#done").width())/2+"px"}).fadeIn(1000);
 setTimeout(function() { $("#done").fadeOut(1000); }, 5000);
}
$(document).ready(function() {
 var curbg=0;
 var menuhide;
 var bgs=new Array();
 bgs[0]="dogflash1.jpg";
 bgs[1]="d3p.jpg";
 bgs[2]="d6l.jpg";
 bgs[3]="d2p.jpg";
 bgs[4]="1sibovelds_sauron_at_rocksands.jpg";
 bgs[5]="dogflash.jpg";
 bgs[6]="amazon-xquisit-kiss-sm.jpg";
 setInterval(function() {
  $("#fadebox").fadeTo("slow",0, function() {
   if ( curbg == bgs.length ) { curbg=0; }
   $("#fadebox").css({backgroundImage: "url(images/"+bgs[curbg]+")"});
   curbg++;
   $("#fadebox").fadeTo("slow",1);
  });
 }, 8000);
 $("div[type=dropdown]").mouseover(function() {
  clearTimeout(menuhide);
 });
 $("a[type=dropdown]").mouseover(function() {
  clearTimeout(menuhide);
  $("div[type=dropdown]").hide();
  $("div[type=dropdown][dropdown="+$(this).attr("dropdown")+"]").css({top: $(this).offset().top+"px", left: eval($(this).offset().left+$(this).outerWidth()-5)+"px"}).show();
 });
 $("div[type=dropdowncont]").mouseout(function() {
  var dropdown=$(this).attr("dropdown");
  menuhide=setTimeout(function() { $("div[type=dropdown][dropdown="+dropdown+"]").hide(); }, 500);
 });
 $("#link-type").change(function() {
  if ( $(this).val() == "sub" ) {
   $("#link-to").css({display: ""});
  }
  else { $("#link-to").css({display: "none"}); $("#link-to-select").val("0"); }
 });
 $("img.smallimg").click(function() {
  $("[id=popup]").remove();
  $("body").prepend("<div id='popup' class='popup' style='display: none;'><a href='"+$(this).attr("src")+"' target='_blank'><img src='"+$(this).attr("src")+"' alt='"+$(this).attr("alt")+"' class='largeimg' /></a><br /><br /><div class='center'><input type='button' value='Close' popdown='true' /></div></div>");
  $("#popup").css({left: eval($(document).width()-$("#popup").width())/2+"px"}).fadeIn(500);
  $("[popdown=true]").click(function() { $("#popup").fadeOut(500, function() { $(this).remove(); }); });
 });
 $("[focusme=true]").focus().select();
});

