﻿/// <reference path="jquery-vsdoc.js" />

var selectorItems = new Array(
			{ textEl: 'catWebTxt', imgEl: 'catWebChk', type: 'web' },
			{ textEl: 'catImgTxt', imgEl: 'catImgChk', type: 'images' },
			{ textEl: 'catVidTxt', imgEl: 'catVidChk', type: 'videos' },
			{ textEl: 'catNewsTxt', imgEl: 'catNewsChk', type: 'news' },
			{ textEl: 'catAllTxt', imgEl: 'catAllChk', type: 'web+images+videos+news' });

var googleMap;

var GeoLocationService = {
    clientIpServiceSite: 'http://jsonip.appspot.com/',
    clientIp: null,
    PutUserGeolocation: function () {
        GeoLocationService.GetCurrentClientIp(function () {
            $.post('http://www.lavva.com/Services/LavvaService.ashx?meth=PUTUSERGEOLOCATION', { sessionId: 0, clientIp: GeoLocationService.clientIp }, null, "json");
        });

    },
    GetCurrentClientIp: function (onsuccess) {
        if (GeoLocationService.clientIp != null) {
            onsuccess();
            return;
        }
        if ($.browser.msie && window.XDomainRequest) {
            //cross-domain request
            var xdr = new window.XDomainRequest;
            if (xdr != null) {
                xdr.onload = function () {
                    var rawdata = xdr.responseText;
                    var jsonData = $.parseJSON(rawdata);
                    GeoLocationService.clientIp = jsonData.ip;
                    onsuccess();
                }
                xdr.open("get", GeoLocationService.clientIpServiceSite);
                xdr.send();
            }
        }
        else {
            $.get(GeoLocationService.clientIpServiceSite, null, function (result) {
                GeoLocationService.clientIp = result.ip;
                onsuccess();
            }, "json");
        }
    }
}

$(document).ready(function () {
//    if ($.browser.msie) {
//        var elm = $(".shadow");
//        var pos = $(elm).position();
//        elm.after("<div class='ie-shadow'></div>");
//        $(".ie-shadow").width($(elm).width() + 10).height($(elm).height()).css("left", (pos.left - 10) + "px").css("top", (pos.top + 1) + "px");
//    }
    $(".corner").corner("bottom");

    //    var queryType = getCookie('UserSearchQueryType');
    //    if (queryType !== undefined && queryType !== null && queryType !== '') {
    //        if (queryType.indexOf("web") != -1) {
    //            ChangeQueryType('hdQueryType', 'web');
    //        }
    //        if (queryType.indexOf("images") != -1) {
    //            ChangeQueryType('hdQueryType', 'images');
    //        }
    //        if (queryType.indexOf("videos") != -1) {
    //            ChangeQueryType('hdQueryType', 'videos');
    //        }
    //        if (queryType.indexOf("news") != -1) {
    //            ChangeQueryType('hdQueryType', 'news');
    //        }
    //    }
    setCookie('UserSearchQueryType','web');
    /*$('#tbQueryFirst').get(0).focus();*/
    $(".searchOptions li.searchCategory > a").focus(function () {
        $('#tbQueryFirst').get(0).focus();
        $(document).scrollTop(0);
    });

    setTimeout(LoadBGAjaxFull, 100);

    if (window.UserVoice)
        UserVoice.Popin.setup({
            key: 'lavva',
            host: 'lavva.uservoice.com',
            forum: 'general',
            lang: 'en'
        });

    try {
        var pageTracker = _gat._getTracker("UA-9099165-1");
        pageTracker._trackPageview();
    } catch (err) { }

    try {
        reinvigorate.track("bu44q-952o39458a");
    } catch (err) { }

    LavvaGeoMap.initialize();
    LavvaGeoMap.putCurrentRequestLocation();

    $('.tabChatFeed').click(function () {
        $('.tabRealtimeMap').removeClass('active');
        $('.tabChatFeed').addClass('active');
        $('#homeGS').show();
        $('#map_canvas').css("visibility", "hidden");

        $(".tabsWrapper").css({ "width": "75%", "margin": "0 auto" });
        $(".mainFrame").css({ "text-align": "center", " margin": "0 auto" });
    });

    $('.tabRealtimeMap').click(function () {
        $('.tabChatFeed').removeClass('active');
        $('.tabRealtimeMap').addClass('active');
        $('#homeGS').hide();
        $('#map_canvas').css("visibility", "visible");

        $(".tabsWrapper").css({ "width": "100%", "margin": "0" });
        $(".mainFrame").css({ "text-align": "none", " margin": "0" });
    });

    var host = "http://www.lavva.com/";

    $("a#home").click(function () { });
    $("a#profile").click(function () { window.location.href = host + "MyAccount.aspx"; });
    $("a#classifieds").click(function () { window.location.href = host + "Classifieds.aspx"; });
    $("a#gsmap").click(function () { window.location.href = host + "RealTimeMap.aspx"; });
    $("a#messages").click(function () { window.location.href = host + "MyAccounts.aspx"; });
    $("a#settings").click(function () { });
    $("a#logout").click(function () { });
});

