﻿// Limit the number of characters in an input
function LimitChars(obj,limit) 
{
    if(String(obj.value).length > limit) 
    {
        obj.value = String(obj.value).substring(0,limit);
    }
}

// Update the counter showing the number of chars left
function UpdateCharCount(obj,limit)
{
    var count = document.getElementById(obj.id + "_Count");

    if(count) 
    {
        count.value = limit - String(obj.value).length;
    }
}

function CompetitionForm(compID)
{
	window.open("CompetitionPopUp.aspx?ContentID=" + compID, 'Competition', 'height=750,width=640,scrollbars=yes,toolbar=no,status=yes,menubar=no,location=no,resizable=yes');
}

function OpenGalleryPopup(url)
{
    var width = 759;
    var height = 720;
    
    return OpenPopup(url, "GalleryPopup", width, height);
}

function OpenPopup(url, windowName, width, height)
{
    var popup;
    
    var left = 0;
    var top = 0;

    if (document.all || document.layers)
    {
        left    = (screen.availWidth - width) / 2;
        top     = (screen.availHeight - height) / 2;
    }
    else
    {
        left    = (screen.width - width) / 2;
        top     = (screen.height - height) / 2;
    }
    
    popup = window.open(url, windowName, "width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizeable=yes,left=" + left + ",top=" + top);
    
    
    if (!popup.opener)
        popup.opener = self;
        
    return false;
}