function showBlurLayer() {
    var blurLayer =  $("divBlurLayer");
    var docWidth = document.width;
    var docHeight = document.height;
    blurLayer.style.width = docWidth + "px";
    blurLayer.style.height = docHeight + "px";
    blurLayer.parentNode.removeChild(blurLayer);
    document.body.appendChild(blurLayer);
    blurLayer.show();
}

function centerObjectAndMoveToRoot(object, dimension) {
    var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
    var scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft;
    object.style.left = (document.viewport.getWidth() - dimension.width) /2 + scrollLeft + "px";
    object.style.top = (document.viewport.getHeight() - dimension.height) /2 + scrollTop + "px";
    object.parentNode.removeChild(object);
    document.body.appendChild(object);
    Element.show(object);
}

function showFeaturedProject(url) {
    showBlurLayer();
    $("iframeProjectPopup1").src = url;
    centerObjectAndMoveToRoot($("divProjectPopup"), {
        width:650,
        height:440
    })
}

function closeFeaturedProject() {
    $("divBlurLayer").hide();
    $("divProjectPopup").hide();  
}

function showRegisterForm(val) {
    showBlurLayer();
    var formRegister = $("formRegister");
    centerObjectAndMoveToRoot(formRegister, {
        width:Element.getWidth(formRegister),
        height:Element.getHeight(formRegister)
        });
}

function closeRegisterForm() {
    $("divBlurLayer").hide();
    $("formRegister").hide();
}

function fileBrowserCallBack(field_name, url, type, win) {
    browserField = field_name;
    browserWin = win;
    window.open(TinyMCE_BrowserURL, "browserWindow", "modal,width=800,height=780,scrollbars=1");
}

function SetUrl(url) {
    window.browserWin.document.getElementById('src').value = url;
    window.browserWin.focus();
}
scrollStep=1

timerLeft=""
timerRight=""

function toLeft(id){
    document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
    clearTimeout(timerRight)
    document.getElementById(id).scrollLeft+=scrollStep
    timerRight=setTimeout("scrollDivLeft('"+id+"')",10)
}

function scrollDivRight(id){
    clearTimeout(timerLeft)
    document.getElementById(id).scrollLeft-=scrollStep
    timerLeft=setTimeout("scrollDivRight('"+id+"')",10)
}

function toRight(id){
    document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function stopMe(){
    clearTimeout(timerRight)
    clearTimeout(timerLeft)
}

function roundNumber(num, dec) {
    var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
    return result;
}