//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
function confirmDelete(msg){
   var del = confirm(msg);
   if(del) return true;
   else return false;
}
////////////////////////////////////////////
////////////////////////////////////////////
function chgBg(obj,color){
   if (document.all || document.getElementById)
     obj.style.backgroundColor=color;
   else if (document.layers)
     obj.bgColor=color;
}

function printMe(id){
   window.print();
   window.location.href="ship_order.php?id="+id+"&cmd=print";
}

var submitcount=0;
function checkSubmit() {
   if (submitcount == 0)
      {
      submitcount++;
      return true;
      }
   else
      {
      alert("This form has already been submitted. Please wait!");
      return false;
      }
}

function checkArray(form, arrayName) { 
  var retval = new Array(); 
  for(var i=0; i < form.elements.length; i++) { 
    var el = form.elements[i]; 
    if(el.type == "checkbox" && el.name == arrayName && el.checked) { 
      retval.push(el.value); 
    }
  } return retval; 
}

function checkAddToCart(form) {
  var itemsChecked = checkArray(form, "cid[]");
  if(itemsChecked.length > 0) {
    return true;
  }
  else $("#errorMessage").dialog('open');  
  return false;
}

function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }
}

function loadXMLDoc(url,id){
   if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   }
   else{// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   xmlhttp.open("GET",url,false);
   xmlhttp.send(null);
   document.getElementById(id).innerHTML=xmlhttp.responseText;
}

var finestra;
function closePopup() {
   if (finestra != null && !finestra.closed) finestra.close();
}
function popUp(url,w,h){
   closePopup();
   finestra=window.open(url,"","border=thin,titlebar=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + w + ",height=" + h);
   finestra.moveTo((screen.width/2)-175,30);
   finestra.focus();
}

function PrintContent(id){
  var DocumentContainer = document.getElementById(id);
  var WindowObject = window.open("", "PrintWindow",
  "width=600,height=500,screenX=50,screenY=50,top=50,left=50,toolbars=no,location=no,directories=no,menubar=no,scrollbars=no,status=no,resizable=yes");
  WindowObject.document.writeln(DocumentContainer.innerHTML);
  WindowObject.document.close();
  WindowObject.focus();
  WindowObject.print();
  WindowObject.close();
}

function disableEnterKey(e){
     var key;
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox
     return (key != 13);
}
