var lp_root='www.linkpolonia.com';
var pageLoadTime=new Date();
function $(id){return document.getElementById(id);}
function $onLoad(f) { var x = window.onload; if (typeof (x) != 'function') { window.onload = f; } else { window.onload = function() { if (x) { x(); } f(); }; } }
function $addClick(f) { var x = window.onclick; if (typeof (x) != 'function') { window.onclick = f; } else { window.onclick = function() { if (x) { x(); } f(); }; } }
function $addScroll(f) { var x = window.onscroll; if (typeof (x) != 'function') { window.onscroll = f; } else { window.onscroll = function() { if (x) { x(); } f(); }; } }
function $init(r) { lp_root = r; }
function $el(tag) { var e = document.createElement(tag); return e; }
function $txt(data) { var e = document.createTextNode(data); return e; }
function $getXmlHttpRequest() {
    var xmlHttp;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e2) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e3) {
                return false;
            }
        }
    }
    return xmlHttp;
}
function $ajax(url, callback) {
    var xmlHttp = $getXmlHttpRequest();
    if (xmlHttp && callback) {
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                callback(xmlHttp);
            }
        };
    }
    xmlHttp.open('GET', url, true);
    xmlHttp.send(null);
}
function $eachChild(parent, callback) {
    var children = parent.childNodes;
    for (var c = 0; c < children.length; c++) {
        callback(children[c]);
    }
}

function constrainTextLength(sourceId, reportId, textLength) { var sourceElement = document.getElementById(sourceId); if (sourceElement) { var reportElement = document.getElementById(reportId); if (reportElement) { if (sourceElement.value.length > textLength) { sourceElement.value = sourceElement.value.substring(0, textLength);}
if (sourceElement.value.length > textLength - 1) { reportElement.className = "ErrorMessage";}
else { reportElement.className = "";}
reportElement.innerHTML = sourceElement.value.length + '/' + textLength;}
}
}
function endsWith(sourceString, stringEnd) { var regex = new RegExp(stringEnd + '$'); return regex.test(sourceString);}

function ValidateImageFile(inputBoxName, errorDisplayName, errorMessage)
{ var inputBox = document.getElementById(inputBoxName); var errorDisplay = document.getElementById(errorDisplayName); var valid = false; if (inputBox && errorDisplay)
{ var re = new RegExp("^.*\.([gG][iI][fF]|[jJ][pP][eE]?[gG]|[pP][nN][gG])$"); if (re.test(inputBox.value))
{ valid = true; errorDisplay.innerHTML = '';}
else
{ valid = false; errorDisplay.innerHTML = errorMessage;}
}
return valid;}
function ValidateNonEmpty(inputBoxName, errorDisplayName, errorMessage)
{ var inputBox = document.getElementById(inputBoxName); var errorDisplay = document.getElementById(errorDisplayName); var valid = false; if (inputBox && errorDisplay)
{ if (inputBox.value != '')
{ valid = true; errorDisplay.innerHTML = '';}
else
{ valid = false; errorDisplay.innerHTML = errorMessage;}
}
return valid;}
function SwitchPictures(imgID, thumbID) {
    var img = $(imgID);
    var thumb = $(thumbID);
    if (img && thumb) {
        $eachChild(thumb.parentNode.parentNode, setHorizThumbClass);
        var temp = thumb.src.replace('90x90', '250x250');
        img.src = temp;
        thumb.parentNode.className = 'PhotoSelected';
    }
    return false;
}
function SwitchPictures2(imgID, thumbID, detailID, detailID2) {
    var img = $(imgID);
    var thumb = $(thumbID);
    var detail = $(detailID);
    var detail2 = $(detailID2);
    if (img && thumb) {
        $eachChild(thumb.parentNode.parentNode, setHorizThumbClass);
        var temp = thumb.src.replace('90x90', '250x250');
        img.src = temp;
        thumb.parentNode.className = 'PhotoSelected';
    }
    if (detail && detail2) {
        detail.innerHTML = detail2.innerHTML;
    }
    return false;
}
function clearClass(i) { if (i && i.className) { i.className = ''; } }
function setHorizThumbClass(i) { if (i && i.className) { i.className = 'HorizontalThumb'; } };
function ToggleLoggedInPopup(newStyle) { document.getElementById('MustBeLoggedIn').style.display = newStyle; document.getElementById('MustBeLoggedInBG').style.display = newStyle; return false;}
function NoUrlsOrEmails(sID, out) { var str = document.getElementById(sID).value; var re = new RegExp(/.*(http|www|([\w]{2,50}@[\w]{2,50})).*/); if (str.match(re)) { document.getElementById(out).style.display = ''; return false;}
else { document.getElementById(out).style.display = 'none'; return true;}
}


var backgroundID = "";
var popupID = "";
var shadowRightID = '';
var shadowBottomID = '';
function clearPopup() { backgroundID = ''; popupID = ''; }

