﻿
        function showUsRegulation() {
            $('.regulations:not(#us_export)').css('display', 'none');
            $('#us_export').css("display", "block");
        }
         
        function showUKRegulation() {
            $('.regulations:not(#uk_regulations)').css('display','none');

            $('#uk_regulations').css("display", "block");
        }
        function viewInvoice(invoice) {
            window.open("InvoiceView.aspx?Invoice=" + invoice + "");

        }
        //Function that aligns numbers @ decimals
        function formatDecimals() {
          
            $('.aBDP').each(function() {
                var wholePart, fractionPart;
                wholePart = Math.floor($(this).text() - 0);
                //var dec = $(this).text().s
                fractionPart = Math.floor(($(this).text() % 1) * 10000 + 0.5) / 10000 + "";

                var value = $(this).text();
                var dec = value.indexOf(".") + 1;
                var decval = value.substr(dec, 2);
                html = '<span class="left">' + wholePart + '.' + '</span>';

                html += '<span class="right">' + decval + '</span>';
                $(this).html(html);
            });
            //alert("format");
        }
        function preloader() {
            var images = ['Image/CategoryImage/Beauty.jpg', 'Image/CategoryImage/Bed.jpg', 'Image/CategoryImage/camera.jpg', 'Image/Worldshop.gif', 'Image/CategoryImage/Handbags.jpg', 'Image/CategoryImage/Sunglasses,jpg',
'Image/CategoryImage/Tools.jpg', 'Image/CategoryImage/SportsEquipment.jpg', 'Image/CategoryImage/Luggage.jpg', 'Image/CategoryImage/vaccum.jpg', 'Image/CategoryImage/NintendoWii.jpg', 'Image/CategoryImage/Laptop.jpg', 'Image/CategoryImage/Shoes.jpg',
'Image/CategoryImage/Jewelery.jpg', 'Image/CategoryImage/Games.jpg', 'Image/CategoryImage/Furniture.jpg', 'Image/CategoryImage/Toy.jpg', 'Image/CategoryImage/Mens.jpg', 'Image/CategoryImage/Children.jpg', 'Image/CategoryImage/DVDS.JPG', 'Image/menu_bg1.gif', 'Image/next-horizontal.png', 'Image/prev-horizontal.png', 'Image/worldshop.jpg', 'Image/view_demo.jpg', 'Image/myaccountNew.png',
'Image/menuBG_orange.gif', 'Image/prohibited2.jpg', 'Boat.jpg', 'Movies.jpg', 'Baby.jpg', 'services.jpg', 'MensDept.jpg', 'Image/step1.jpg', 'Image/step2.jpg', 'Image/step3.jpg', 'Image/step4.jpg'];

            $.each(images, function(i) {
                images[i] = new Image();
                images[i].src = this;
               
            });
        }

        //Checks if the country session if blank no country selected get country by ip
        function SelectCountry() {
            var country = $(".userCountry").val();
            $.ajax({

                type: "POST",
                url: "wsutils.asmx/getCountry",
                dataType: "html",
                async: false,
                success: function(msg) {
                    // alert(msg.toString().length);
                    if (msg.toString().length < 1) {

                        checkCountry();
                    }
                    else if (msg.toString() == "IL") {

                        $(".renewal").hide();
                        $(".atracking").attr('href', 'http://www.tnt.com/webtracker/tracker.do?navigation=1&respLang=iw&respCountry=il');
                    }


                }

            });
        }
        function checkCountry() {
           // alert(sGeobytesInternet);
            //var country = "IL";
            var country = sGeobytesInternet;
            if (sGeobytesLocationCode == "unknown") {

            }
            else {
                //alert(country);
                if (country != "US") {
            
                    $.ajax({
                        type: "POST",
                        url: "wsutils.asmx/UpdateSession",
                        data: "country=" + country + "",
                        success: function() {
                            //alert("sucess");
                        }


                    });

                    $(".imgFlag").attr('src', "Image/img_" + country + ".gif")
                    $(".imgFlag").show();

                    $(".userCountry").val("" + country + "")
                    if (country == "IL") {
                        $(".renewal").hide();
                       $(".atracking").attr('href','http://www.tnt.com/webtracker/tracker.do?navigation=1&respLang=iw&respCountry=il');
                    }
                    if (country == "BH") {
                        $(".pnBH").show();
                    }
                    else {
                        $(".pnBH").hide();
                        $(".pnDefault").show();

                    }
                }
               
                /*  
                $.post("wsutils.asmx/UpdateSession", data:"{ country: BH }",
                function(data) {
                alert("Data Loaded: " + data);
                });*/

                // alert(sGeobytesInternet);
            }
        }

        $(document).ready(function() {

            /*
            if ($(".countryChange").val() == "N") {

                checkCountry();
            }
            */

           // SelectCountry();
        $(function() {
            $("input.numeric").bind('keyup blur', function() {

                if (this.value.match(/[^\d+(?:\.\d{0,2})]/g)) {
                    this.value = this.value.replace(/[^\d+(?:\.\d{0,2})]/g, '');
                }

            });
        });


            $(".widget_style").jCarouselLite({
                btnPrev: ".widget .prev",
                btnNext: ".widget .next",
                scroll: 4.5,
                visible: 4,
                auto: 500,
                speed: 20000,
                mouseWheel: true,
                hoverPause: true,
                circular: true
            });
            $("#bisb").click(function() {
                window.location = "Avertise.aspx";
            });


            $(".registerlink").click(function() {

                //alert("register click");
                if ($(".userCountry").val() != "") {
                    window.location = "RegisterAccount.aspx";
                }
                else {
                    alert("Please select your country at the top before you can begin registration");
                }
            });
            formatDecimals();

            $(".video_demo a[rel^='prettyPhoto']").prettyPhoto({ theme: 'light_rounded' });

            $.tools.addTipEffect("slidedown",

            // opening animation
        	function() {
        	    var opacity = this.getConf().opacity;
        	    this.getTip().css({ opacity: 0 }).animate({ opacity: opacity }, 300).show();
        	},

            // closing animation
        	function() {
        	    this.getTip().animate({ top: '+=5', opacity: 0 }, 300, function() {
        	        $(this).hide().animate({ top: '+=10' }, 0);
        	    });
        	}
        );

            $("#rate_value").tooltip({ effect: 'slidedown', position: ['top', 'right'], offset: [30, -35] });

            var IE7_PNG_SUFFIX = ".png";
        });
      