function boldSuggs(sender, args) {
    var list = sender.get_completionList().children;
    var prefixRE = new RegExp(sender._currentPrefix, "g");
    var bold = "<b>" + sender._currentPrefix + "</b>";
    for (var i = 0; i < list.length; i++) {
        list[i].innerHTML = list[i].innerHTML.replace(prefixRE, bold);
    }
}

function showSuggs(sender) {
    var list = sender.get_completionList();
    var wrapper = $("#divSugg");
    wrapper.height($(list).height()).show();
    $(".acList").width(wrapper.width());
}

function hideSuggs(sender) {
    $("#divSugg").hide();
}

function selectSugg(sender, item) {
    sender.get_element().value = item.get_value();
}

function SaveQueryDataToCookie(controlId, key) {
    var query = $("#" + controlId).get(0).value;
    setCookie(key, query, null);
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate());
    document.cookie = c_name + "=" + escape(value) +
        ((expiredays == null) ? "; path=/" : ";expires=" + exdate.toGMTString() + +"; path=/");
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function MakeSearch(button, chatOn, queryInput) {
    var dstLnk = "#";
    var query = queryInput.value;
    var queryType = getCookie('UserSearchQueryType');
    if ((!query.trim && query != '') || (query.trim && query.trim() != '')) {
        if (chatOn) {
            queryType = (queryType == '') ? 'web' : queryType;

            dstLnk = window.location.protocol + "//" + window.location.hostname + "/GoSocial.aspx?q=" +
                 encodeURIComponent(query.trim ? query.trim() : query) + "&st=" + queryType;

        }
        else {
            queryType = (queryType == '') ? 'web' : queryType;
            var chatParam = (chatOn) ? "&chat=on" : '';
            dstLnk = window.location.protocol + "//" + window.location.hostname + "/GoSocial.aspx?q=" +
                encodeURIComponent(query.trim ? query.trim() : query) + "&st=" + queryType + chatParam;

        }
        window.location = dstLnk;
    }
    else {
        return false;
    }
}

function ChangeQueryType(hidFieldEl, qType) {
    var hidFieldObj = document.getElementById(hidFieldEl);

    var elIndex = -1;
    var checkAll = false;
    var switchToFalse = false;
    if (hidFieldObj != null) {
        if (qType.indexOf('+') >= 0)
            checkAll = true;
        var qTypeArr = (checkAll ? qType : hidFieldObj.value).split('+', 4);
        if (qTypeArr != null) {
            for (var i = 0; i < qTypeArr.length; ++i) {
                if (qType == qTypeArr[i])
                    elIndex = i;
            }
            if (elIndex < 0) {
                if (hidFieldObj.value.split('+', 4).length == 4) {
                    checkAll = switchToFalse = true;
                    qTypeArr = [];
                }
                else {
                    qTypeArr.push(qType);
                    if (qTypeArr.length == 4)
                        checkAll = true;
                }
            }
            hidFieldObj.value = ParseQueryTypeToUrlFormat(qTypeArr, elIndex);
            if (hidFieldObj.value == 'web+images+videos+news+web+images+videos+news') {
                hidFieldObj.value = 'web+images+videos+news';
            }
            setCookie('UserSearchQueryType', hidFieldObj.value, null);

        }
        for (var i = 0; i < selectorItems.length; ++i)
            if (checkAll)
            QueryTypeSynchronization(!switchToFalse, selectorItems[i]);
        else {
            if (selectorItems[i].type.indexOf('+') >= 0)
                QueryTypeSynchronization(false, selectorItems[i]);
            else if (qType == selectorItems[i].type)
                QueryTypeSynchronization(elIndex < 0, selectorItems[i]);
        }
    }
}

