// a custom onComplete handler to prevent form submits for the demo
            function OnComplete()
            {
                //alert("The form validates! (normally, it would submit the form here).");
                //return false;
                return validateSearch(document.forms['frmSearch']);
            }


            $(document).ready(function() {


                jQuery(function($){
                    $("#whereSearch").Watermark("Type a location");
                    $("#what").Watermark("Type a keyword");

                    setupZoom();
                });

                /*
        $("#whereSearch").autocomplete("{/literal}{$baseUrl}autoCompleteWhere.php{literal}", {
                        width: 320,
                        highlight: false,
                        scroll: true,
                        scrollHeight: 300

                });

                 */

                $("#whereSearch").autocomplete(baseUrl+"autoCompleteWhat.php", {
                    width: 320,
                    highlight: false,
                    scroll: true,
                    scrollHeight: 300,
                    selectFirst: false,
                    extraParams: {field_selected: 'location' }
                });


                $("#what").autocomplete(baseUrl+"autoCompleteWhat.php", {
                    width: 320,
                    /*max: 3,*/
                    highlight: false,
                    scroll: true,
                    scrollHeight: 300,
                    selectFirst: false,
                    extraParams: {field_selected: function() { return $("input[name=field]:checked").val(); } }

                });



                //$("#session_flash_message").fadeOut(1000);

                var TEST_COOKIE = 'test_cookie';
                jQuery.cookie( TEST_COOKIE, true );
                if ( jQuery.cookie ( TEST_COOKIE ) )
                {
                    jQuery.cookie( TEST_COOKIE, null );
                    //alert( 'Good news, cookies are enabled.' );
                }
                else
                {
                    $('#notification_main').show('slow');
                    $('#notification_main_message').html("This site uses cookies. Your browser either doesn't support cookies or you have it turned off.");
                    // alert( 'Cookies are not enabled. Please enable and try again.' );
                    //window.location.href='error_cookie.php';

                }


                $(function(){
                    DD_roundies.addRule('div#session_flash_message','6px');
                    DD_roundies.addRule('div#session_flash_message_error','6px');

                    $("#websites1").msDropDown({useSprite:'sprite'});

                })


                $(".close").click(
                function () {
                    $(this).parent().fadeTo(400, 0, function () { // Links with the class "close" will close parent
                        $(this).slideUp(400);
                    });
                    return false;
                }
            );


                $("#frmSearch").RSV({
                    onCompleteHandler: OnComplete,
                    rules: [
                        "required,what,Please type your search keywords."
                    ]
                });


                $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
                $("ul.topnav li span").hover(function() { //When trigger is clicked...
                    //Following events are applied to the subnav itself (moving subnav up and down)
                    $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

                    $(this).parent().hover(function() {
                    }, function(){
                        $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
                    });

                    //Following events are applied to the trigger (Hover events for the trigger)
                }).hover(function() {
                    $(this).addClass("subhover"); //On hover over, add class "subhover"
                }, function(){	//On Hover Out
                    $(this).removeClass("subhover"); //On hover out, remove class "subhover"
                });

                $(".topnav li ul li a").each(function(){
                    var text = $(this).html();
                    $(this).html(text.replace(/ /g, "&nbsp;"));
                })



            });


            function clearAllWaterMarks(){
                $.Watermark.HideAll();
            }

            /*** Css hack for safari chrome ***/
            document.write("<style type='text/css'>")
            document.write("@media screen and (-webkit-min-device-pixel-ratio:0){");
            document.write(".dd{float: left;margin:  -3px 8px 0 0;}");
            document.write(".login{float: right;}}");
            document.write("</style>");

            /*******End css hack *****************/

            function changeSite(site){
                if(site=="")return false;
                var patt=/http:\/\//g;
                var result=patt.test(site);
                if(!result){
                    //  alert("http://"+site)
                    window.location.href = "http://"+site;
                }else{
                    window.location.href =  site;
                }
            }
