var _key = '';
var _mouseX = 0;
var _mouseY = 0;

var _bannerPreviousID = 0;
var _bannerNextID = 1;
var _bannerTimerID = 1;

$(document).ready(function() {
if (document.getElementById('tblFrontpageNews') != null) { $('#news_0').show(); $('#news_action_0').attr('src', 'images/actions/expanded.gif'); }
    $().mousemove(function(e) { _mouseX = e.pageX; _mouseY = e.pageY; });
}
);

jQuery.fn.center = function (absolute) {
	return this.each(function () {
		var t = jQuery(this);

		t.css({
			position:	absolute ? 'absolute' : 'fixed', 
			left:		'575px', 
			top:		'300px', 
			zIndex:		'99'
		}).css({
			marginLeft:	'-' + (t.outerWidth() / 2) + 'px', 
			marginTop:	'-' + (t.outerHeight() / 2) + 'px'
		});

		if (absolute) {
			t.css({
				marginTop:	parseInt(t.css('marginTop'), 10) + jQuery(window).scrollTop(), 
				marginLeft:	parseInt(t.css('marginLeft'), 10) + jQuery(window).scrollLeft()
			});
		}
	});
};

function BCarroussel(prefix, previousID, nextID, max, timeout)
{
    $('#' + prefix + previousID).hide('slow');
    $('#' + prefix + nextID).show('slow');

    if (max > 1)
    {        
        previousID = nextID;
        nextID = (nextID>=max) ? 1 : nextID+1;

        setTimeout("BCarroussel('" + prefix + "', " + previousID + ", " + nextID + ", " + max + ", " + timeout + ")", timeout);
    }
}

function ShowFrontpageItem(type, max, item)
{
    var div = type.replace('action_', '');
    if (document.getElementById(div + item).style.display!='block')
    {
        for (var i = 0; i < max; i++)
        {
            var onCompleted = null;

            $('#' + type + i).attr('src', 'images/actions/collapsed.gif');
            $('#' + div + i).hide('slow');

            if (i == max - 1)
            {
                onCompleted = function() {
                    $('#' + type + item).attr('src', 'images/actions/expanded.gif');
                    $('#' + div + item).show('slow');
                };
            }

            $('#' + div + i).hide('slow', onCompleted);
        }
    }
}

function ShowFrontPageItemEvent(type, max, item)
{
    $('#' + type + item).attr('src', 'images/actions/expanded.gif');
    $('#' + div + item).show('slow');
}

function SubmenuItem_Over(item) { item.className = 'submenuitem_over'; }
function SubmenuItem_Out(item) { item.className = 'submenuitem'; }
function Quickmenu_Over(item) { item.className = 'quickmenu_over'; }
function Quickmenu_Out(item) { item.className = 'quickmenu'; }
function ListItem_Over(item) { item.className = 'listitem_over'; }
function ListItem_Out(item) { item.className = 'listitem'; }
function ObjectOver(obj){ obj.style.cursor = 'hand'; }
function ObjectOut(obj){ obj.style.cursor = 'pointer'; }
function ObjectOverBold(obj){ obj.style.cursor = 'hand'; obj.style.fontWeight='bold'; }
function ObjectOutBold(obj){ obj.style.cursor = 'pointer'; obj.style.fontWeight='normal'; }
function ObjectOverLink(obj){ obj.style.cursor = 'hand'; obj.style.color='#ff0000'; obj.style.textDecoration='underline'; }
function ObjectOutLink(obj){ obj.style.cursor = 'pointer'; obj.style.color='#000000'; obj.style.textDecoration='none'; }
function SelectOver(item) { item.style.cursor = 'hand'; item.style.backgroundColor = '#f0efaf'; }
function SelectOut(item) { item.style.cursor = 'pointer'; item.style.backgroundColor = '#ffffff'; }
function RowOver(row) { row.style.cursor = 'hand'; row.style.backgroundColor = '#ffffff'; }
function RowOut(row) { row.style.cursor = 'pointer'; row.style.backgroundColor = ''; }

