function confirmImgDel() {
        var blnRes=true;
        var ret= confirm("Are you sure you want to remove this image?");
        if (ret){
         blnRes = true;
        }
        else {
         blnRes=false;
        }
        return blnRes;
}
function DeleteMe(frm) {
        var ret = confirm("Are you sure you want to delete this record?");
        if (ret){
		var obj =document.getElementById(frm);
		obj.hidPageMode.value='delete';
                obj.submit();
        }
	return false;
}


function EnlargeMe($stockID){
	var sUrl = "ViewImg.php?id="+$stockID;
	window.open(sUrl,null,"height=300,width=450,status=no,toolbar=no,menubar=no,location=no");
}
function CancelMe() {
        var ret = confirm("Are you sure you want to cancel?");
        if (ret){
            window.navigate('menu.php');
        }
}

function SetCombo(objRef,strSearch){
  var i,intIndex;
  var objCombo = document.getElementById(objRef);
  for (i=0; i < objCombo.length; i++){
        if (objCombo.options[i].value == strSearch){
                intIndex = i;
        }
  }
  return intIndex;
}

function SubmitMe(sel,form) {
        if (sel != 0){
	     var objForm = document.getElementById(form);
             objForm.submit();
        }
}
function EnableSub(category){
        if (category != "ForOrders") {
                document.frm.selSubCategory.disabled=1;
                document.frm.selSubCategory.selectedIndex=0;
        }
        else{
                document.frm.selSubCategory.disabled=0;
        }
}

//This function validates new Country on manageCategory.php
function newSubCategory(){
	if (document.frm.txtNewSub.value==""){
		alert("Please enter a Country name.");
		document.forms[0].txtNewSub.focus();
		return false;
}
}

//This function validates new New Category on manageCategory.php 

function newCategory(){
	if(document.frm.txtNewCat.value==""){
		alert("Please enter a New Category.");
		document.forms[0].txtNewCat.focus();
		return false;
}
}

//This function checks that all information on manageContactInfo.php is entered
function ContactInfoValidate(){

	if(document.frm.txtMailInfo.value==""){
		alert("Please enter your Mailing information.");
		document.forms[0].txtMailInfo.focus();
		return false;
}

	if (document.frm.txtPhone.value==""){
		alert("Please enter a Phone Number.");
		document.forms[0].txtPhone.focus();
		return false;
}

	if (document.frm.txtClosing.value==""){
		alert("Please enter a Closing statement.");
		document.forms[0].txtClosing.focus();
		return false;
}

	if (document.frm.txtGreeting.value==""){
		alert("Please enter a Greeting statement.");
		document.forms[0].txtGreeting.focus();
		return false;
}

	if (document.frm.txtEmail.value==""){
		alert("Please enter an Email address.");
		document.forms[0].txtEmail.focus();
		return false;
}
}
	
//This funtion checks that all information on manageCatalog.php is correct
function ManCatValidate(){

	if (document.frm.selStockID.value==""){
		alert("Please enter a Stock ID.");
		document.forms[0].selStockID.focus();
		return false;
}

	if (document.frm.selSubCategory.disabled==false && document.frm.selSubCategory.options[0].selected){
		alert("Please Select a Country.");
		document.forms[0].selSubCategory.focus();
		return false;
}

	if (document.forms[0].selCategory.value==""){
		alert("Please select a Category.");
		document.forms[0].selCategory.focus();
		return false;
}
	
	if (document.frm.txtName.value==""){
		alert("Please enter a product Name.");
		document.forms[0].txtName.focus();
		return false;
}

	if (document.frm.selCondition.options[0].selected ){
		var val = confirm("You did not select a condition. Would you like to select one now?");
		if (val){
			document.forms[0].selCondition.focus();
			return false;
		}
}
	if (document.frm.txtPrice.value==""){
	
		var val = confirm("You did not enter a price. Would you like to enter one now?");
		if (val) {
			document.forms[0].txtPrice.focus();
			return false;
		}
}

	if (isNaN(document.frm.txtPrice.value)){
		alert("Please enter a Product Price without a $ sign. e.g. 10.00");
		document.forms[0].txtPrice.focus();
		return false;
}
	if (document.frm.txtDivision.value==""){
		var val = confirm("You did not enter a division/unit. Would you like to enter one now?");
		if (val) {
			document.forms[0].txtDivision.focus();
			return false;
		}
}

	if (document.frm.txtDescript.value==""){
		var val = confirm("You did not enter a description. Would you like to enter one now?");
		if (val){
			document.forms[0].txtDescript.focus();
			return false;
		}
}
} 

//This function checks that all information on manageTerms.php are correct
function ManTermsValidate(){

	if (document.frm.txtTerm.value==""){
		alert("Please enter a Policy Description or Cancel.");
		document.forms[0].txtTerm.focus();
		return false;
}
}

function SubmitForm(action) {
        var act = action;
  document.frm.selStockID.disabled=false;
  document.frm.hidTemp.value=action;
  document.frm.submit();
}

