/*
	Copyright Code Computerlove Ltd 2007-2009
	Build: 1.0.0.127
	Date: 05/10/2009 10:52:21
*/

// JavaScript Document

// Event when mouse moves over the calendar icon
function CalendarIconMouseOver(objItem){
	objItem.style.background="#666666";
}


// Event when mouse moves out of the calendar icon
function CalendarIconMouseOut(objItem){
	objItem.style.background="";
}

// Focus on an element
function focusOnElement( objName )
{
	obj = document.getElementById( objName );
	if ( obj )
	{
		obj.focus();
	}
}

// Calendar Date Check
var satOnly = false;
var SPECIAL_DAYS = {};
var earliestYear;
var earliestMonth;
var earliestDay;

function checkDate( dt, yr , mth, dy )
{	
	//alert( 'start ' + yr + ' ' + mth + ' ' + dy );
	if ( dt.getDay() == 0 )
	{
		return true;
	}
	if ( satOnly == true )
	{
		if ( dt.getDay() != 6 )
		{
			return true;
		}
	}
	else
	{
		if ( dt.getDay() == 6 )
		{
			return true;
		}
	}
	if ( dateIsSpecialv2( yr , mth, dy ) ) return true;
	//alert( 'date not special ' );

	if ( yr < earliestYear )
	{
		return true;
	}
	if ( yr == earliestYear )
	{
		//alert( 'year equal ' );
		if ( mth < earliestMonth )
		{
			return true;
		}
		if ( mth == earliestMonth )
		{
			//alert( 'month equal ' );
			if ( dy < earliestDay )
			{
				//alert( 'day less than ' + earliestDay );		
			
				return true;
			}
		}
	}
	return false;
}
		  
function dateIsSpecial(year, month, day)
	{
	var m = SPECIAL_DAYS[ month ];
	if (!m ) return false;
	for (var i in m) if ( m[i] == day ) return true;
	return false;
}

function dateIsSpecialv2(year, month, day)
{
	for(i=0;i<SPECIAL_DAYS.length;i++)
	{
		if( SPECIAL_DAYS[i].getFullYear()==year && SPECIAL_DAYS[i].getMonth()==month && SPECIAL_DAYS[i].getDate()==day)
		{
			return true;		
		}
	}
	return false;
}


// This function opens the room creator.
function open_rc(options){
	options = options + '';
	if (options.length > 0){
		if (options.substring(0, 1) != '?') options = '?' + options;
	}
	var domain = '';
	try { domain = document.domain; }
	catch (e) {}
	var win="/flash/roomcreator/default.aspx" + options;
	// Ensure domain is http and not https
	if (domain != '') win = 'http://' + domain + win;
	var Wdth=650;var Hgt=530;var cen_x=(screen.availWidth/2)-(Wdth/2);var cen_y=(screen.availHeight/2)-(Hgt/2);
	window.open( win, "rc", "screenX="+cen_x+",screenY="+cen_y+",top="+cen_y+",left="+cen_x+",width=" + Wdth + ",height=" + Hgt + ",toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=0,resizable=0");
}


function launchRCFromCompare() {
	var f=document.forms[0];
	if(f) {
		var rcqs='?room_id=-99';var j=0;
		for(var i=0; i<f.elements.length; i++) {
			if(f.elements[i].name=='RCCB' && f.elements[i].checked) {
				var sa=f.elements[i].value.split('|');
				j++;
				rcqs+='&c_c'+j+'id='+sa[0];
				rcqs+='&c_c'+j+'d_text='+escape(sa[1]);
				rcqs+='&c_c'+j+'file='+escape(sa[2]);
			}
		}
		if(j>0) {
			open_rc(rcqs);
		}
	}
}

function setSizesFromWindow(s, t1, t2) {
	if(document.getElementById) {
		var sel = document.getElementById(s);
		var tx1 = document.getElementById(t1);
		var tx2 = document.getElementById(t2);
		if(sel&&tx1&&tx2) {
			var s=sel.options[sel.selectedIndex].value;
			var sa=s.split("|");
			if(sa.length==3) {
				tx1.value=sa[1];
				tx2.value=sa[2];
			}
		}
		
	}
}

window.onload=hideme;

function hideme() {
	if(document.getElementById) {
		var objDiv = document.getElementById('hideme');
		if(objDiv)objDiv.style.display="none";
	}
}
function showme() {
	var objDiv = document.getElementById('hideme');
	if (objDiv != null) {
		if (objDiv.style.display=="none") {
			objDiv.style.display="";
		} else {
			objDiv.style.display="none";
		}
	}
}

function hideElement(id) {
	if(document.getElementById) {
		var objDiv = document.getElementById(id);
		if(objDiv)objDiv.style.display="none";
	}
}

var temp;
	
function redirect(x){
	for (m=temp.options.length-1;m>0;m--)
		temp.options[m]=null
	for (i=0;i<group[x].length;i++){
		temp.options[i]=new Option(group[x][i].text,group[x][i].value)
	}
	temp.options[0].selected=true
}