function HandlePopupNew(bgID, pID, maxHeight, maxWidth) {
    //first we set two global vars so the onscroll function will work
    backgroundID = bgID;
    popupID = pID;
    shadowRightID = 'popupShadowRight';
    shadowBottomID = 'popupShadowBottom';

    //now we initialize and bind the scroll function. (otherwise it would
    //only show up when bound)
    HandleScroll();
    $addScroll(HandleScroll);

    //if we dont have a specified maxWidth, set it to the width of the currently visible window
    if (maxWidth == null) {
        maxWidth = document.documentElement.clientWidth;
    }

    //the biggest we want the popup to be is 70 pixels less then the size of the window.
    var popupHeight = Math.min(maxHeight, document.documentElement.clientHeight - 70);
    var popupWidth = Math.min(maxWidth, document.documentElement.clientWidth - 70);

    
    //now, resize, and then recenter the popup. lastly it might not be visible, so make sure it is.
    var popup = $(popupID);
    if (popup != null) {
        popup.style.height = popupHeight + 'px';
        popup.style.marginTop = -0.5 * popupHeight + 'px';
        popup.style.width = popupWidth + 'px';
        popup.style.marginLeft = -0.5 * popupWidth + 'px';
        popup.style.display = '';
    }

    var shadowR = $(shadowRightID);
    if (shadowR != null) {
        shadowR.style.height = (popupHeight) + 'px';
        shadowR.style.marginTop = -0.5 * popupHeight + 'px';
        shadowR.style.marginLeft = 0.5 * popupWidth + 'px';
        shadowR.style.display = '';
    }

    var shadowB = $(shadowBottomID);
    if (shadowB != null) {
        shadowB.style.width = (popupWidth + 20) + 'px';
        shadowB.style.marginTop = 0.5 * popupHeight + 'px';
        shadowB.style.marginLeft = -0.5 * popupWidth + 'px';
        shadowB.style.display = '';
    }

    //similarly, the background might be hidden, so let's show that for sure too.
    var background = $(backgroundID);
    if (background != null) {
        background.style.display = '';
    }
    
}

function HandleScroll() {
    if (backgroundID != "" && popupID != "") {
        //how far down do we move things?
        var offset = (document.documentElement.clientHeight * 0.5) + document.documentElement.scrollTop;

        //move the background down
        var background = $(backgroundID);
        if (background != null) {
            background.style.top = document.documentElement.scrollTop + "px";
        }
        //move the popup down
        var popup = $(popupID);
        if (popup != null) {
            popup.style.top = offset + "px";
        }

        var shadowR = $(shadowRightID);
        if (shadowR != null) {
            shadowR.style.top = offset + "px";
        }
        var shadowB = $(shadowBottomID);
        if (shadowB != null) {
            shadowB.style.top = offset + "px";
        }
    }
}
var lastPost = '';
function $preventDuplicate(id,t) {
    var c = $(id);
    var b = false;
    if (c) {
        if (c.value != '' && c.value != lastPost) {
            b = true;
            lastPost = c.value;
        }
        else if (c.value != '') {
            alert(t);
        }
        else {
            b = true; // Pass on to validation.
        }
    }
    return b;
}

var PostID = -1;
var vanish = 5000; // ms
var pID = 'LatestPostPopup';
var pbID = 'LatestPostBody';
var piID = 'PostImg';
var ppID = 'LatestPostProile';
var ptID = 'LatestThread';
var pfID = 'LatestForum';
var pfsID = 'fSpan';
var stopGetPostTime = 30 * 60 * 1000; // 30m * 60s/m * 1000ms/s.
function getPost() {
    var now = new Date();
    if ((now - pageLoadTime) < stopGetPostTime) {
        url = lp_root + '/GetPost.axd?p=' + PostID;
        $ajax(url, processPost);
    }
}
function processPost(result) {
    var pBody=$(pbID);
    var pImg=$(piID);
    var pProf=$(ppID);
    var pThread=$(ptID);
    var pForum=$(pfID);
    var pfSpan=$(pfsID);
    if(result){
        var res = eval('('+result.responseText+')');
        if (res){
            if(pBody){pBody.innerHTML=res.PostBody;}
            if(pImg){pImg.src=res.PostImg;}
            if(pProf){pProf.href=res.PostProfile;pProf.innerHTML=res.Poster;}
            if(pForum && pfSpan){
                if (res.ForumLink!=''){
                    pForum.href=res.ForumLink;
                    pForum.innerHTML=res.ForumName;
                    pfSpan.style.display='inline';
                }
                else{
                    pfSpan.style.display='none';
                }
            }
            if (pThread) { pThread.href = res.ThreadLink; pThread.innerHTML = res.ThreadName; }
            PostID = res.PostID;
            showLatestPost(pID);
        }
    }
}
// Animation.
function showLatestPost(id) {
    var animator = new Animator(id);
    animator.add(new Animation(200).show().bottom(700, 600).left(10, 50).opacity(0, 100).width(110, 680));
    animator.start()
    setTimeout('hideLatestPost(\'' + id + '\')', vanish);
}
function hideLatestPost(id) {
    var animator = new Animator(id);
    animator.add(new Animation(200).hide().bottom(600, 10).left(50, 10).opacity(100, 0).width(680, 110));
    animator.start()    
}
function hideLatestPostCallback(id) {
    var animator = new Animator('PostDockArrow');
    ajaxPager('PostBrowser', 'Forums', '1', '6', 'PostDockContent', '');
    animator.add(new Animation(100).color(17, 200, 51, 200, 153, 51));
    animator.add(new Animation(100).color(200, 17, 200, 17, 51, 153));
    animator.add(new Animation(100).color(17, 200, 51, 200, 153, 51));
    animator.add(new Animation(100).color(200, 17, 200, 17, 51, 153));
    animator.add(new Animation(100).color(17, 200, 51, 200, 153, 51));
    animator.add(new Animation(100).color(200, 17, 200, 17, 51, 153));
    animator.start();
}
function setDisplay(id,d){var e=$(id);if(e){e.style.display=d;}}
function hide(id){setDisplay(id,'none');}
function unhide(id) { setDisplay(id, 'block'); }
function chkCount(boxID, countID) {
    var box = document.getElementById(boxID);
    var count = document.getElementById(countID);
    var n = parseInt(count.innerHTML);
    if (box.checked) {
        count.innerHTML = n + 1;
    }
    else {
        count.innerHTML = n - 1;
    }
}
var oldHeader = '';
var oldContents = '';
function InitPanel(oH, oC) {
    oldHeader = oH;
    oldContents = oC;
}
function SwitchPanel(newHeader, newContents) {
    var oH = document.getElementById(oldHeader);
    if (oH != null) {
        oH.className = 'accordionHeader';
    }
    
    var nH = document.getElementById(newHeader);
    if (nH != null) {
        nH.className = 'accordionHeaderSelected';
    }

    var oC = document.getElementById(oldContents);
    if (oC != null) {
        oC.style.display = 'none';
    }

    var nC = document.getElementById(newContents);
    if (nC != null) {
        nC.style.display = '';
    }
    
    oldHeader = newHeader;
    oldContents = newContents;
}
function IsValidName(oSrc, args) {
    var n = args.Value.toLowerCase();
    var v = true;
    var a, b, c;
    var i = 0;
    if (n.length > 2) {
        for (i = 2; i < n.length; i++) {
            a = n.substring(i, i + 1);
            b = n.substring(i - 1, i);
            c = n.substring(i - 2, i - 1);
            if (a == b && a == c) {
                v = false;
                break;
            }
        }
    }
    if (v) {
        v = (n.indexOf('>') == -1) && (n.indexOf('<') == -1);
    }
    args.IsValid = v;
}
//OBSOLETE... should be killed as soon as possible
function HandlePopup(bgID, pID, maxHeight, maxWidth) {
    //first we set two global vars so the onscroll function will work
    backgroundID = bgID;
    popupID = pID;

    //now we initialize and bind the scroll function. (otherwise it would
    //only show up when bound)
    HandleScroll();
    $addScroll(HandleScroll);

    //if we dont have a specified maxWidth, set it to the width of the currently visible window
    if (maxWidth == null) {
        maxWidth = document.documentElement.clientWidth;
    }

    //the biggest we want the popup to be is 20 pixels less then the size of the window.
    var popupHeight = Math.min(maxHeight, document.documentElement.clientHeight - 20);
    var popupWidth = Math.min(maxWidth, document.documentElement.clientWidth - 20);

    //now, resize, and then recenter the popup. lastly it might not be visible, so make sure it is.
    var popup = $(popupID);
    if (popup != null) {
        popup.style.height = popupHeight + 'px';
        popup.style.marginTop = -0.5 * popupHeight + 'px';
        // popup.style.width = popupWidth + 'px';
        // popup.style.marginLeft = -0.5 * popupWidth + 'px';
        popup.style.display = '';
    }
    //similarly, the background might be hidden, so let's show that for sure too.
    var background = $(backgroundID);
    if (background != null) {
        background.style.display = '';
    }
}

