// JavaScript Document

<!--
function MM_preloadImages() { //v3.0
  var d=document; 
  if(d.images){ 
    if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
    for(i=0; i<a.length; i++) {
      if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}
    }
  }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3) {
   if ((x=MM_findObj(a[i]))!=null) {
     document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
   }
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function check_insert(type) {
  document.generic_form.action += '&action=ins';
  document.generic_form.submit();
}

function check_update(type) {
  if ( document.generic_form.id.selectedIndex < 0 ) {
    alert('Select a row first!');
  } else {
    document.generic_form.action += '&action=upd&id=' + document.generic_form.id[document.generic_form.id.selectedIndex].value;
    document.generic_form.submit();
  }
}

function check_delete(type) {
  if ( document.generic_form.id.selectedIndex < 0 ) {
    alert('Select a row first!');
  } else {
    if (confirm("Are you sure you want to delete")) {
	if ( typeof document.generic_form.id.selectedIndex == 'undefined' ) {
	  document.generic_form.action += '&action=del&id=' + document.generic_form.id.value;
	} else {
	  document.generic_form.action += '&action=del&id=' + document.generic_form.id[document.generic_form.id.selectedIndex].value;
	}
	document.generic_form.submit();
    }
  }
}

function do_popup(url, l_width, l_height, l_scroll)
{
  if (document.all)
    var xMax = screen.width, yMax = screen.height;
  else
    if (document.layers)
      var xMax = window.outerWidth, yMax = window.outerHeight;
    else
      var xMax = 640, yMax=480;

  var xOffset = (xMax - l_width)/2, yOffset = (yMax - l_height)/2;

  var details = 'location=0,status=0,scrollbars='+l_scroll+',width='+l_width+',height='+l_height+',';
  details = details + 'screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset;

  window.open(url,'title',details);
}

function check_art_form()
{
	if ( document.generic_form.title.value == '') { 
	    alert('You must enter a title for the artwork!');
	    return FALSE;
	}
	if ( document.generic_form.artistId.options[document.generic_form.artistId.selectedIndex].value == '0') { 
	    alert('You must select an artist!');
	    return FALSE;
	}
	if ( document.generic_form.categoryId.options[document.generic_form.categoryId.selectedIndex].value == '0') { 
	    alert('You must select an category!');
	    return FALSE;
	}
	if ( document.generic_form.typeId.options[document.generic_form.typeId.selectedIndex].value == '0') { 
	    alert('You must select an type!');
	    return FALSE;
	}
	if ( document.generic_form.styleId.options[document.generic_form.styleId.selectedIndex].value == '0') { 
	    alert('You must select an style!');
	    return FALSE;
	}
	if ( document.generic_form.price.value == '') { 
	    alert('You must enter a price!');
	    return FALSE;
	}
	document.generic_form.submit();
}

function check_artist_form()
{
	if ( document.generic_form.artistname.value == '') { 
	    alert('You must enter a value for the artist name!');
	    return FALSE;
	}
	document.generic_form.submit();
}

function check_type_form()
{
	if ( document.generic_form.type_name.value == '') { 
	    alert('You must enter a value for the type!');
	    return FALSE;
	}
	document.generic_form.submit();
}

function check_style_form()
{
	if ( document.generic_form.style_name.value == '') { 
	    alert('You must enter a value for the style!');
	    return FALSE;
	}
	document.generic_form.submit();
}


function check_arttype_form()
{
	if ( document.generic_form.typename.value == '') { 
	    alert('You must enter a value for the art type!');
	    return FALSE;
	}
	document.generic_form.submit();
}


function check_user_form()
{
	if ( document.generic_form.username.value == '') { 
	    alert('You must enter a value for the username!');
	    return FALSE;
	}
	if ( document.generic_form.password.value == '') { 
	    alert('You must enter a value for the password!');
	    return FALSE;
	}
	if ( document.generic_form.password.value == document.generic_form.username.value) { 
	    alert('username and password cannot be the same!');
	    return FALSE;
	}
	if ( document.generic_form.password.length < 6) { 
	    alert('password must be more than six characters!');
	    return FALSE;
	}
	document.generic_form.submit();
}


function check_catagory_form()
{
	if ( document.generic_form.cat_name.value == '') { 
	    alert('You must enter a value for the catagory!');
	    return FALSE;
	}
	if ( document.generic_form.on_mouse_over_img.value == '') { 
	    alert('You must enter a value for the on mouse over image!');
	    return FALSE;
	}
	if ( document.generic_form.normal_img.value == '') { 
	    alert('You must enter a value for the normal image!');
	    return FALSE;
	}
	if ( document.generic_form.href.value == '') { 
	    alert('You must enter a destination href!');
	    return FALSE;
	}
	if ( document.generic_form.order_results.value == '') { 
	    alert('You must enter a sequence order number!');
	    return FALSE;
	}
	if ( document.generic_form.description.value == '') { 
	    alert('You must enter a description!');
	    return FALSE;
	}
	if ( document.generic_form.width.value == '') { 
	    alert('You must enter a width!');
	    return FALSE;
	}
	document.generic_form.submit();
}

//-->
