﻿// JScript File
function initAjaxProgress()
{
    var pageHeight = (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
    //SET HEIGHT OF BACKGROUND
    var bg = document.getElementById('ajaxProgressBg');
    bg.style.height = (pageHeight + 1000) + 'px';
    //POSITION THE PROGRESS INDICATOR ON INITIAL LOAD
    reposAjaxProgress();
    //REPOSITION THE PROGRESS INDICATOR ON SCROLL
    window.onscroll = reposAjaxProgress;
}

function reposAjaxProgress()
{
    var div = document.getElementById('ajaxProgress');
    var st = document.body.scrollTop;
    if (st == 0) {
        if (window.pageYOffset) st = window.pageYOffset;
        else st = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }
    div.style.top = 150 + st + "px";
}

//Sasireka(03/Dec/10): Include the script for add to cart validation
function validate(RowIndex,GridName,CartSelection)  
    {  
     //flag for to check weather any option is selected or not. Default to all selected.  
     var flag = true;
     //Retrieves controls for which the drop down selected option is set.          
     var gv = document.getElementById(GridName);
     var Index = RowIndex+1;
     var items = gv.rows[Index].getElementsByTagName('select');
     for (i = 0; i < items.length; i++) {            
     if (items[i].type == "select-one") {
     var index = items[i].selectedIndex;
     if (items[i].options[index].value == 0) {
     flag = false;}
     }
     }
     if(!flag)  
     {
        // alert("Please select option");
         $find(CartSelection).show();
   }   
       return flag;  
   }  