function ShowPopupInFrame(fdiv, fid, src, height, width) {


    HandlePopupNew('PopupBackground', fdiv, height, width);

    //the biggest we want the popup to be is 20 pixels less then the size of the window.
    height = Math.min(height, document.documentElement.clientHeight - 70);
    width = Math.min(width, document.documentElement.clientWidth - 70);

    
    var iframeContainer = $(fdiv);
    iframeContainer.style.width = width + 'px';
    iframeContainer.style.marginLeft = (-0.5 * width) + 'px';
    iframeContainer.style.height = height + 'px';
    iframeContainer.style.marginTop = (-0.5 * height) + 'px';
    var iframe = $(fid);
    iframe.style.width = width + 'px';
    iframe.style.height = height + 'px';

   
    showFrame(fid, src);
}
function hideFramePopup(fdiv,fid){
    hideFrame(fid);
    hide(fdiv);
    hide(backgroundID);
    hide(shadowBottomID);
    hide(shadowRightID);
    clearPopup();
}
function showFrame(fid,src){
    var f= $(fid);
    if(f){
        f.style.display='block';
        f.src=src;
    }
}
function hideFrame(fid){
    var f=$(fid);
    if(f){
        f.src = '';
        while (f.hasChildNodes()) {
            f.removeChild(f.firstChild);
        }
        f.style.display='none';
    }
}
function setupWizardWait(cmdID) {
    var cmd = $(cmdID);
    if (cmd) {
        cleaned = cmd.href.replace('javascript:', '');
        cleaned = cleaned.replace(/%20/g, ' ');
        cmd.href = 'javascript:' + cleaned + ';if(typeof(Page_IsValid)=="undefined" || Page_IsValid){wizardWait("' + cmdID + '");clearHref("' + cmdID + '");}';
    }
}
function wizardWait(cmdID) {
    var wait = $('wizWait');
    if (wait) { wait.style.display = 'block'; }
}
function clearHref(cmdID) { 
    var cmd = $(cmdID);
    if (cmd) { cmd.removeAttribute('href'); }
}
function popupMemberImage(link) {
    if (link && link.parentNode && link.parentNode.parentNode) {
        var container = link.parentNode.parentNode;
        container.style.zIndex = '100';
        if (container.lastChild.className != 'MemberImageCloseUp') {
            var bg = $el('div');
            bg.className = 'MemberImageCloseUp';

            var t = $el('table');
            t.style.width = '100%';
            t.style.height = '100%';
            var tbody = $el('tbody');
            var tr = $el('tr');
            var td = $el('td');
            td.align = 'center';
            td.valign = 'middle';

            var big = $el('img');
            big.src = link.firstChild.src.replace(/thumbnail\./i, 'Profile.');

            td.appendChild(big);
            tr.appendChild(td);
            tbody.appendChild(tr);
            t.appendChild(tbody);
            bg.appendChild(t);

            container.appendChild(bg);
        }
        else {
            container.lastChild.style.display = 'block';
        }
    }
}
function hideMemberImage(link) {
    if (link && link.parentNode && link.parentNode.parentNode) {
        var container = link.parentNode.parentNode;
        container.style.zIndex = '0';
        if (container.lastChild.className == 'MemberImageCloseUp') {
            container.lastChild.style.display = 'none';
        }
    }
}
function notify(m) {
    var i = 'clientNotify';
    var d = $(i);
    if (d) {
        d.innerHTML = m;
        unhide(i);
    }
}
// Enhanced drop down.
var hideSuppressed = false;
var g_optionsId;
var g_textId;
var g_valueId;
var g_timer;
var g_options = [];
if(window.captureEvents){window.onclick=hideOptions;}else{document.onclick=hideOptions;}
function ddRegisterDropDown(optionsId) {
    g_options.push(optionsId);
}
function suppressHide(b) {
    hideSuppressed = b;
}
function showOptions(optionsId, textId) {
    var options = $(optionsId);
    if (options) {
        var original = options.style.display;
        _hideOptions();
        if(original != 'block'){
            g_optionsId = optionsId;
            options.style.width = options.parentNode.offsetWidth + "px";
            options.style.display = "block";
        }
    }
    else {
        _hideOptions();
    }
}
function _hideOptions() {
    for (var i = 0; i < g_options.length; i++) {
        var options = $(g_options[i]);
        if (options) {
            options.style.display = "none";
        }
    }
}
function hideOptions() {
    if (!hideSuppressed) {
        _hideOptions();
    }   
}
function setItem(optionsId, textId, valueId, text, value) {
    var textBox = $(textId);
    var valueBox = $(valueId);
    if (textBox && valueBox) {
        textBox.innerHTML = text;
        valueBox.value = value;
    }
}
function ddShowLoading(optionsId) {
    var options = $(optionsId);
    if (options) {
        var img = $el('img');
        img.src = lp_root + '/images/loading2.gif';
        options.appendChild(img);
    }
}