function QueryTypeSynchronization(enable, item) {
    var textObj = document.getElementById(item.textEl);
    var imgObj = document.getElementById(item.imgEl);

    if (enable) {
        if (imgObj)
            imgObj.checked = true;
        if (textObj) {
            textObj.className = "stCheckBoxA";
        }
    }
    else {
        if (imgObj)
            imgObj.checked = false;
        if (textObj) {
            textObj.className = "stCheckBox";
        }
    }
}

function SetQueryType(hidFieldEl, qType) {
    var hidFieldObj = document.getElementById(hidFieldEl);

    if (hidFieldObj)
        hidFieldObj.value = qType;

    for (var i = 0; i < selectorItems.length; ++i) {
        QueryTypeSynchronization(type == selectorItems[i].type, selectorItems[i]);
    }
}

function ParseQueryTypeToUrlFormat(qTypeArr, indexToDel) {
    if (qTypeArr.length > 0) {
        var strRes = "";
        for (var i = 0; i < qTypeArr.length; ++i) {
            if (i != indexToDel) {
                strRes += qTypeArr[i] + '+';
            }
        }
        if (strRes.charAt(strRes.length - 1) == '+')
            strRes = strRes.substr(0, strRes.length - 1);
        if (strRes.charAt(0) == '+')
            strRes = strRes.substr(1, strRes.length);
        return strRes;
    }

    return "";
}

function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g, "");
}

function MakeHomeSearch(chatOn, gosocial,fbc) {
    var dstLnk = "#";
    var query = document.getElementById('tbQueryFirst').value;
    var queryType = getCookie('UserSearchQueryType');
    if ((!query.trim && query != '') || (query.trim && (query = query.trim()) != '')) {
        queryType = (queryType == '') ? 'web' : queryType;
        dstLnk = gosocial ? (fbc ? "http://www.lavva.com/GoSocial.aspx?q=" + encodeURIComponent(query) + "&st=" + queryType + "&fbc=1" : "GoSocial.aspx?q=" + encodeURIComponent(query) + "&st=" + queryType) : (fbc ? "GoSocial.aspx?q=" + encodeURIComponent(query) + "&st=" + queryType + "&fbc=1" : "Search.aspx?q=" + encodeURIComponent(query) + "&st=" + queryType);
        window.location = dstLnk;
    }
    return false;
}

function fireMakeSearch(event) {
    if (event.keyCode == 13)
        return MakeHomeSearch(false, 1);
}

function validateForm() {
    var result = false;
    var query = document.getElementById('tbQueryFirst').value;
    var queryType = document.getElementById('hdQueryType').value;
    if (query && query.trim() != '') {
        var targetPage = 'GoSocial.aspx?q=';
        document.forms['aspnetForm'].action = targetPage + escape(query) + '&st=' + queryType;
        result = true;
    }
    return result;
}

function WebForm_OnSubmit(showChat) {
    var queryType = $("#hdQueryType").get(0).value;
    var query = SetFormAction('tbQueryFirst', 'hdQueryType', showChat);
    if (query != '') {
        document.forms['aspnetForm'].action = query;
        document.forms['aspnetForm'].submit();
    }
}

function SetFormAction(queryContainer, queryTypeContainer, showChat) {
    var query = document.getElementById(queryContainer).value;
    var queryType = document.getElementById(queryTypeContainer).value;
    if (query != '') {
        SaveQueryDataToCookie(queryContainer, 'UserSearchQuery');
        Sys.WebForms.PageRequestManager.getInstance()._postBackSettings = { async: false };
        var chatParam = '';
        var targetPage = '';
        if (showChat) {
            targetPage = 'GoSocial.aspx?q=';
        }
        else {
            targetPage = 'GoSocial.aspx?q=';
        }
        query = targetPage + escape(query) + '&st=' + queryType + chatParam;
    }
    return query;
}

