var ipfx = '/images/';

var home_on = new Image();
home_on.src = ipfx + 'home_on.gif';

var artist_on = new Image();
artist_on.src = ipfx + 'artist_on.gif';

var works_on = new Image();
works_on.src = ipfx + 'works_on.gif';

var archive_on = new Image();
archive_on.src = ipfx + 'archive_on.gif';

var exhib_on = new Image();
exhib_on.src = ipfx + 'exhib_on.gif';

var mailing_on = new Image();
mailing_on.src = ipfx + 'mailing_on.gif';

var merchandise_on = new Image();
merchandise_on.src = ipfx + 'merchandise_on.gif';

var contact_on = new Image();
contact_on.src = ipfx + 'contact_on.gif';

 function open_order(id){
   if(!opener.document){
      open('/index.php?_mode=purchase&ixartwork=' + id, "MainWindow");
   }else{
      opener.document.location = '/index.php?_mode=purchase&ixartwork=' + id; 
   }
   self.close()
 }
 
 function restore () {
    if (innerWidth != origWidth || innerHeight != origHeight)
        location.reload();
        
    var origWidth, origHeight;
        if ((navigator.appName == 'Netscape') &&
            (parseInt(navigator.appVersion) == 4)) {
            origWidth = innerWidth;
            origHeight = innerHeight;
            window.onresize = restore;
        }
}

function doRemoveComments (f) {
    var base = '/~techblog/cgi-bin/MT/mt.cgi?__mode=delete_confirm&_type=comment&blog_id=7';
    var url = '';
    var e = f.comment_delete;
    if (!e) return;
    if (e.value && e.checked)
        url += '&id=' + e.value;
    else
        for (i=0; i<e.length; i++)
            if (e[i].checked)
                url += '&id=' + e[i].value;
    if (!url) {
        alert('You did not select any comments to delete.');
        return false;
    }
    url = base + url;
    window.open(url, 'confirm_delete', 'width=370,height=150');
}

function doRemovePings (f) {
    var base = '/~techblog/cgi-bin/MT/mt.cgi?__mode=delete_confirm&_type=ping&blog_id=7';
    var url = '';
    var e = f.ping_delete;
    if (!e) return;
    if (e.value && e.checked)
        url += '&id=' + e.value;
    else
        for (i=0; i<e.length; i++)
            if (e[i].checked)
                url += '&id=' + e[i].value;
    if (!url) {
        alert('You did not select any pings to delete.');
        return false;
    }
    url = base + url;
    window.open(url, 'confirm_delete', 'width=390,height=150');
}

function formatStr (v) {
    if (!document.selection) return;
    var str = document.selection.createRange().text;
    if (!str) return;
    document.selection.createRange().text = '<span ' + v + '>' + str + '</span>';
}

function insertLink () {
    if (!document.selection) return;
    var str = document.selection.createRange().text;
    if (!str) return;
    var my_link = prompt('Enter URL:', 'http://');
    if (my_link != null)
        document.selection.createRange().text = '<a href="' + my_link + '" target="_blank">' + str + '</a>';
}

function load_pg(url){
    var id = document.forms[1].entry_id.value
        if(document.forms[1].mode[0].checked){
            document.location = url + '&id=' + id ;
            return false;
        }else{
            document.location = '?p=entry_main&mode=delete&id=' + id ;
            return false;
        }
}

function admin_reload(url){
    var brand = document.forms[1].brand.value
    var gen = document.forms[1].table.value
        document.location = url + '&table=' + gen + '&brand=' + brand
        return true;
}

  function pop_up(blah){
    var brand = document.forms[0].brand.value;
        if(brand != "gnar"){
            blah = window.open("http://www.key3media.com/?s=blog&brand=" + brand, "new", "scrollbars=yes, resizable=no,width=820,height=600,left=100,top=100");
            blah.focus();
            document.forms[0].brand.value = 'gnar' ;
            
        }
   return false;
   }

function confirm_action(url,msg){
    if(confirm(msg)){
        location.replace(url)
    }else{
        return;
    }
}

function admin_settings(url){
    var brand = document.forms[1].brand.value
        document.location = url + '&brand=' + brand
        return true;
}

function LaunchWindow( _url, w, h, id) {

  if(w > h){ 
      Nh = h + 145;
      Nw = w + 20;
  }else{
      Nw = w+ 150 ;
      Nh = h + 40;
  }
  var paintingViewer = open( _url, "paintingViewer_" + id , "scrollbars=no, resizable=no,width=" + Nw + ",height="+ Nh + ",left=100,top=100");
}