﻿var loginInPlace;

function redirect(str)
{
	window.location.href = str;
}

function attemptLogin(obj)
{
    showDialogStandard(siteRoot + '/ajax/componentloader?name=Dialog_Login&mode=inline', 'Sign In', enumDialogSize.small);
}

function reloadPage()
{
    window.location.reload();
    return;
}

function switchImage(elementid, image)
{
    bgimage = "url('"+image+"')";
    document.getElementById(elementid).style.backgroundimage = bgimage;
}

function DetectEnterKey(e)
{
    var characterCode;
    // NN4 specific code
    if(e && e.which) 
    {
        e = e;
        characterCode = e.which;
    }
    else
    {
        if(!e) e = event;
        // IE specific code
        characterCode = e.keyCode; 
    }
    // Enter key is 13
    if (characterCode == 13) 
    {
        e.returnValue=false;
        e.cancelBubble = true;
        
        return true;
    }
    else 
        return false;
}

function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
	    do 
	    {
		    curleft += obj.offsetLeft;
		    curtop += obj.offsetTop;
	    }
	    while (obj = obj.offsetParent);
    }
	return [curleft,curtop];
}

var optionsOn = false;

function showOptionsBar() {
    if (!optionsOn) {
        Effect.SlideDown('top-options-block');
        $('set-options').addClassName('set-options-active');
        optionsOn = true;
    } else {

        Effect.SlideUp('top-options-block');
        $('set-options').removeClassName('set-options-active');
        optionsOn = false;
    }
    return false;
}

function topMessage(message)
{
    var bar = $('visualeditor-topmessage');
    if(!bar) return;
    
    var barInner = $('visualeditor-topmessage-inner');
    if(!barInner) return;
    
    barInner.innerHTML = message;
    Effect.SlideDown(bar, { duration: 1.0, scope: 'topmsg' });
    new Effect.Highlight(bar, { startcolor: '#ffff99', endcolor: '#ffffff', duration: 5.0, scope: 'topmsg' });
    setTimeout("Effect.SlideUp('visualeditor-topmessage', { duration: 1.0 })", 8000);
}

function slideLeft() {

}

function slideRight() {

}