function WebForm_FireDefaultButton(event, target) {
    var result = true;
    if (event.keyCode == 13) {
        var src = event.srcElement || event.target;
        if (!src || (src.tagName.toLowerCase() != "textarea")) {
            result = WebForm_OnSubmit(false);
        }
    }
    return result;
}

function LoadBGAjaxFull() {
    $("#divSugg").html("<div class='cbPointerIN2'></div><div class='ppWindow'><div class='ppCornerTL'></div><div class='ppCornerTR'></div><div class='ppTLine'></div><div class='ppLLine'></div><div class='ppRLine'></div><div class='ppBGContent'></div><div class='ppCornerBL'></div><div class='ppCornerBR'></div><div class='ppBLine'></div></div>");
    var ajaxsc = document.createElement("script");
    ajaxsc.src = 'http://js.lavva.com/AspNetAjax/AspNetAjaxFull.js';
    ajaxsc.type = "text/javascript";
    document.getElementsByTagName("head")[0].appendChild(ajaxsc);
    handleScriptLoading(ajaxsc, LoadBGAjaxAll);
}

function handleScriptLoading(script, callbackSuccess) {
    script.onload = script.onreadystatechange = function() {
        if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
            callbackSuccess();
            // Handle memory leak in IE
            script.onload = script.onreadystatechange = null;
            if (script.parentNode) {
                script.parentNode.removeChild(script);
            }
        }
    };
}

function InitApplication() {
    Sys.Application.initialize();
    Sys.Application.add_init(function() {
        $create(AjaxControlToolkit.AutoCompleteBehavior, {
            "completionListCssClass": "acList",
            "delimiterCharacters": "",
            "id": "aceQuery",
            "minimumPrefixLength": 1,
            "serviceMethod": "GetSuggestionList",
            "servicePath": "Services/Suggestions.asmx"
        },
        { "hidden": hideSuggs,
            "itemSelected": selectSugg,
            "populated": boldSuggs,
            "shown": showSuggs
        },
        null,
        $("#tbQueryFirst").get(0));
    });
}

function LoadBGAjaxAll() {
    if (!window.Sys || !Sys.WebForms || !Sys.WebForms.PageRequestManager) {
        setTimeout(LoadBGAjaxAll, 100);
        return;
    }
    Sys.WebForms.PageRequestManager._initialize('scriptManager', document.getElementById('aspnetForm'));
    Sys.WebForms.PageRequestManager.getInstance()._postBackControlClientIDs = new Array();
    Sys.WebForms.PageRequestManager.getInstance()._asyncPostBackControlClientIDs = new Array();
    Sys.WebForms.PageRequestManager.getInstance()._updatePanelClientIDs = new Array();
    var scriptLoader = Sys._ScriptLoader.getInstance();
    scriptLoader.queueScriptReference('http://js.lavva.com/AspNetAjax/Toolkit/AjaxControlToolkit.ExtenderBase.BaseScripts.js');
    scriptLoader.queueScriptReference('http://js.lavva.com/AspNetAjax/Toolkit/AjaxControlToolkit.Common.Common.js');
    scriptLoader.queueScriptReference('http://js.lavva.com/AspNetAjax/Toolkit/AjaxControlToolkit.Compat.Timer.Timer.js');
    scriptLoader.queueScriptReference('http://js.lavva.com/AspNetAjax/Toolkit/AjaxControlToolkit.PopupExtender.PopupBehavior.js');
    scriptLoader.queueScriptReference('http://js.lavva.com/AspNetAjax/Toolkit/AjaxControlToolkit.AutoComplete.AutoCompleteBehavior.js');
    scriptLoader.loadScripts(0, InitApplication, function() { }, function() { });
}