function ddHideLoading(optionsId) {
    var options = $(optionsId);
    if (options && options.childNodes && options.childNodes[0]) {
        options.removeChild(options.childNodes[0]);
    }
}
function dropdownAddCountry(optionsId, textId, valueId, data) {
    var options = $(optionsId);
    if (options && options.childNodes.length == 0) {
        options.style.height = Math.min(196, 14 * (data.length)) + 'px';
        data = data.sort(function(a, b) {
            if (a[3] == -1) { return -1; }
            else if (b[3] == -1) { return 1; }
            else { return a[2] > b[2]; }
        });
        for (var row in data) {
            var div = $el('div');
            div.onclick = function() { window.location = this.childNodes[0].childNodes[0].href; };

            var aDiv = $el('div');
            aDiv.style.cssText = 'float:left;';
            var aImg = $el('a');
            aImg.href = data[row][1];
            var a = $el('a');
            a.href = data[row][1];

            var img = $el('img');
            img.src = data[row][0];
            img.alt = data[row][2];
            img.title = data[row][2];
            img.style.marginRight = '3px';

            var txt = $txt(data[row][2]);

            aImg.appendChild(img);
            a.appendChild(txt);

            aDiv.appendChild(aImg);
            aDiv.appendChild(a);
            div.appendChild(aDiv);

            var countDiv = $el('div');
            countDiv.style.cssText = 'float:right;';
            var count = $txt('(' + data[row][4] + ')');
            countDiv.appendChild(count);

            div.appendChild(countDiv);

            var clearDiv = $el('div');
            clearDiv.style.clear = 'both';
            div.appendChild(clearDiv);
            
            options.appendChild(div);
        }
    }
}
function getAdSearchCountries(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdSearchCountries();
    }
}
function ajaxGetAdSearchCountries() {
    var url = lp_root + '/AdSearch/Countries.axd';
    url = url + '?l=' + currentLanguage;
    if (adsearch_parent) {
        url = url + '&p=' + adsearch_parent;
        if (adsearch_child) {
            url = url + '&c=' + adsearch_child;
        }
    }
    $ajax(url, ajaxLoadAdSearchCountries);
}
function ajaxLoadAdSearchCountries(result) {
    if (result) {
        var res = eval(result.responseText);
        if (res) {
            ddHideLoading(g_optionsId);
            dropdownAddCountry(g_optionsId, g_textId, g_valueId, res);        
        }
    }
}
function dropdownAddTuple(optionsId, textId, valueId, data) {
    var options = $(optionsId);
    if (options && options.childNodes.length == 0) {
        options.style.height = Math.min(196, 14 * (data.length)) + 'px';
        data = data.sort(function(a, b) {
            if (a[2] == -1 || a[2] == 150 || a[2] == 180) { return -1; }
            else if (b[2] == -1 || b[2] == 150 || b[2] == 180) { return 1; }
            else { return a[1] > b[1]; }
        });        
        for (var row in data) {
            var div = $el('div');
            div.onclick = function() { window.location = this.childNodes[0].childNodes[0].href; };

            var aDiv = $el('div');
            aDiv.style.cssText = 'float:left;';
            var a = $el('a');
            a.href = data[row][0];

            var txt = $txt(data[row][1]);
            a.appendChild(txt);

            aDiv.appendChild(a);
            div.appendChild(aDiv);

            var countDiv = $el('div');
            countDiv.style.cssText = 'float:right;';
            var count = $txt('(' + data[row][3] + ')');
            countDiv.appendChild(count);

            div.appendChild(countDiv);

            var clearDiv = $el('div');
            clearDiv.style.clear = 'both';
            div.appendChild(clearDiv);

            options.appendChild(div);
        }
    }
}
function ajaxLoadTuple(result) {
    if (result) {
        var res = eval(result.responseText);
        if (res) {
            ddHideLoading(g_optionsId);
            dropdownAddTuple(g_optionsId, g_textId, g_valueId, res);
        }
    }
}
function getAdSearchRegions(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdSearchRegions();
    }
}
function ajaxGetAdSearchRegions() {
    var url = lp_root + '/AdSearch/Regions.axd';
    url = url + '?l=' + currentLanguage;
    if (adsearch_country) {
        url = url + '&k=' + adsearch_country;
        if (adsearch_parent) {
            url = url + '&p=' + adsearch_parent;
            if (adsearch_child) {
                url = url + '&c=' + adsearch_child;
            }
        }
    }
    $ajax(url, ajaxLoadTuple);
}
function getAdSearchAreas(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdSearchAreas();
    }
}
function ajaxGetAdSearchAreas() {
    var url = lp_root + '/AdSearch/Areas.axd';
    url = url + '?l=' + currentLanguage;
    if (adsearch_country) {
        url = url + '&k=' + adsearch_country;
        if (adsearch_region) {
            url = url + '&r=' + adsearch_region;
            if (adsearch_parent) {
                url = url + '&p=' + adsearch_parent;
                if (adsearch_child) {
                    url = url + '&c=' + adsearch_child;
                }
            }
        }
    }
    $ajax(url, ajaxLoadTuple);
}
function getAdSearchMainAds(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdSearchMainAds();
    }
}
function ajaxGetAdSearchMainAds() {
    var url = lp_root + '/AdSearch/MainAds.axd';
    url = url + '?l=' + currentLanguage;
    if (adsearch_country) {
        url = url + '&k=' + adsearch_country;
        if (adsearch_region) {
            url = url + '&r=' + adsearch_region;
            if (adsearch_area) {
                url = url + '&a=' + adsearch_area;
            }
        }
    }
    $ajax(url, ajaxLoadTuple);
}
function getAdSearchSecondaryAds(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdSearchSecondaryAds();
    }
}
function ajaxGetAdSearchSecondaryAds() {
    var url = lp_root + '/AdSearch/SecondaryAds.axd';
    url = url + '?l=' + currentLanguage;
    if (adsearch_parent) {
        url = url + '&p=' + adsearch_parent;
        if (adsearch_country) {
            url = url + '&k=' + adsearch_country;
            if (adsearch_region) {
                url = url + '&r=' + adsearch_region;
                if (adsearch_area) {
                    url = url + '&a=' + adsearch_area;
                }
            }
        }
    }
    $ajax(url, ajaxLoadTuple);
}
function getAdQuickCountries(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdQuickCountries();
    }
}
function ajaxGetAdQuickCountries() {
    var url = lp_root + '/AdSearch/Countries.axd';
    url = url + '?l=' + currentLanguage;
    if (adsearch_parent) {
        url = url + '&p=' + adsearch_parent;
    }
    $ajax(url, ajaxLoadAdQuickCountries);
}
function ajaxLoadAdQuickCountries(result) {
    if (result) {
        var res = eval(result.responseText);
        if (res) {
            ddHideLoading(g_optionsId);
            ddAddCountryPlain(g_optionsId, g_textId, g_valueId, res);
        }
    }
}
function ddAddCountryPlain(optionsId, textId, valueId, data) {
    var options = $(optionsId);
    if (options && options.childNodes.length == 0) {
        options.style.height = Math.min(196, 14 * (data.length)) + 'px';
        for (var row in data) {
            var div = $el('div');
            div.onclick = function() {
                var text = this.childNodes[1].nodeValue;
                var value = this.childNodes[2].childNodes[0].nodeValue;
                setItem(optionsId, textId, valueId, text, value);
                _hideOptions();
            };

            var img = $el('img');
            img.src = data[row][0];
            img.alt = data[row][2];
            img.title = data[row][2];
            img.style.marginRight = '3px';

            var txt = $txt(data[row][2]);

            var span = $el('span');
            span.style.display = 'none';
            span.appendChild($txt(data[row][5]));

            div.appendChild(img);
            div.appendChild(txt);
            div.appendChild(span);
            options.appendChild(div);
        }
    }
}
function ddAddTuplePlain(optionsId, textId, valueId, data) {
    var options = $(optionsId);
    if (options && options.childNodes.length == 0) {
        options.style.height = Math.min(196, 14 * (data.length)) + 'px';
        for (var row in data) {
            var div = $el('div');
            div.onclick = function() {
                var text = this.childNodes[0].nodeValue;
                var value = this.childNodes[1].childNodes[0].nodeValue;
                setItem(optionsId, textId, valueId, text, value);
                _hideOptions();
            };
            var txt = $txt(data[row][1]);

            var span = $el('span');
            span.style.display = 'none';
            span.appendChild($txt(data[row][2]));

            div.appendChild(txt);
            div.appendChild(span);
            options.appendChild(div);
        }
    }
}
function getAdQuickParent(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdQuickParent();
    }
}
function ajaxGetAdQuickParent() {
    var url = lp_root + '/AdSearch/MainAds.axd';
    url = url + '?l=' + currentLanguage;
    $ajax(url, ajaxLoadAdQuickParents);
}
function ajaxLoadAdQuickParents(result) {
    if (result) {
        var res = eval(result.responseText);
        if (res) {
            ddHideLoading(g_optionsId);
            ddAddTuplePlain(g_optionsId, g_textId, g_valueId, res);
        }
    }
}
function getAdQuickChild(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdQuickChild();
    }
}
function ajaxGetAdQuickChild() {
    var url = lp_root + '/AdSearch/SecondaryAds.axd';
    url = url + '?l=' + currentLanguage;
    if (adsearch_parent) {
        url = url + '&p=' + adsearch_parent;
    }
    $ajax(url, ajaxLoadAdQuickChildren);
}
function ajaxLoadAdQuickChildren(result) {
    if (result) {
        var res = eval(result.responseText);
        if (res) {
            ddHideLoading(g_optionsId);
            ddAddTuplePlain(g_optionsId, g_textId, g_valueId, res);
        }
    }
}
function getAdQuickAge(optionsId, textId, valueId) {
    var options = $(optionsId);
    g_optionsId = optionsId;
    g_textId = textId;
    g_valueId = valueId;
    if (options && options.childNodes.length == 0) {
        ddShowLoading(optionsId);
        ajaxGetAdQuickAge();
    }
}
function ajaxGetAdQuickAge() {
    var url = lp_root + '/AdSearch/PersonalsAdvanced.axd';
    url = url + '?l=' + currentLanguage;
    url = url + '&e=Age';
    $ajax(url, ajaxLoadAdQuickAge);
}
function ajaxLoadAdQuickAge(result) {
    if (result) {
        var res = eval(result.responseText);
        if (res) {
            ddHideLoading(g_optionsId);
            ddAddTuplePlain(g_optionsId, g_textId, g_valueId, res);
        }
    }
}
var oldFi = null;
function showFeatureInfo(fi) {
    if (oldFi != null) {
        oldFi.nextSibling.style.display = 'none';
    }
    fi.nextSibling.style.display = 'block';
    oldFi = fi;
}
function hideFeatureInfo(fi) {
    fi.parentNode.parentNode.parentNode.style.display = 'none';
    oldFi = null;
}
function toggleAllCheckboxes() {
    var boss = $('checkAll');
    var idx = 0;
    var chk = $('check'+idx);
    while (chk != null) {
        chk.checked = boss.checked; //we're checked if the boss is, and vice versa
        idx++;
        chk = $('check' + idx);
    }
}
function doCeiling(num, factor, target) {
    $(target).value = Math.ceil(num / factor);
}
function ajaxPager(system, handler, page, size, container, querystring) {
    url = lp_root + '/' + system + '/' + handler + '.axd?n=' + page + '&s=' + size + '&c=' + container;
    if (querystring) {
        url = url + querystring;
    }
    var c = $(container);
    if (c) {
        c.style.position = "relative";
        var d = $el('div');
        d.className = "WizardWaiting";
        d.style.position = "absolute";
        d.style.left = "0";
        d.style.top = "0";
        var i = $el('img');
        i.src = "/images/loading2.gif";
        d.appendChild(i);
        c.appendChild(d);
    }
    $ajax(url, ajaxPagerPopulate);
}
function ajaxPagerPopulate(result) {
    if (result) {
        var res = eval('(' + result.responseText + ')');
        if (res) {
            var container = $(res[0]);
            if (container) {
                container.innerHTML = res[1].replace(/[|]/g, "'");
            }
        }
    }
}

