/* Sogma 23/10/06 */ 

function brightcove(URL) {
	day = new Date();
	id = day.getTime();
	myWindow = window.open(URL, 'brightcove', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=950,height=560');
}

function brightcove_epk(URL) {
	day = new Date();
	id = day.getTime();
	myWindow = window.open(URL, 'brightcove_epk', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=486,height=412');
}

function setStyle(el, property, value) {
	element = document.getElementById(el);
	if(element.style) {element.style[property] = value;}
}

function getStyle(el, styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}


function leaveLadderConfirm(id) {
	var  agree= confirm("Are you sure you want to quit this ladder? Your standings and all your results will be lost.")
	if (agree) {
		window.location="index.php?controller=MatchManager&method=leave&mmid="+id;
	}
}

var iHeight = 200 ;
var collapseStep = 10 ;
var aniSpeed = 2;

function minimisepanel(objDiv) {
	var t =  parseInt( getStyle(objDiv, 'height'));
	if(t>0){ t=t-collapseStep ;
		if(t<=0){setStyle(objDiv, 'display', 'none');}
		setStyle(objDiv, 'height', t+'px');
		setTimeout( "minimisepanel('"+objDiv+"');", aniSpeed);
	}
}

function maximisepanel(objDiv) {
	setStyle(objDiv, 'display', 'block')
	var t = parseInt( getStyle(objDiv, 'height'));
	if(t<=(iHeight-collapseStep)) {	t=t+collapseStep ;
		setStyle(objDiv, 'height', t+'px');
		setTimeout( "maximisepanel('"+objDiv+"');", aniSpeed);
	}
}


function ShowHide(objID,imgref) {
	if (getStyle(objID, 'display')=='block') {
		minimisepanel(objID);
		imgref.src="/core/imgs/menu_media_close.gif";
		return
	}
	maximisepanel(objID);
	imgref.src="/core/imgs/menu_media_open.gif";
}

function entercode() {
	window.open("entercode.php",null,"height=200,width=400,status=no,toolbar=no,menubar=no,location=no");
}

function media_popUp(URL) {
		day = new Date();
		id = day.getTime();
		myWindow = window.open(URL, 'popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=680');
	}

	
// This function sets the cursor at a given position in an input field,
// and selects text between selStart and selEnd if they are not equal
function setSelRange(inputEl, selStart, selEnd)
{
	if (inputEl.setSelectionRange) { 
		inputEl.focus(); 
		inputEl.setSelectionRange(selStart, selEnd); 
	} else if (inputEl.createTextRange) { 
		var range = inputEl.createTextRange(); 
		range.collapse(true); 
		range.moveEnd('character', selEnd); 
		range.moveStart('character', selStart); 
		range.select(); 
	} 
}