function getNewsRootCategories(withText) {

    url = "http://www.lavva.com/Services/LavvaService.ashx?meth=GETNEWSROOTCATEGORIES";
    $.get(url,
              (withText === true ? { withText: "true"} : { withText: "false" }),
              function (result) {
                  if (result && result != null && result != 'undefined')
                      $("#catList").html(result);
              },
              "html");
}
function setTab(index) {
    var src = '/GoSocialPanel/GSPanel.aspx?=' + $('.searchBoxBase').val() + '&GoSocial=1';
    switch (index) {
        case 1:
            $("#header").css('height', '355px');
            $("#catList").empty();
            if ($('#divWeb').is(':hidden')) { $('#divWeb').show(); }
            if ($('#divImg').is(':hidden')) { $('#divImg').show(); }
            if ($('#divVid').is(':hidden')) { $('#divVid').show(); }
            if ($('#divNews').is(':hidden')) { $('#divNews').show(); }
            if ($('#catList').is(':visible')) { $('#catList').hide(); }
            $('.activeTab').removeClass('activeTab').addClass('tab');
            $('#peopleTalkingTab').addClass('activeTab');
            src += '&p=' + index;
            if (src !== $('#homeGS').attr('src')) { $('#homeGS').attr('src', src); }
            break;
        case 2:
            $("#header").css('height', '355px');
            $("#catList").empty();
            if ($('#divWeb').is(':hidden')) { $('#divWeb').show(); }
            if ($('#divImg').is(':hidden')) { $('#divImg').show(); }
            if ($('#divVid').is(':hidden')) { $('#divVid').show(); }
            if ($('#divNews').is(':hidden')) { $('#divNews').show(); }
            if ($('#catList').is(':visible')) { $('#catList').hide(); }
            $('.activeTab').removeClass('activeTab').addClass('tab');
            $('#peopleSearchingTab').addClass('activeTab');
            $('#homeGS').attr('src', 'http://www.lavva.com');
            src += '&p=' + index;
            $('#homeGS').attr('src', src);
            break;
        case 4:
            
            if ($('#socialSection').is(':visible')) {
                $('#socialSection').hide();
            }
            $("#header").css('height', '385px');
            if ($('#divWeb').is(':visible')) { $('#divWeb').hide(); }
            if ($('#divImg').is(':visible')) { $('#divImg').hide(); }
            if ($('#divVid').is(':visible')) { $('#divVid').hide(); }
            if ($('#divNews').is(':visible')) { $('#divNews').hide(); }
            if ($('#catList').is(':hidden')) { $('#catList').show(); }
            $('.activeTab').removeClass('activeTab').addClass('tab');
            $('#latestNewsTab').addClass('activeTab');
            getNewsRootCategories(true);  
            src += '&p=' + index;
            if (src !== $('#homeGS').attr('src')) { $('#homeGS').attr('src', src); }
            break;
        case 5:
            $("#header").css('height', '355px');
            $("#catList").empty();
            if ($('#divWeb').is(':hidden')) { $('#divWeb').show(); }
            if ($('#divImg').is(':hidden')) { $('#divImg').show(); }
            if ($('#divVid').is(':hidden')) { $('#divVid').show(); }
            if ($('#divNews').is(':hidden')) { $('#divNews').show(); }
            if ($('#catList').is(':visible')) { $('#catList').hide(); }
            $('.activeTab').removeClass('activeTab').addClass('tab');
            $('#peopleTab').addClass('activeTab');
            src += '&p=' + index;
            $('#homeGS').attr('src', src);
            break;
        case 10:
            $("#header").css('height', '355px');
            $("#catList").empty();
            if ($('#divWeb').is(':hidden')) { $('#divWeb').show(); }
            if ($('#divImg').is(':hidden')) { $('#divImg').show(); }
            if ($('#divVid').is(':hidden')) { $('#divVid').show(); }
            if ($('#divNews').is(':hidden')) { $('#divNews').show(); }
            if ($('#catList').is(':visible')) { $('#catList').hide(); }
            $('.activeTab').removeClass('activeTab').addClass('tab');
            $('#mapsTab').addClass('activeTab');
            src += '&p=' + index;
            $('#homeGS').attr('src', src);
            break;
        default:
            break;
    }
}

