// JavaScript Document
$(document).ready(function(){ 
	$(".vjustify").vjustify(); 
	$(".vjustify2").vjustify(); 
}); 


function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function OpenPreview(imagename){
  window.open('preview.htm?'+imagename,'Preview','top=0,left=0,width=50,height=50,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');
}

function OpenOrder(orderid){
  window.open('vieworder.asp?OrderID='+orderid,'Order','top=0,left=0,width=630,height=500,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
}

function Changedetails(userid){
  window.open('changedetails.asp?UserID='+userid,'Details','top=0,left=0,width=630,height=500,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
}


jQuery.fn.vjustify=function() {
    var maxHeight=0;
    this.each(function(){
        if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
    });
    this.each(function(){
        $(this).height(maxHeight + "px");
        if (this.offsetHeight>maxHeight) {
            $(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
        }
    });
};