///Requires absolute URL from a AbstractTabHandler.GetURL() call
function ajaxTabs(headerid, tabId, container, url) {

    //hide all the tabs first...
    var listOfTabs = $(container.substring(0, container.length - 1));
    var toReset = 0;
    while (listOfTabs.childNodes[toReset] != null) {
        if (listOfTabs.childNodes[toReset].style != null) {
            listOfTabs.childNodes[toReset].style.display = 'none';
        }
        toReset++;
    }

    //now we care about which tab is visibly selected...
    var idx = 0;
    var header = $(headerid);

    while (header.childNodes[idx] != null) {
        header.childNodes[idx].className = 'TabHeader';
        idx++;
    }
    $(tabId).className = 'SelectedTabHeader';
    
    //then look for the one we want, and either just show it (if it has content)
    //or load the content appropriately (if it doesn't).
    var c = $(container);
    if (c.innerHTML == null || c.innerHTML == '') {
        ddShowLoading(container);
        if (url.length > 0) {
            $ajax(url, ajaxTabsPopulate);
        }
    }
    c.style.display = 'block';
    return false;
}
function ajaxTabsPopulate(result) {
    if (result) {
        var res = eval('(' + result.responseText + ')');
        
        if (res) {
            var container = $(res[0]);
            ddHideLoading(container);
            if (container) {
                container.innerHTML = res[1].replace(/[|]/g, "'");
            }
        }
    }
}
function togglePostDock() {
    var c = $('PostDockContent');
    if (c.style.display == 'none') {
        showPostDock();
    }
    else {
        hidePostDock();
    }
}
function showPostDock() {
    var animator = new Animator('PostDockContent');
    animator.add(new Animation(200).opacity(0,100).show());
    animator.start();
    ajaxPager('PostBrowser', 'Forums', '1', '6', 'PostDockContent', '');
}
function hidePostDock() {
    var animator = new Animator('PostDockContent');
    animator.add(new Animation(200).opacity(100,0).hide());
    animator.start();
}
function delete_cookie(cookie_name, path, domain) {
    var cookie_date = new Date();
    cookie_date.setTime(cookie_date.getTime() - 1);
    document.cookie = cookie_name += "=;path=" + path + ";domain=" + domain + ";expires=" + cookie_date.toGMTString();
}
function disableButton(btn, valGroup, validate) {
    if (valGroup && valGroup != "") {
        if (validate) {
            Page_ClientValidate(valGroup);
        }
    }
    else {
        if (validate) {
            Page_ClientValidate();
        }
    }
    if (!validate || Page_IsValid) {
        btn.style.display = 'none';
        var img = btn.nextSibling;
        img.style.display = 'inline';
    }
}
function swapPollPanes(pane1id, pane2id, str1, str2) {
    var p1 = $(pane1id);
    var p2 = $(pane2id);
    if (p1.style.display == 'none') {
        p1.style.display = 'block';
        p2.style.display = 'none';
        $('togglePollPane').innerHTML = str2;
    }
    else {
        p1.style.display = 'none';
        p2.style.display = 'block';
        $('togglePollPane').innerHTML = str1;
    }
}