function setCurrentCategory(catIndex) {
    var elementName = '#newsCategory' + catIndex;
    var lElementName = '#newsCat' + catIndex;
    $('.newsCategory').removeClass('activeNewsCategoryTab');
    $('.newsCat').removeClass('activeNewsTab');
    $(lElementName).addClass('activeNewsTab');
    $(elementName).addClass('activeNewsCategoryTab');
    window.parent.$('#homeGS')[0].contentWindow.setCurrentCategory(catIndex);
}
function goRegistrationOrAccount() {
var url = "http://www.lavva.com/Services/LavvaService.ashx?meth=CHECKUSERLVLOGIN";
$.get(url, function (data) {
    if (data === "true") {
        window.location.href = "http://www.lavva.com/MyAccount.aspx";
    }
    else {
        window.location.href = "http://www.lavva.com/Login.aspx";
    }
});

}
function showBigAd() {
    var height = $(document).height();
    var iPrepend = "<div id=\"bigGlowAd\"><div id=\"bigGlowAdCloseButton\"></div><div id=\"bigGreen\"></div></div><div class=\"divBigForAd\" style=\"min-height:" + height + "px !important;\"></div>";
    $('#content').prepend(iPrepend);
    $('#bigGlowAdCloseButton').click(hideBigAd);
}
function hideBigAd() {
    $('#bigGlowAd').remove();
    $('.divBigForAd').remove();
}
function goMakeHomeSearch() {
	var anyValue = document.getElementById('tbQueryFirst').value;
	if (anyValue != '') {
		MakeHomeSearch(false, 1, 1);
	}
}
$(document).ready(function () {
    $('#gsPeel').click(showBigAd);
    $(document).click(function (event) {
        if ($(event.target).attr('id') === 'bigGlowAd') {
            hideBigAd();
            $('#homeGS').contents().find('#ucLogin_lnkFBLogin').click();
        }
        if ($(event.target).attr('id') === 'bigGreen') {
            window.location.href = "http://www.lavva.com/Info.aspx?p=11";
        }
    });
    $('#divGames').click(function () {
        window.location.href = 'http://www.lavva.com/games';
    });
    $('#gsMyAccount').click(goRegistrationOrAccount);
    var gsPeopleTalkingTab = "<li class=\"gsTab\" style=\"width: 20%;\"><a href=\"#\" id=\"peopleTalkingTab\" class=\"tab\" onclick=\"setTab(1);\"><div class=\"inlineEl gsTabContent\"><span>People&nbsp;Talking</span><span class=\"linkSeparator\"></span></div></a></li>";
    var gsPeopleSearchingTab = "<li class=\"gsTab\" style=\"width: 20%;\"><a href=\"#\" id=\"peopleSearchingTab\" class=\"tab\" onclick=\"setTab(2);\"><div class=\"inlineEl gsTabContent\"><span>People&nbsp;Searching</span><span class=\"linkSeparator\"></span></div></a></li>";
    var gsPeopleTab = "<li class=\"gsTab\" style=\"width: 20%;\"><a href=\"#\" id=\"peopleTab\" class=\"tab\" onclick=\"setTab(5);\"><div class=\"inlineEl gsTabContent\"><span>People</span><span class=\"linkSeparator\"></span></div></a></li>";
    var gsLatestNewsTab = "<li class=\"gsTab\" style=\"width: 20%;\"><a href=\"#\" id=\"latestNewsTab\" class=\"activeTab\" onclick=\"setTab(4);\"><div class=\"inlineEl gsTabContent\"><span>Latest&nbsp;News</span><span class=\"linkSeparator\"></span></div></a></li>";
    var gsMapTab = "<li class=\"gsTab\" style=\"width: 20%;\"><a href=\"#\" id=\"mapsTab\" class=\"tab\" onclick=\"setTab(10);\"><div class=\"inlineEl gsTabContent\"><span>Map</span></div></a></li>";
    var htmlString = "<ul>" + gsLatestNewsTab + gsPeopleTalkingTab + gsPeopleSearchingTab + gsPeopleTab + gsMapTab + "</ul>";
    $('#tWrapper').html(htmlString);
    getNewsRootCategories(true);

    $('#tbQueryFirst').focus();
    $('#fbButton').click(function () {
        /*$('#homeGS').contents().find('#ucLogin_lnkFBLogin').click();*/
        var d = document;
        var f = d.frames ? d.frames['homeGS'] : d.getElementById('homeGS');
        var p = f.document || f.contentWindow.document;
        var iButton = p.getElementById('ucLogin_lnkFBLogin');
        window.frames.homeGS.changeFBonclick();
		$(iButton).click();
    });
});
