﻿// JScript File

/* SET HEIGHT OF FILEMANAGER IFRAME*/
        function getDocHeight(doc) {
          var docHt = 0, sh, oh;
          if (doc.height) docHt = doc.height;
          else if (doc.body) {
            if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
            if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
            if (sh && oh) docHt = Math.max(sh, oh);
          }
          return docHt;
        }

        function setIframeHeight(iframeName) {
          var iframeWin = window.frames[iframeName];
          var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
          if ( iframeEl && iframeWin ) {
            iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
            var docHt = getDocHeight(iframeWin.document);
            // need to add to height to be sure it will all show
            if (docHt) iframeEl.style.height = docHt + 30 + "px";
          }
        }  

/* ENABLE/DISABLE SUBMIT BUTTON ON CONTACT FORM */
function setSubmitButton(objVal)
{
    if (objVal == true)
    {
        document.forms.frmGetMeInfo.btnContactMe.disabled = false;
    }
    else
    {
        document.forms.frmGetMeInfo.btnContactMe.disabled = true;
    }
}


/* ENABLE/DISABLE SUBMIT BUTTON ON CONTACT FORM */
function setSubmitButton2(objVal)
{
    if (objVal == true)
    {
        document.forms.frmGetMeInfo.btnContactMe2.disabled = false;
    }
    else
    {
        document.forms.frmGetMeInfo.btnContactMe2.disabled = true;
    }
}


/* VALIDATE CONTACT FORM */
function validateForm(frmGetMeInfo)
    {
    if(document.forms.frmGetMeInfo.INFO_REQUEST_NAME.value=="")
        {
            alert("Please enter your full name.");
            document.forms.frmGetMeInfo.INFO_REQUEST_NAME.focus();
            return false;
        }

    if(document.forms.frmGetMeInfo.INFO_REQUEST_EMAIL.value=="")
        {
            alert("Please enter your email address.");
            document.forms.frmGetMeInfo.INFO_REQUEST_EMAIL.focus();
            return false;
        }
    return true;
}


/* CONFIRM DELETION OF INFOREQUEST */
function ConfirmDelInfoRequest(delID)
    {
        var goStr = 'admin.asp?adAction=DeleteInfoRequest&delID='+delID
        if (confirm('Confirm!\nDo you really want to delete this information request?')) {
            //alert(goStr);
            window.location=goStr;
            }
    }
    
    
/* CONFIRM DELETION OF CATEGORY */
function ConfirmDelCategory(delID)
    {
        var goStr = 'admin.asp?adAction=DeleteCategory&delID='+delID
        if (confirm('Confirm!\nDo you really want to delete this category?')) {
            //alert(goStr);
            window.location=goStr;
            }
    } 
    
    
    
    
/* CONFIRM DELETION OF MAIN CATEGORY */
function ConfirmDelMainCategory(delID)
    {
        var goStr = 'admin.asp?adAction=DeleteMainCategory&delID='+delID
        if (confirm('Confirm!\nDo you really want to delete this main category?')) {
            //alert(goStr);
            window.location=goStr;
            }
    }       
    
    
    
    
/* VALIDATE NEW CATEGORY FORM */
function validateNewCatForm(frmNewCategory)
    {
    if(document.forms.frmNewCategory.categoryName.value=="")
        {
            alert("Please enter a name for the Category.");
            document.forms.frmNewCategory.categoryName.focus();
            return false;
        }
    if(document.forms.frmNewCategory.category_description.value=="")
        {
            alert("Please enter a description for the Category.");
            document.forms.frmNewCategory.category_description.focus();
            return false;
        }        
    return true;
}




/* VALIDATE NEW MAIN CATEGORY FORM */
function validateNewMainCatForm(frmNewMainCategory)
    {
    if(document.forms.frmNewMainCategory.mainCategoryName.value=="")
        {
            alert("Please enter a name for the Main category.");
            document.forms.frmNewMainCategory.mainCategoryName.focus();
            return false;
        }
        
    if(document.forms.frmNewMainCategory.mainCategoryDescription.value=="")
        {
            alert("Please enter a name for the Main category description.");
            document.forms.frmNewMainCategory.mainCategoryDescription.focus();
            return false;
        }        
        
    return true;
}