__h_scrolls = [];
function startHorizScroll(id, parentWidth, delta, time) {
    if (__h_scrolls[id]) { return; }
    __h_scrolls[id] = setInterval('scrollHoriz("' + id + '", ' + parentWidth + ', ' + delta + ')', time);
}

function stopHorizScroll(id) {
    if (__h_scrolls[id]) {
        clearInterval(__h_scrolls[id]);
        delete (__h_scrolls[id]);
    }
}

/**
 * Makes a given element horizontally scrollable.
 * It will be wrapped in a parent div, and clipped by it.
 * Two arrows on either side will scroll the contents.
 *
 * @param id the id of the element to make scrollable.
 */
function makeScrollable(id, width) {
    var scroll = $(id);
    if (scroll) {
        scroll.style.display = 'block';
        var actualScrollWidth = 0;
        for (var i = 0; i < scroll.childNodes.length; i++) {
            var node = scroll.childNodes[i];
            if (node && node.offsetWidth) {
                actualScrollWidth += node.offsetWidth + 10;
            }
        }
        scroll.style.width = '' + (actualScrollWidth) + 'px';
        
        var scrollWidth = scroll.style.width;
        scrollWidth = scrollWidth.substr(0, scrollWidth.length - 2)
        var isScrollable = scrollWidth > width;
        
        var wrapper = $el("div");
        var left = $el("div");
        var right = $el("div");
        var parent = scroll.parentNode;
        var clear = $el("div");

        wrapper.style.cssText = "float:left;";
        wrapper.style.width = width + 'px';
        wrapper.style.height = '80px';
        wrapper.style.position = 'relative';
        wrapper.className = 'ThumbScrollHorizontal';

        scroll.style.left = '0';
        scroll.style.top = '0';
        scroll.style.height = '80px';

        if (isScrollable) {
            left.className = 'ThumbScrollLeftArrow';
            left.onmouseover = function() { startHorizScroll(id, width, 7, 50); }
            left.onmouseout = function() { stopHorizScroll(id); }
            right.className = 'ThumbScrollRightArrow';
            right.onmouseover = function() { startHorizScroll(id, width, -7, 50); }
            right.onmouseout = function() { stopHorizScroll(id); }
        }
        else {
            left.className = 'ThumbScrollNonArrow';
            right.className = 'ThumbScrollNonArrow';
        }

        clear.style.clear = 'both';

        parent.removeChild(scroll);

        wrapper.appendChild(scroll);
        parent.appendChild(left);
        parent.appendChild(wrapper);
        parent.appendChild(right);
        parent.appendChild(clear);
        
    }
}


