 
//                    $(function(){
//                    $(document).click(function(e){
//                    if ($(e.target).closest("#drop").length == 0) {
//                    $('div#drop').slideUp('slow');
//                    }
//                    });
//                    <!--$('div#drop').blur(function(){$(this).slideUp('slow');});-->
//                    $('li#triggerdrop').mouseenter(function(){$('div#drop').slideDown('slow');$('div#drop').focus();});
//                    });
//                    var vVariantID = 0;
//                    var pProductID = 0;

//                    function ajaxAddtoWishList()
//                    {
//                    var pid  = <xsl:value-of select="ProductID" disable-output-escaping="yes"></xsl:value-of>;
//                    var vid  = <xsl:value-of select="VariantID" disable-output-escaping="yes"></xsl:value-of>;
//                    var qty = getQty(pid,vid);
//                    var $url = "addtocart.aspx?IsWishList=1&amp;Quantity="+qty+"&amp;ProductID="+pid+"&amp;VariantID="+vid;

//                    $.ajax({
//                    url: $url,
//                    success: function(data) {
//                    window.location.href = "wishlist.aspx?returnurl="+window.location.pathname;
//                    }
//                    });
//                    }

                    function getQty(pid,vid)
                    {
                        var el = $get('Quantity_' + pid + '_' + vid);
                        if (el) {
                        return el.value;
                        }
                        return '1';
                    }

                    function GetPRFrequency(pid, vid) {
                        var pr = document.getElementById("pr");
                        if (pr == null) {
                            //alert('PR1');
                            pr = document.getElementById("pr_" + pid + "_" + vid);
                            if (pr == null) {
                                //alert('PR2');
                                pr = document.getElementById("pr_" + pid);
                                if (pr == null) {
                                return "0"
                                }
                                else {
                                    return pr.options[pr.selectedIndex].value;
                                }
                            }
                            else {
                                return pr.options[pr.selectedIndex].value;
                            }
                        }
                        else{
                        return pr.value;
                        }
                    }

//                    function viewLargeImage()
//                    {
//                    var imgLarge = <xsl:value-of select="ProductID" disable-output-escaping="yes"></xsl:value-of> + ".jpg";
//                    }



                    function AjaxAddToCart(pid,vid) {
                        
                        vVariantID = vid;
                        pProductID = pid;
                        document.getElementById('AddToCartButton_' + pProductID + '_' + vVariantID).style.display ='none';
                        document.getElementById('preload'  + vVariantID).style.display ='block';
                        var qty = getQty(pid,vid);
                        var colorDDL = document.getElementById("Color_"+ pProductID + '_' + vVariantID);
                        var sizeDDL = document.getElementById("Size_"+ pProductID + '_' + vVariantID);
                        var c = "";
                        var cText = "";
                        if (colorDDL != null) {
                            c = colorDDL.options[colorDDL.selectedIndex].value;
                            cText = colorDDL.options[colorDDL.selectedIndex].text;
                            if (cText.indexOf("Out of Stock") > 0) {
                                document.getElementById('preload' + vVariantID).style.display = 'none';
                                document.getElementById('AddToCartButton_' + pProductID + '_' + vVariantID).style.display = 'inline';                                
                                alert("The selected product is Out of Stock.");
                                return false;
                            }
                            else if (c == "-,-") {
                                document.getElementById('preload' + vVariantID).style.display = 'none';
                                document.getElementById('AddToCartButton_' + pProductID + '_' + vVariantID).style.display = 'inline';                                
                                alert("Please select a Color");
                                return false;
                            }
                            //alert(c);
                        }

                        var s = "";
                        var sText = "";
                        if (sizeDDL != null) {
                            s = sizeDDL.options[sizeDDL.selectedIndex].value;
                            sText = sizeDDL.options[sizeDDL.selectedIndex].text;
                            if (sText.indexOf("Out of Stock") > 0) {
                                document.getElementById('preload' + vVariantID).style.display = 'none';
                                document.getElementById('AddToCartButton_' + pProductID + '_' + vVariantID).style.display = 'inline';                                
                                alert("The selected product is Out of Stock.");
                                return false;
                            }
                            else if (s == "-,-") {
                                document.getElementById('preload' + vVariantID).style.display = 'none';
                                document.getElementById('AddToCartButton_' + pProductID + '_' + vVariantID).style.display = 'inline';                                
                                alert("Please select a Size");
                                return false;
                            }
                            //alert(s);
                        }

                        var pr = GetPRFrequency(pid,vid);

                        var page = "addtocart.aspx?Quantity=" + qty + "&ProductID=" + pid + "&VariantID=" + vid + "&Color=" + c + "&Size=" + s + "&pr=" + pr + "&ajax=1";
                        tsSendRequestAddToCart(page);
                        return false;                  
                    }

                    function tsCreateRequestObjectAddToCart()
                    {
                        var ro;
                        var browser = navigator.appName;
                        if(browser == "Microsoft Internet Explorer")
                        {
                            ro = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        else
                        {
                            ro = new XMLHttpRequest();
                        }
                        return ro;
                    }
                    
                    var httpAddToCart = tsCreateRequestObjectAddToCart();

                    function tsSendRequestAddToCart(action)
                    {
                        httpAddToCart.open('get', action);
                        httpAddToCart.onreadystatechange = handleResponseAddToCart;
                        httpAddToCart.send(null);
                    }
                    
                    
                    function handleResponseAddToCart()
                    {
                        //alert(httpAddToCart.readyState);
                        if (httpAddToCart.readyState == 4)
                        {
                            var resultDiv = document.getElementById('drop');
                            var res = httpAddToCart.responseText;
                            var q = res.substring(0,res.indexOf('|'));

                            if (parseInt(q) > 1) {
                                document.getElementById('ctl00_ltrNumCartItems').innerHTML = q + " Items";
                            }
                            else {
                                if (parseInt(q) == 1) {
                                    itemValue = 1;
                                }
                                document.getElementById('ctl00_ltrNumCartItems').innerHTML = q + " Item";
                            }
                            //alert("quantity=" + q);
                            res = res.substring(res.indexOf('|')+1);
                            resultDiv.innerHTML = res;
                            //alert('hi');
                            //document.getElementById('AddToCartButton_' + pProductID + '_' + vVariantID).style.display = 'inline';
                            document.getElementById('preload' + vVariantID).style.display = 'none';
                            document.getElementById('AddToCartButton_' + pProductID + '_' + vVariantID).style.display = 'inline';                            
                           // document.getElementById('preload'  + vVariantID).style.display ='none';
                            //alert(http.responseText);
                            //alert(resultDiv.innerHTML);
                            if(resultDiv.innerHTML.length > 9) {
                                
                                //resultDiv.style.display = 'none';
                                
                                //$(resultDiv).slideDown('slow');

                                //$(resultDiv).focus();
                                //Call this to initialize mouseover events when cart item changes from 0 to 1
                                //slideDrop();
                                slideDropVisible2();
                                resultDiv.style.display = '';
                                
                                
                                
                                
                                //alert("disp=" + resultDiv.style.display);
                                
                            }
                        }
                    }

                    

                  
