function ProductLinePageHelperv2(SiteID,ProductLineID,KeyManager,GlobalAjaxContextHandler)
{
    this.SiteID         = SiteID;
    this.ProductLineID  = ProductLineID;
    this.KeyManager     = KeyManager;
    this.AjaxRoot       = '/shared/php/ajax';
    this.GlobalAjaxContextHandler = GlobalAjaxContextHandler;
    this.AddToCartEnabled= false;
    this.DefaultValues  = Array();
    this.DefaultPriceBox= "";
    this.Token1 = '';
    this.ImageThumbs    = Array();
    this.ImageMain      = Array();
    this.IsMainImage    = 0;
    this.CurrentThumb   = 0;
    this.CurrentImageID = 0;
    
    this.SendToFriend=function()
    { 
        var Parameters      = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionSendToFriend&SiteID="+this.SiteID+"&ProductLineID="+this.ProductLineID;        
        var objAjaxv2       = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.SendToFriendCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);
        var temp = document.getElementById('email_to_friend_container');
        Parameters+='&'+objAjaxv2.GetFormValues(temp);
        objAjaxv2.Parameters=Parameters;        
        objAjaxv2.EventData = null;
        objAjaxv2.GetPost(true);
    }
    
    this.SendToFriendCallBack = function(Success,Response,EventData)
    {
        this.GenericCallBack(Success,Response,EventData);                
    }
    
    this.YMMBoxSetYear=function()
    {
        var Year            = $('#YMMBoxYear')[0].options[$('#YMMBoxYear')[0].selectedIndex].value;
        var MakeID          = $('#YMMBoxMakeID')[0].options[$('#YMMBoxMakeID')[0].selectedIndex].value;
        var ModelID         = $('#YMMBoxModelID')[0].options[$('#YMMBoxModelID')[0].selectedIndex].value;
        var Parameters      = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionYMMBoxSetYear&SiteID="+this.SiteID+"&YMMBoxYear="+Year+"&YMMBoxModelID="+ModelID+"&YMMBoxMakeID="+MakeID+"&ProductLineID="+this.ProductLineID;
        var objAjaxv2       = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.YMMBoxSetYearCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);
        objAjaxv2.EventData = null;
        objAjaxv2.GetPost(true);
    }
    
    this.YMMBoxSetYearCallBack = function(Success,Response,EventData)
    {
        this.GenericCallBack(Success,Response,EventData);        
    }
    
    this.YMMBoxSetMake=function()
    {
        //var Year            = $('#YMMBoxYear')[0].options[$('#YMMBoxYear')[0].selectedIndex].value;
        var Make            = $('#YMMBoxMakeID')[0].options[$('#YMMBoxMakeID')[0].selectedIndex].value;        
        var Parameters      = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionYMMBoxSetMake&SiteID="+this.SiteID+"&YMMBoxMakeID="+Make+"&ProductLineID="+this.ProductLineID; //&YMMBoxYear="+Year+"
        var objAjaxv2       = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.YMMBoxSetMakeCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);
        objAjaxv2.EventData = null;
        objAjaxv2.GetPost(true);
    }
    
    this.YMMBoxSetMakeCallBack = function(Success,Response,EventData)
    {
        this.GenericCallBack(Success,Response,EventData);        
    }
    
    this.YMMBoxSetModel=function()
    {
        //var Year            = $('#YMMBoxYear')[0].options[$('#YMMBoxYear')[0].selectedIndex].value;
        var MakeID          = $('#YMMBoxMakeID')[0].options[$('#YMMBoxMakeID')[0].selectedIndex].value;
        var ModelID         = $('#YMMBoxModelID')[0].options[$('#YMMBoxModelID')[0].selectedIndex].value;
        var Parameters      = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionYMMBoxSetModel&SiteID="+this.SiteID+"&YMMBoxMakeID="+MakeID+"&YMMBoxModelID="+ModelID+"&ProductLineID="+this.ProductLineID;
        var objAjaxv2       = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.YMMBoxSetModelCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);
        objAjaxv2.EventData = null;
        objAjaxv2.GetPost(true);
    }
    this.YMMBoxSetModelCallBack = function(Success,Response,EventData)
    {
        this.GenericCallBack(Success,Response,EventData);        
    }
    
    this.YMMBoxSetAppNote=function(Forced)
    {
        //IE6 hits onblur with our ie width fix and has -1 for the index
        if($('#YMMBoxApplicationID')[0].selectedIndex < 0)
            return;
        var Year            = $('#YMMBoxYear')[0].options[$('#YMMBoxYear')[0].selectedIndex].value;
        var ModelID         = $('#YMMBoxModelID')[0].options[$('#YMMBoxModelID')[0].selectedIndex].value;
        var ApplicationID   = $('#YMMBoxApplicationID')[0].options[$('#YMMBoxApplicationID')[0].selectedIndex].value;
        if(ApplicationID=='' && Forced !== true)
            return;
        var AttributeOption1ID='';
        if($('#YMMBoxAttributeOption1ID')[0] != null)
            AttributeOption1ID=$('#YMMBoxAttributeOption1ID')[0].options[$('#YMMBoxAttributeOption1ID')[0].selectedIndex].value;
        var Parameters      = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionYMMBoxSetAppNote&SiteID="+this.SiteID+"&YMMBoxYear="+Year+"&YMMBoxModelID="+ModelID+"&YMMBoxApplicationID="+ApplicationID+"&YMMBoxAttributeOption1ID="+AttributeOption1ID+"&ProductLineID="+this.ProductLineID;
        var objAjaxv2       = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.YMMBoxFetchAppNoteCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);        
        objAjaxv2.GetPost(true);
    }
    this.YMMBoxFetchAppNoteCallBack = function(Success,Response,EventData)
    {
        this.GenericCallBack(Success,Response,EventData);
    }
    
    this.CheckForSingleApp=function()
    {
        if($('#YMMBoxApplicationID')[0].length==2)
        {
            $('#YMMBoxApplicationID')[0].selectedIndex=1;
            this.YMMBoxSetAppNote();
        }
    }
    
    this.CheckForSingleAttribute=function(ID)
    {
        if ($('#'+ID)[0] != null)
        {
            if ($('#'+ID)[0].length==2)
            {
                $('#'+ID)[0].selectedIndex=1;
                if (ID=='YMMBoxAttributeOption1ID')
                    this.YMMBoxSetAttribute1();
                else if (ID=='YMMBoxAttributeOption2ID')
                    this.YMMBoxSetAttribute2();
            }
        }
        else if (ID != null && ID.Options != null)
        {
            if (ID.Length==2)
            {
                ID.SelectedIndex=1;
                this.YMMBoxSetAttribute2(ID.Options[1]);  
            }
        }
    }
    
    this.YMMBoxSetAttribute1=function(Option1Obj)
    {
        //IE6 hits onblur with our ie width fix and has -1 for the index
        if($('#YMMBoxAttributeOption1ID')[0] != null && $('#YMMBoxAttributeOption1ID')[0].selectedIndex < 0)
            return;
        
        var Year            = $('#YMMBoxYear')[0].options[$('#YMMBoxYear')[0].selectedIndex].value;
        var ModelID         = $('#YMMBoxModelID')[0].options[$('#YMMBoxModelID')[0].selectedIndex].value;
        var AttributeOption1ID = Option1Obj && Option1Obj.ExtraData ? Option1Obj.ExtraData : $('#YMMBoxAttributeOption1ID')[0].options[$('#YMMBoxAttributeOption1ID')[0].selectedIndex].value;        
        var Application     = $('#YMMBoxApplicationID')[0] != null ? "&YMMBoxApplicationID="+$('#YMMBoxApplicationID')[0].value : ""; 
        var Parameters      = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionYMMBoxSetAttributeOption1ID&SiteID="+this.SiteID+"&YMMBoxYear="+Year+"&YMMBoxModelID="+ModelID+"&YMMBoxAttributeOption1ID="+AttributeOption1ID+"&ProductLineID="+this.ProductLineID+Application;
        var objAjaxv2       = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.YMMBoxSetAttributeOption1CallBack, "POST", Parameters, this.GlobalAjaxContextHandler);        
        objAjaxv2.GetPost(true);
    }
    
    this.YMMBoxSetAttributeOption1CallBack=function(Success,Response,EventData)
    {
        this.GenericCallBack(Success,Response,EventData);
    }
    
    this.YMMBoxSetAttribute2=function(Option2Obj)
    {
        //IE6 hits onblur with our ie width fix and has -1 for the index
        if($('#YMMBoxAttributeOption2ID')[0] != null && $('#YMMBoxAttributeOption2ID')[0].selectedIndex < 0)
            return;
            
        var Year            = $('#YMMBoxYear')[0].options[$('#YMMBoxYear')[0].selectedIndex].value;
        var ModelID         = $('#YMMBoxModelID')[0].options[$('#YMMBoxModelID')[0].selectedIndex].value;
        var AttributeOption1ID = $('#YMMBoxAttributeOption1ID')[0].options[$('#YMMBoxAttributeOption1ID')[0].selectedIndex].value;        
        var AttributeOption2ID = Option2Obj && Option2Obj.ExtraData ? Option2Obj.ExtraData : $('#YMMBoxAttributeOption2ID')[0].options[$('#YMMBoxAttributeOption2ID')[0].selectedIndex].value;        
        var Application     = $('#YMMBoxApplicationID')[0] != null ? "&YMMBoxApplicationID="+$('#YMMBoxApplicationID')[0].value : "";
        var Parameters      = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionYMMBoxSetAttributeOption2ID&SiteID="+this.SiteID+"&YMMBoxYear="+Year+"&YMMBoxModelID="+ModelID+"&YMMBoxAttributeOption1ID="+AttributeOption1ID+"&YMMBoxAttributeOption2ID="+AttributeOption2ID+"&ProductLineID="+this.ProductLineID+Application;
        var objAjaxv2       = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.YMMBoxSetAttributeOption1CallBack, "POST", Parameters, this.GlobalAjaxContextHandler);        
        objAjaxv2.GetPost(true);
    }
    
    this.YMMBoxSetAttributeOption2CallBack=function(Success,Response,EventData)
    {
        this.GenericCallBack(Success,Response,EventData);
    }
    
    this.ResetDropDown=function(ControlID)
    {
        if($('#'+ControlID)[0] != null)
        {
            $('#'+ControlID)[0].selectedIndex=0;
            for(var c=$('#'+ControlID)[0].length;c>0;c--)
            {
                $('#'+ControlID)[0].remove(c);
            }
            //$(ControlID).options[0] = new Option(this.DefaultValues[ControlID],'',true);            
            $('#'+ControlID)[0].disabled=true;
            $('#'+ControlID)[0].className='disabled_control';            
        }
    }
    this.DisableAddToCart=function()
    {
        this.AddToCartEnabled=false;
        if($('#add_to_cart_button')[0] != null)
            $('#add_to_cart_button')[0].src='/images/product_line/add-to-cart.png'; // no longer disabled graphic
        $('#product_application_id')[0].value='';
    }
    
    this.EnableAddToCart=function(ApplicationID,Note)
    {
        this.AddToCartEnabled=true;
         if($('#add_to_cart_button')[0] != null)
            $('#add_to_cart_button')[0].src='/images/product_line/add-to-cart.png';
         
         if($('#scn')[0] != null)
         {
             if(Note === undefined)
                $('#scn')[0].value='';
             else
                $('#scn')[0].value=Note;
         }
        $('#product_application_id')[0].value=ApplicationID;
    }
    
    this.EnableAddProductToCart=function(ProductID,Note)
    {
        this.AddToCartEnabled=true;
         if($('#add_to_cart_button')[0] != null)
            $('#add_to_cart_button')[0].src='/images/product_line/add-to-cart.png';
         
         if($('#scn')[0] != null)
         {
             if(Note === undefined)
                $('#scn')[0].value='';
             else
                $('#scn')[0].value=Note;
         }
        $('#product_id')[0].value=ProductID;
        $('#mode')[0].value='insert_product_by_id';
    }
    
    this.AddToCart=function()
    {
        if(this.AddToCartEnabled)            
            $('#AddToCartForm')[0].submit();        
        else
            alert('Please select all options for your vehicle to order');
    }
    this.ShowWarning=function(Warning)
    {
        alert(Warning);
    }
    this.ClearFitmentWarning=function()
    {
        if($('#fitment_warning')[0] != null)
            $('#fitment_warning')[0].style.display='none';
    }
    this.SetDefaultOptionValue=function(ID,Value)
    {
        this.DefaultValues[ID]=Value;
    }
    this.GenericCallBack = function(Success, ResponseObject, EventData)
    {
        if(Success)
        {
            var element;
            var event_array = Array();
            try
            {
                eval("var obj= "+ResponseObject.responseText);
                this.LastResponse=obj;
                if(EventData != null)
                {
                    if(EventData.constructor != Array)
                        event_array.push(EventData);
                    else
                        event_array = EventData;
                        
                    for(var c=0; c<event_array.length; c++)
                    {
                        element = document.getElementById(event_array[c]);
                        if(obj.Response != "")
                            element.innerHTML = obj.Response;
                    }
                }                
                
                if(obj.Javascript != null)            
                    window.eval(obj.Javascript);
            }
            catch(ex)
            {
                alert('Sorry an error has occured '+ex.toString());    
            }                
        }
    }
    
    this.dump=function(arr,level)
    {
        var dumped_text = "";
        if(!level) level = 0;
        
        //The padding given at the beginning of the line.
        var level_padding = "";
        for(var j=0;j<level+1;j++) level_padding += "    ";
        
        if(typeof(arr) == 'object') { //Array/Hashes/Objects 
            for(var item in arr) {
                var value = arr[item];
                
                if(typeof(value) == 'object') { //If it is an array,
                    dumped_text += level_padding + "'" + item + "' ...\n";
                    dumped_text += dump(value,level+1);
                } else {
                    dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
                }
            }
        } else
        { //Stings/Chars/Numbers etc.
            dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
        }
        return dumped_text;
    }
    
    this.COC2SelectApplication = function(OptionCount, ApplicationID)
    {
        var CheckboxID         = "product_application_id"+OptionCount;
        var CheckboxElement    = document.getElementById(CheckboxID);
        
        if(ApplicationID != -1)
        {
            CheckboxElement.disabled    = false;
            CheckboxElement.checked     = true;
            CheckboxElement.value        = ApplicationID;
            // update the pricing for the option for the selected application
            // update the image for the option for the selected application
            this.COC2UpdateOptionInformation(OptionCount, ApplicationID);
        }
        else
        {
            CheckboxElement.disabled    = true;
            CheckboxElement.checked     = false;
            CheckboxElement.value         = -1;
        }
    }
    
    this.COC2UpdateOptionInformation = function(OptionCount, ApplicationID)
    {        
        var Parameters        = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionCOC2UpdateOptionInfo&SiteID="+this.SiteID+"&ProductLineID="+this.ProductLineID+"&ProductApplicationID="+ApplicationID+"&OptionCount="+OptionCount;
        var objAjaxv2         = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.GenericCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);
        objAjaxv2.EventData   = null;
        objAjaxv2.GetPost(true);
    }
    
    this.COC2CheckSelectedApplication = function(OptionCount)
    {
        // is the checkbox checked?
        var CheckboxID         = "product_application_id"+OptionCount;
        var CheckboxElement    = document.getElementById(CheckboxID);
        var IsChecked         = (CheckboxElement.checked === true) ? true : false;
        
        // are there multiple applications (i.e. is there a select)
        var MultipleOptionsID     = "multiple_options"+OptionCount;
        var MultipleOptions        = (document.getElementById(MultipleOptionsID).value == 1) ? true : false;
        
        // get the application element
        var ApplicationElementID     = "application"+OptionCount;
        var ApplicationElement        = document.getElementById(ApplicationElementID);
        
        // if there is a select, see if need to reset default value
        if(MultipleOptions === true)
        {
            if(IsChecked === false)
            {
                var DefaultOptionID                    = "option_default"+OptionCount;
                ApplicationElement.selectedIndex     = DefaultOptionID;
                CheckboxElement.value                = -1;
                CheckboxElement.disabled            = true;
            }
        }
        // otherwise, set the value of the checkbox based on if checked or not
        else
        {
            if(IsChecked === false)
                CheckboxElement.value = -1;
            else
                CheckboxElement.value = ApplicationElement.value;
        }
    }
    
    this.COC2AddToCart = function()
    {
        var SelectedApplicationCount     = 0;
        var OptionCount                 = document.getElementById("application_count").value;
        var OptionNumber                = 0;
        var CheckboxID                    = null;
        var CheckboxElement             = null;
        
        // how many applications have been selected?
        for(var i = 0; i <= OptionCount; i++)
        {
            OptionNumber    = i;
            CheckboxID         = "product_application_id"+OptionNumber;
            CheckboxElement    = document.getElementById(CheckboxID);
            // if the checkbox is undefined, that is because it is disabled and it isn't checked
            if(CheckboxElement != undefined)
            {
                // is the checkbox checked?
                if(CheckboxElement.checked === true)
                    SelectedApplicationCount++;
            }
        }
        
        // if no applications have been selected, do not proceed
        if(SelectedApplicationCount == 0)
        {
            alert("You must select at least one Product that you would like to order.");
            return;
        }
        // otherwise it is okay to proceed
        else
        {
            this.AddToCartEnabled=true;
            this.AddToCart();
        }
    }
    
    this.Popup = function(url)
    {
        var newwin = window.open(url, null, "location=no, menubar=no, status=no, toolbar=no, scrollbars=no");
    }
    
    this.GetProductImageWithSize=function(ProductApplicationSelect,Size)
    {
        var ProductApplicationID = ProductApplicationSelect.options[ProductApplicationSelect.selectedIndex].value;        
        var ElementID         = "selected_product_image";        
        var ajaxv2             = new Ajaxv2();
        var Parameters         = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionGetProductImage&SiteID="+this.SiteID+"&Size="+Size+"&ProductLineID="+this.ProductLineID+"&ProductApplicationID="+ProductApplicationID
        var objAjaxv2         = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.GenericCallBack, "POST", Parameters, GlobalAjaxContextHandler);
        objAjaxv2.EventData    = ElementID;
        objAjaxv2.GetPost(true);
    }
    
    this.GetProductFeatures = function(ProductApplicationSelect, position)
    {
        var ProductApplicationID = ProductApplicationSelect.options[ProductApplicationSelect.selectedIndex].value;
        
        var ElementID = "product_features"+position;
        var ajaxv2 = new Ajaxv2();
        var Parameters = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionGetProductFeatures&SiteID="+this.SiteID+"&ProductApplicationID="+ProductApplicationID;
        var objAjaxv2 = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.GetProductFeaturesCallback, "POST", Parameters, GlobalAjaxContextHandler);
        objAjaxv2.EventData = ElementID;
        objAjaxv2.GetPost(true);
    }
    
    this.GetProductFeaturesCallback = function(Success, ResponseObject, EventData)
    {
        if(Success)
        {
            var element;
            var event_array = Array();
            try
            {
                eval("var obj= "+ResponseObject.responseText);
                this.LastResponse=obj;

                element = document.getElementById(EventData);
                if(obj.Response != "")
                    element.innerHTML = obj.Response;
            }
            catch(ex)
            {
                alert('Sorry an error has occured '+ex.toString());    
            }                
        }
    }
    
    this.CO1AttributeYMMAddToCart=function()
    {
        if(this.CO1AttributeYMMValidate() != true)
            return false;
                
        this.AddToCartEnabled=true;
        this.AddToCart();        
    }
    
    this.CO1AttributeYMMValidate=function()
    {
        
        var objects = $('#colored_ordering_container')[0].getElementsByTagName('select');
        for(var c = 0; c < objects.length; c++)
        {
            var obj = objects[c];
            if(obj.selectedIndex >=0 && obj.options[obj.selectedIndex].value != "-1")
                return true;
        }
        alert("Please select the colors for the part(s) you would like to order.");
        return false;
    }
    
    this.COSUSelectApplication = function(OptionCount, ApplicationID)
    {
        var CheckboxID         = "product_application_id"+OptionCount;
        var CheckboxElement    = document.getElementById(CheckboxID);
        
        if(ApplicationID != -1)
        {
            CheckboxElement.disabled    = false;
            CheckboxElement.checked     = true;
            CheckboxElement.value        = ApplicationID;            
            // update the image-price for the option for the selected application
            this.COSUUpdateOptionInformation(OptionCount, ApplicationID);
        }
        else
        {
            CheckboxElement.disabled    = true;
            CheckboxElement.checked     = false;
            CheckboxElement.value         = -1;
        }
    }
    
    this.COSUUpdateOptionInformation = function(OptionCount, ApplicationID)
    {
        var Parameters        = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionCOSUUpdateOptionInformation&SiteID="+this.SiteID+"&ProductLineID="+this.ProductLineID+"&ProductApplicationID="+ApplicationID+"&OptionCount="+OptionCount;
        var objAjaxv2         = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.GenericCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);
        objAjaxv2.EventData   = null;
        objAjaxv2.GetPost(true);
    }
    
    this.COSUCheckSelectedApplication = function(OptionCount)
    {
        // is the checkbox checked?
        var CheckboxID         = "product_application_id"+OptionCount;
        var CheckboxElement    = document.getElementById(CheckboxID);
        var IsChecked         = (CheckboxElement.checked === true) ? true : false;
        
        // are there multiple applications (i.e. is there a select)
        var MultipleOptionsID     = "multiple_options"+OptionCount;
        var MultipleOptions        = (document.getElementById(MultipleOptionsID).value == 1) ? true : false;
        
        // get the application element
        var ApplicationElementID     = "application"+OptionCount;
        var ApplicationElement        = document.getElementById(ApplicationElementID);
        
        // if there is a select, see if need to reset default value
        if(MultipleOptions === true)
        {
            if(IsChecked === false)
            {
                var DefaultOptionID                    = "option_default"+OptionCount;
                ApplicationElement.selectedIndex     = DefaultOptionID;
                CheckboxElement.value                = -1;
                CheckboxElement.disabled            = true;
            }
        }
        // otherwise, set the value of the checkbox based on if checked or not
        else
        {
            if(IsChecked === false)
                CheckboxElement.value = -1;
            else
                CheckboxElement.value = ApplicationElement.value;
        }
    }
    
    this.COSUAddToCart = function()
    {
        var SelectedApplicationCount     = 0;
        var OptionCount                 = document.getElementById("application_count").value;
        var OptionNumber                = 0;
        var CheckboxID                    = null;
        var CheckboxElement             = null;
        
        // how many applications have been selected?
        for(var i = 0; i <= OptionCount; i++)
        {
            OptionNumber    = i;
            CheckboxID         = "product_application_id"+OptionNumber;
            CheckboxElement    = document.getElementById(CheckboxID);
            // if the checkbox is undefined, that is because it is disabled and it isn't checked
            if(CheckboxElement != undefined)
            {
                // is the checkbox checked?
                if(CheckboxElement.checked === true)
                    SelectedApplicationCount++;
            }
        }
        
        // if no applications have been selected, do not proceed
        if(SelectedApplicationCount == 0)
        {
            alert("You must select at least one Product that you would like to order.");
            return;
        }
        // otherwise it is okay to proceed
        else
        {
            this.AddToCartEnabled=true;
            this.AddToCart();
        }
    }
    
    this.IOIAddToCart=function(ApplicationID,Note)
    {
        this.EnableAddToCart(ApplicationID,Note);
        this.AddToCart();
    }
    this.BackgroundAddToCart=function(ApplicationID,ResultContainerID)
    {
        var Parameters        = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionAddToShoppingCart&SiteID="+this.SiteID+"&ProductLineID="+this.ProductLineID+"&ProductApplicationID="+ApplicationID;
        var objAjaxv2         = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.GenericCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);
        objAjaxv2.EventData   = ResultContainerID;
        objAjaxv2.GetPost(true);
    }
    this.ResetPricebox=function()
    {
        /*var Parameters      = "token="+this.Token1+"&key="+this.KeyManager.GetProductLinePageKey()+"&event=ActionResetPricebox&SiteID="+this.SiteID+"&ProductLineID="+this.ProductLineID;
        var objAjaxv2       = new Ajaxv2(this.AjaxRoot+"/product_line_page_helper_v2.php", this, this.GenericCallBack, "POST", Parameters, this.GlobalAjaxContextHandler);
        objAjaxv2.EventData = 'price_box_pricing';
        objAjaxv2.GetPost(true);*/
        $('#price_box_pricing')[0].innerHTML=this.DefaultPriceBox;
    }
    
    this.SwapMainImage=function(cnt)
    {
        var main_image      = document.getElementById('FormImage');
        main_image.src      = this.ImageThumbs[cnt][1];
        var s               = this.ImageThumbs[cnt][2];
        main_image.title    = s.replace('&amp;','&').replace('&quot;','"');
        this.IsMainImage    = 1;  
        this.CurrentImageID = this.ImageThumbs[cnt][0];
        this.CurrentThumb   = cnt;
    }
    
    this.AddImageThumb=function(image_id, thumb_200x200, thumb_title)
    {
        var cnt = 0;
        
        if(this.ImageThumbs.length != 0)
            cnt = this.ImageThumbs.length;
            
        this.ImageThumbs[cnt] = new Array(image_id, thumb_200x200, thumb_title);
    }
    
    this.AddImageMain=function(image_id, thumb_200x200, thumb_title)
    {
        var cnt = 0;
        
        if(this.ImageMain.length != 0)
            cnt = this.ImageMain.length;
            
        this.ImageMain[cnt] = new Array(image_id, thumb_200x200, thumb_title);
        this.CurrentImageID = image_id;
    }
    
    this.SubmitImageLandingForm=function(product_line_id,product_id,image_id,url)
    {
        if(image_id == 0)
            image_id = this.CurrentImageID;
            
        var form = document.createElement("form");
        form.setAttribute("method", "post");
        form.setAttribute("action", url);
        form.setAttribute("target", "target_of_post");
        
        var input_pline = document.createElement('input');
        input_pline.type = 'hidden';
        input_pline.name = 'product_line_id';
        input_pline.value = product_line_id;
        form.appendChild(input_pline);

        var input_prod = document.createElement('input');
        input_prod.type = 'hidden';
        input_prod.name = 'product_id';
        input_prod.value = product_id;
        form.appendChild(input_prod);
        
        var input_image = document.createElement('input');
        input_image.type = 'hidden';
        input_image.name = 'image_id';
        input_image.value = image_id;
        form.appendChild(input_image);
        
        document.body.appendChild(form);
        
        form.submit();

        document.body.removeChild(form);
    }
    
    this.GetReviews = function(start, count, product_line_id, product_id, order_by)
    {
        var ElementID  = "reviews_container";
        var Parameters = "action=GetReviews&start="+start+"&count="+count+"&product_line_id="+product_line_id+"&product_id="+product_id+"&order_by="+order_by;
        var objAjaxv2  = new Ajaxv2(this.AjaxRoot+"/product_review_helper.php", this, this.GenericCallBack, "POST", Parameters, GlobalAjaxContextHandler);
        objAjaxv2.EventData = ElementID;
        objAjaxv2.GetPost(true);
    }
}