function scrollHoriz(id, parentWidth, delta) {
    var scroll = $(id);
    if (scroll) {
        var left = scroll.style.left;
        left = parseInt(left.substring(0, left.length - 2));
        left += delta;
        var width = scroll.style.width;
        width = parseInt(width.substring(0, width.length - 2));
        if (left > 0) { left = 0; }
        if (left < (parentWidth - width)) { left = (parentWidth - width); }
        scroll.style.left = left + 'px';
    }
}

function insertAfter(parent, node, referenceNode) {
    parent.insertBefore(node, referenceNode.nextSibling);
}
//function constrainTextLength(sourceId, reportId, textLength) { var sourceElement = document.getElementById(sourceId); if (sourceElement) { var reportElement = document.getElementById(reportId); if (reportElement) { if (sourceElement.value.length > textLength) { sourceElement.value = sourceElement.value.substring(0, textLength);}

function $doLimitTextSize(textid, maxlength) {
    var textInput = $(textid);
    if (textInput) {
        if(textInput.value.length > maxlength){
            textInput.value = textInput.value.substring(0, maxlength);
        }
        var report = $(textid + 'details');
        if (report) {
            report.innerHTML = textInput.value.length + '/' + maxlength;
        }
    }
}

/**
 * Limits the length of a given text input, and displays the remaining available characters.
 */
function $limitTextSize(textid, maxlength) {
    var textInput = $(textid);
    if (textid) {
        var details = $el('span');
        var detailid = textid + 'details';
        details.id = detailid;
        details.innerHTML = '0/' + maxlength;
        if (textInput.nextSibling) {
            textInput.parentNode.insertBefore(details, textInput.nextSibling);
        }
        textInput.onkeyup = function() { $doLimitTextSize(textid, + maxlength); };
    }
}

