function toggleDisplay(chkBox, divId){
	var show = chkBox.checked;
	var div1 = document.getElementById(divId)
	if (show == true) {
		div1.style.display = 'block'
	} else {
		div1.style.display = 'none'
	}
}

function ChangeValueOneZero(chkBox)
{
	var chkBoxValue = chkBox.value;
	if(chkBoxValue == 1)
		chkBoxValue = 0;
	else
		chkBoxValue = 1;
	chkBox.value = chkBoxValue;
}

function explode( delimiter, string, limit ) {
    // http://kevin.vanzonneveld.net
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}

// common function for tinymce init
// elms could be comma separated values of element id
// ex: initTinyMCE("PrizeMoney,contest_selected");
function initTinyMCE(elms)
{
		tinyMCE.init({
		theme : "advanced",
		mode: "exact",
		elements : elms,
		skin : "o2k7",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		//theme_advanced_statusbar_location : "bottom",
		//theme_advanced_resizing : true,
		
		// Example content CSS (should be your site CSS)
		content_css : "tiny_mce/css/content.css"		
	});
}

function jumpToEventEditPage(step, eventid)
{
	// as in iframe
	self.parent.location.href = 'edit-event-step'+step+'.php?eventid='+eventid;

	//window.location.href = 'edit-event-step'+step+'.php?eventid='+eventid;
}

function popupWindow(windowWidth, windowHeight, windowName, windowUri)
{
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

    newWindow = window.open(windowUri, windowName, 'resizable=0,width=' + windowWidth + 
        ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight);

    newWindow.focus();
    return newWindow.name;
}
