﻿// JScript File

    function AddBookmark(title) {
    if (document.all)
        window.external.AddFavorite(this.location,title);
    else
        window.sidebar.addPanel(title, this.location, "");
    }
    
    function CheckIn(el, id) {
        if (!User.IsAuthenticated) {
            LoginRequired(el, 'You must be logged in to user our location features.');
            return;
        }
        var url = '/services/checkin.ashx?id=' + id;
            $.get(url,
              null,
               CheckInPostBack
             );
    }
    function CheckInPostBack(result) {
        alert(result);
    }
    
    function SetRating(obj, text, establishmentId, rating) {
        if (!User.IsAuthenticated) {
            LoginRequired(obj, text);
            return;
        }
        
        $.get('/RateEstablishment?establishmentid=' + establishmentId + '&rating=' + rating, null, null);
        
    }
    function AddToMyFavorites(obj,text) {
        if (!User.IsAuthenticated) {
                LoginRequired(obj,text);
            }
    }
    function SendToFriend() {
    
    }

    function LoginRequired(obj, title) {
         var win = new PopupWindow('bubble'); 
        win.autoHide(); 
        var el = document.getElementById('bubble');
        
        el.style.left = (5+ findPosX(obj)) + 'px';
        el.style.top = (findPosY(obj) + getElementHeight(obj)) + 'px';
        
        
        var txt = document.getElementById('bubbletext');
        txt.innerHTML=title;
        el.style.display = 'block';
        
        
        //AttachFloater(el);
    }
    
    function DebugCallBack(text) {
        alert(text);
    }
    
    function SendToPhone() {
        var num = document.getElementById('phonenumber');
        
        $.get('/Services/SendToPhone.ashx?phone=' + num.value + '&id=' + establishmentId ,null, DebugCallBack);
        HideSendToPhone();
    }
    function PrintPage() {
        window.print();
    }
    
    function ShowSendToPhone(obj) {
    
    var win = new PopupWindow('sendtophone'); 
    win.autoHide(); 
     var ctrl = document.getElementById('sendtophone');
        ctrl.style.left = (5+getElementWidth(obj) + findPosX(obj)) + 'px';
        ctrl.style.top = (findPosY(obj)) + 'px';
        ctrl.style.display = 'block';
    }
    function HideSendToPhone() {
        var ctrl = document.getElementById('sendtophone');
        ctrl.style.display = 'none';
    }
        