function SelectClick(item)
{
    var select = item.parentNode.parentNode.parentNode.parentNode;
    var target = $(item.parentNode.parentNode.parentNode.parentNode).attr('target');
    var overlay = document.getElementById('divOverlay');
    
    document.getElementById(target).value = item.innerHTML;
    if (select!=null) select.style.display = 'none';
    if (overlay!=null) overlay.style.display = 'none';
}

function SelectClickID(item, reload)
{
    var select = item.parentNode.parentNode.parentNode.parentNode;
    var target = $(item.parentNode.parentNode.parentNode.parentNode).attr('target');
    var descriptiontarget = $(item.parentNode.parentNode.parentNode.parentNode).attr('descriptiontarget');
    var overlay = document.getElementById('divOverlay');
    
    document.getElementById(target).value = item.id;
    document.getElementById(descriptiontarget).value = item.innerHTML;
    if (select!=null) select.style.display = 'none';
    if (overlay!=null) overlay.style.display = 'none';
    
    try
    {
        if (reload==true) __doPostBack('add', '0');
    }
    catch(e) {}
}

function SelectClickProgramTeam(item, reload)
{
    var select = item.parentNode.parentNode.parentNode.parentNode;
    var target = $(item.parentNode.parentNode.parentNode.parentNode).attr('target');
    var overlay = document.getElementById('divOverlay');
    
    document.getElementById(target).value = item.id;
    if (select!=null) select.style.display = 'none';
    if (overlay!=null) overlay.style.display = 'none';
    
    __doPostBack('loadclubs', item.id);
}

function SelectTargetClick(id)
{
    var select = document.getElementById(id);
    var overlay = document.getElementById('divOverlay');
    
    if (select.style.display=='none' || select.style.display=='')
    {
        if (select!=null) select.style.display = 'block';
    }
    else
    {
        if (overlay!=null) overlay.style.display = 'none';
        if (select!=null) select.style.display = 'none';    
    }
}

function MenuOver(img)
{
    var key = $(img).attr('key');
    var smnu = document.getElementById('tblSubmenu_' + key);

    if (key != _key)
    {
        var smnu_prev = document.getElementById('tblSubmenu_' + _key);
        
        if(smnu_prev != null) smnu_prev.style.display = 'none';
    }
    
    img.style.cursor = 'hand';
    img.src = 'images/menu_' + key + '_a.gif';
    
    if (document.getElementById('divMenu_' + key) != null)
    {
        document.getElementById('divMenu_' + key).style.display = 'block';        
    }
    
    if(smnu != null) smnu.style.display = 'block';
    
    _key = key;    
    
    ShrinkQuickmenu();
}

function MenuOut(img)
{
    var key = $(img).attr('key');

    img.style.cursor = 'pointer';
    img.src = 'images/menu_' + key + '.gif';
}

function HideSubmenu(key)
{
    var smnu = document.getElementById('tblSubmenu_' + key);

    if(smnu != null) smnu.style.display = 'none';
}

function HideSubMenus()
{
    try
    {
        document.getElementById('tblSubmenu_overozc').style.display = 'none';
        document.getElementById('tblSubmenu_actueel').style.display = 'none';
        document.getElementById('tblSubmenu_jeugd').style.display = 'none';
        document.getElementById('tblSubmenu_elftallen').style.display = 'none';
        document.getElementById('tblSubmenu_supportersvereniging').style.display = 'none';
        document.getElementById('tblSubmenu_sponsorcommissie').style.display = 'none';
    }
    catch(e) {}
}

function ExtendQuickmenu()
{
    $('#divQuickmenuExtended').show('fast');
}

function ExtendQuickmenuFade(start, end, step)
{
    if (start != end)
    {
        var margin = start + step;
        document.getElementById('divQuickmenuExtended').style.marginLeft = margin + 'px';
        setTimeout("ExtendQuickmenuFade(" + margin + "," + end + "," + step + ")", 10);        
    }    
}

function ShrinkQuickmenu()
{    
    $('#divQuickmenuExtended').hide('fast');
}

function LinkMore(img)
{
    var key = $(img).attr('key');

    img.style.cursor = 'hand';
    img.src = 'images/' + key + '_o.gif';
}

function LinkLess(img)
{
    var key = $(img).attr('key');
    img.style.cursor = 'pointer';
    img.src = 'images/' + key + '.gif';
}