/* CONFIRM DELETION OF PRODUCT */
function ConfirmDelProduct(delID)
    {
        var goStr = 'admin.asp?adAction=DeleteProduct&delID='+delID
        if (confirm('Confirm!\nDo you really want to delete this product?')) {
            //alert(goStr);
            window.location=goStr;
            }
    }  
    
    


/* VALIDATE ADDPRODUCT FORM */
function validateAddProduct(frmAddProduct)
    {
    if(document.forms.frmAddProduct.productName.value=="")
        {
            alert("Please enter product name.");
            document.forms.frmAddProduct.productName.focus();
            return false;
        }

    if(document.forms.frmAddProduct.product_short_description.value=="")
        {
            alert("Please enter the short description.");
            document.forms.frmAddProduct.product_short_description.focus();
            return false;
        }
        
    if(document.forms.frmAddProduct.product_description.value=="")
        {
            alert("Please enter the description.");
            document.forms.frmAddProduct.product_description.focus();
            return false;
        }   
        
    if(document.forms.frmAddProduct.product_price.value=="")
        {
            alert("Please enter the product price.");
            document.forms.frmAddProduct.product_price.focus();
            return false;
        }              
        
    return true;
}




/* VALIDATE EDITPRODUCT FORM */
function validateEditProduct(frmEditProduct)
    {
    if(document.forms.frmEditProduct.productName.value=="")
        {
            alert("Please enter product name.");
            document.forms.frmEditProduct.productName.focus();
            return false;
        }

    if(document.forms.frmEditProduct.product_short_description.value=="")
        {
            alert("Please enter the short description.");
            document.forms.frmEditProduct.product_short_description.focus();
            return false;
        }
        
    if(document.forms.frmEditProduct.product_description.value=="")
        {
            alert("Please enter the description.");
            document.forms.frmEditProduct.product_description.focus();
            return false;
        }   
        
    if(document.forms.frmEditProduct.product_price.value=="")
        {
            alert("Please enter the product price.");
            document.forms.frmEditProduct.product_price.focus();
            return false;
        }              
        
    return true;
}


/* VIEW AN IMAGE. Usage: <img width=400 name=pic src="/images/<%=site_name & "/" & rs("pic")%>" /> */
	function ViewPic(this_pic){
		document.pic.src=this_pic;
	}
	
	
	
/* VALIDATE NEW/CHANGE CATEGORY IMAGE */	
function validateCatImageForm(frmAddCatImg)
    {
        if(document.forms.frmAddCatImg.File1.value=="")
            {
                alert("Please select your image first.");
                document.forms.frmAddCatImg.File1.focus();
                return false;
            }
        return true;
    }




/* VALIDATE NEW PAGE NAME */	
function validateNewPageFrm(frmNewPage)
    {
        if(document.forms.frmNewPage.page_title.value=="")
            {
                alert("Please enter the title of the page.");
                document.forms.frmNewPage.page_title.focus();
                return false;
            }
        return true;
    }
    
    
    
/* VALIDATE SAVE PAGE NAME */	
function validateEditPageFrm(frmEditPage)
    {
        if(document.forms.frmEditPage.page_title.value=="")
            {
                alert("Please enter the title of the page.");
                document.forms.frmEditPage.page_title.focus();
                return false;
            }
        return true;
    }    
    
    
    
/*CONFIRM DELETION OF PRODUCT*/
function ConfirmDeletePage(delID)
    {
        var goStr = 'admin.asp?adAction=DeletePage&delID='+delID
        if (confirm('Confirm!\nDo you really want to delete this page?')) {
            //alert(goStr);
            window.location=goStr;
            }
    }     