function gotoSearch() {
    var t = $('SearchName');
    if (t) {
        var l = lp_root + '/Search.aspx';
        var v = t.value;
        if (v.length > 0) {
            l += '?term=' + v;
        }
        window.location = l;
        return false;
    }
    return false;
}

function handleEnter(event) {
    var e = event ? event : window.event;
    if (e && e.keyCode == 13) {
        return gotoSearch();
    }
    return true;
}

var lastRegionPicked = '';
var lastAreasID = '';

function populateGeoAjax(results) {
    ajaxPagerPopulate(results);
    document.documentElement.scrollTop = 0;
}

function citiesInRegion(containerID, regionID, linkID) {
    $(containerID).innerHTML = '';
    ddShowLoading(containerID);
    url = lp_root + '/Geography/CitiesInRegion.axd?r=' + regionID + '&cid=' + containerID;
    $(linkID).style.fontWeight = 'bold';
    var old = $(lastRegionPicked);
    if (old != null) {
        old.style.fontWeight = 'normal';
    }
    lastRegionPicked = linkID;
    lastAreasID = containerID;
    $ajax(url, populateGeoAjax);
}

function getCitiesWithAdsByRegion(containerID, regionID, linkID) {
    $(containerID).innerHTML = '';
    ddShowLoading(containerID);
    url = lp_root + '/Geography/AdCities.axd?r=' + regionID + '&cid=' + containerID;
    $(linkID).style.fontWeight = 'bold';
    var old = $(lastRegionPicked);
    if (old != null) {
        old.style.fontWeight = 'normal';
    }
    lastRegionPicked = linkID;
    lastAreasID = containerID;
    $ajax(url, populateGeoAjax);
}

var addthis_config = { services_compact: 'digg,twitter,facebook,linkedin,livejournal,myspace,reddit,stumbleupon' }

var seconds = 119;

function startDollarCountdown() {
    $('DollarCountdown').innerHTML = "02:00";
    setInterval('dollarCountdown()', 1000);
}
function dollarCountdown() {
    var minutes = "00:";
    if (seconds >= 60) {
        minutes = "01:";
    }
    var secsToShow = (seconds % 60);

    if (secsToShow >= 10) {
        $('DollarCountdown').innerHTML = minutes + secsToShow;
    }
    else {
        if (secsToShow >= 0) {
            $('DollarCountdown').innerHTML = minutes + "0" + secsToShow;
        }
        else {
            endDollarCountdown();
        }
    }
    seconds--;
}
function endDollarCountdown() {
    clearInterval('dollarCountdown()');
    hide('PopupBackground');
    hide('OneDollarPopup');
}
function RenewFriendInvitation(s, r) {
    var url = lp_root + '/friendinvitations.axd?s=' + s + '&r=' + r + '&a=renew';
    $('time' + r).innerHTML = new Date().format("MM/dd/yyyy h:mm:ss tt");
    $ajax(url, empty);
}
function DeleteFriendInvitation(s, r, e) {
    var url = lp_root + '/friendinvitations.axd?s=' + s + '&r=' + r + '&a=delete';
    $(e).parentNode.style.display = 'none';
    $ajax(url,empty);
}
function empty(){
}


function UpdatePhotoBrowser(container, album) {
    var url = lp_root + '/PhotoGallery/ListPhotosInAlbum.axd?a=' + album + '&c=' + container;
    $ajax(url, ajaxPagerPopulate);
}

function UpdateAdPhotoBrowser(container, id) {
    var url = lp_root + '/PhotoGallery/ListPhotosInAd.axd?id=' + id + '&c=' + container;
    $ajax(url, ajaxPagerPopulate);
}

function UpdateEventPhotoBrowser(container, id) {
    var url = lp_root + '/PhotoGallery/ListPhotosInEvent.axd?id=' + id + '&c=' + container;
    $ajax(url, ajaxPagerPopulate);
}

function UpdateCityInfo(ui, form, area) {
    var url = lp_root + '/Geography/AreaInformation.axd?a=' + area + '&cid=' + ui;
    $(form).value = area;
    $ajax(url, ajaxPagerPopulate);
}

function CreateCityInfo(ui, form, country, region, areaname) {
    var url = lp_root + '/Geography/CreateArea.axd?an=' + areaname + '&c=' + country + '&r=' + region + '&cid=' + ui + '&f=' + form;
    $ajax(url, createCityInfoPopulate);
}
function createCityInfoPopulate(result) {
    if (result) {
        var res = eval('(' + result.responseText + ')');
        if (res) {
            var container = $(res[0]);
            var f = $(res[1]);
            var id = res[2];
            var ui = res[3].replace(/[|]/g, "'");
            if (f) {
                f.value = id;
            }
            if (container) {
                container.innerHTML = ui;
            }
        }
    }
}
function enforceStrictPassword(p, err, msg) {
    var lower = new RegExp('.*[a-z].*');
    var upper = new RegExp('.*[A-Z].*');
    var number = new RegExp('.*[0-9].*');
    var symbol = new RegExp('.*[@!#$%^&].*');
    var text = $(p).value;
    var result = lower.test(text) && upper.test(text) && (number.test(text) || symbol.test(text)) && text.length >= 8 && text.length <= 15;
    if (!result) {
        $(err).innerHTML = msg;
    }
    else {
        $(err).innerHTML = '';
    }
    return result;
}