function AddEmoticon(img)
{
    var msg = document.getElementById('ctl00_cplMain_txtMessage');
    var emoticon = $(img).attr('alt');

    InsertAtCursor(msg, ' ' + emoticon + ' ');
    msg.focus();
}

function InsertAtCursor(myField, myValue)
{
    if (document.selection)
    {
        myField.focus();
        sel = document.selection.createRange();
        sel.text = myValue;
    }
    else if (myField.selectionStart || myField.selectionStart == '0')
    {
        var startPos = myField.selectionStart;
        var endPos = myField.selectionEnd;
        myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
    }
    else
    {
        myField.value += myValue;
    }
}

function ShowContent(div, overlay)
{
    var panel = document.getElementById(div);

    if (overlay==true)
    {
        SetOpacity('divOverlay', 50)
        overlay = document.getElementById('divOverlay');
        if (overlay!=null) overlay.style.display = 'block';
    }

    if (panel!=null) panel.style.display = 'block';
}

function HideContent(div)
{
    var panel = document.getElementById(div);
    var overlay = document.getElementById('divOverlay');

    if (panel!=null) panel.style.display = 'none';
    if (overlay!=null) overlay.style.display = 'none';    
}

function HideOverlay()
{
    var overlay = document.getElementById('divOverlay');

    if (overlay!=null) overlay.style.display = 'none';    
}

function SetOpacity(id, opacity)
{
    var object = document.getElementById(id);

    if (object!=null)
    {
        object.style.opacity = (opacity / 100);
        object.style.MozOpacity = (opacity / 100);
        object.style.KhtmlOpacity = (opacity / 100);
        object.style.filter = "alpha(opacity=" + opacity + ")";
    }
} 

function ShowNewsImage(img, id)
{
    var div = document.getElementById(id);

    if (div!=null)
    {
        var html = '';
        
        html += '<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" style=\"background-color:#ffffff;border:solid 1px #c0c0c0;white-space:nowrap;\">';
            html += '<tr style=\"height:20px;\">';
                html += '<td style=\"font-weight:bold; padding-left:5px;\">&nbsp;</td>';
                html += '<td style=\"padding-right:5px;\"><img src=\"images/actions/x.gif\" alt=\"Sluiten\" border=\"0\" onmouseover=\"ObjectOver(this)\" onmouseout=\"ObjectOut(this)\" style=\"float:right;\" /></td>';
            html += '</tr>';
            html += '<tr>';
                html += '<td runat=\"server\" colspan=\"2\" style=\"padding-bottom:2px;padding-left:2px;padding-right:2px;;\"><img src=\"' + img.src + '\" alt=\"\" alt=\"\" style=\"border:solid 1px #c0c0c0;\" /></td>';
            html += '</tr>';
        html += '</table>';
    
        div.innerHTML = html;
        div.style.display = 'block';
    }
}

function ShowUserAdContact(id)
{
    var tr = document.getElementById('userad_' + id);
    
    tr.style.display = (tr.style.display == 'block') ? 'none' : 'block';
}


function ShowUserAdAttachment(path)
{    
    var html = '';
    var y = _mouseY + 15;
    
    html += '<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" style=\"background-color:#ffffff;border:solid 1px #c0c0c0;white-space:nowrap;\">';
        html += '<tr style=\"height:20px;\">';
            html += '<td style=\"font-weight:bold; padding-left:5px;\">&nbsp;</td>';
            html += '<td style=\"padding-right:5px;\"><img src=\"images/actions/x.gif\" alt=\"Sluiten\" border=\"0\" onmouseover=\"ObjectOver(this)\" onmouseout=\"ObjectOut(this)\" style=\"float:right;\" /></td>';
        html += '</tr>';
        html += '<tr>';
            html += '<td runat=\"server\" colspan=\"2\" style=\"padding-bottom:2px;padding-left:2px;padding-right:2px;;\"><img src=\"' + path + '\" alt=\"\" alt=\"\" style=\"border:solid 1px #c0c0c0;\" /></td>';
        html += '</tr>';
    html += '</table>';
                
    $('#divUserAdAttachment').html(html);
    $('#divUserAdAttachment').show();
    $('#divUserAdAttachment').css('top', y + 'px');
    $('#divUserAdAttachment').css('left', '186px');
}
