
//-----------------------------------------------------------------//
//------ ClientControls - Copyright (C) 2004/2005 Freeway ApS -----//
//-----------------------------------------------------------------//

//--------------//
// RadioButtons //
//--------------//

var RB_URLIDX_UNCHK = 0;
var RB_URLIDX_CHK = 1;
var RB_URLIDX_UNCHK_DIS = 2;
var RB_URLIDX_CHK_DIS = 3;
var RB_ID = 0;
var RB_UrlTable = new Array ();

function RB_NewUrlSet ( basepath, unchk, chk, unchk_dis, chk_dis )
{
	var index = RB_UrlTable.length;
	var rec = RB_UrlTable [index] = new Array ();
	rec [ RB_URLIDX_UNCHK ] = basepath + unchk;
	rec [ RB_URLIDX_CHK ] = basepath + chk;
	rec [ RB_URLIDX_UNCHK_DIS ] = basepath + unchk_dis;
	rec [ RB_URLIDX_CHK_DIS ] = basepath + chk_dis;
}

function RB_GetUrl ( color, ischecked, isdisabled )
{
	if ( ( color < 0 ) || ( color >= RB_UrlTable.length ) )
	{
		alert ('RB_GetUrl::Invalid color (' + color + ')');
		return "";
	}
	
	var index;
	
	if ( isdisabled )
		index = RB_URLIDX_UNCHK_DIS;
	else
		index = RB_URLIDX_UNCHK;
	
	if ( ischecked )
		index += 1;
	
	return RB_UrlTable [ color ] [ index ];
}

function RB_CreateStateObject ( imageobject, hiddenobject, colorid, isdisabled )
{
	var stateobj = new Array ();
	stateobj [0] = imageobject;
	stateobj [1] = hiddenobject;
	stateobj [2] = colorid;
	stateobj [3] = isdisabled;
	return stateobj;
}

function RB_ChgState ( state, ischecked )
{
	state [0].src = RB_GetUrl ( state [2], ischecked, state [3] );
	state [1].value = (ischecked ? "true" : "false");
	//alert (state + " " + ischecked);
}

function drb ( colorid, ischecked, isdisabled, spaces, caption, hidid, hidname, groupname )
{
	var id = RB_ID++;	
	var imgid = "rbdot" + id;
	var radiobtnid = "rb" + id;
	var stateobj;
	var strspaces = "";
	
	for ( i = 0; i < spaces; i++ )
		strspaces += "&nbsp;";
	
	document.open ();
	document.write ( "<table cellpadding=0 cellspacing=0 border=0 onclick=\"RB_ChangeRadioButtonState ( '" + radiobtnid + "');\">" );
	document.write ( "<tr><td class=DatingRadioButton><img id=\"" + imgid + "\"></td>" );
	document.write ( "<td valign=center style=\"cursor: pointer;\">" + strspaces + unescape ( caption ) + "</td>" );
	document.write ( "</tr>" );
	document.write ( "</table>" );
	document.close ();
	
	var imgobj = document.getElementById ( imgid );
	var hidobj = document.getElementById ( hidid );
	
	stateobj = RB_CreateStateObject ( imgobj, hidobj, colorid, isdisabled );
	RB_ChgState ( stateobj, ischecked );
	RB_AddRadioButton ( radiobtnid, unescape ( groupname ), stateobj, RB_ChgState, ischecked );
}

function dhl ( caption, iconurl, isdisabled, spaces, wrap, classname, navigateurl )
{
	var strspaces = "";
	
	for ( i = 0; i < spaces; i++ )
		strspaces += "&nbsp;";

	if ( classname == null )
		classname = (isdisabled ? "DatingHyperLinkDisabled" : "DatingHyperLink");
	
		
	document.open ();
	
	document.write ( "<table cellpadding=0 cellspacing=0 border=0>" );
	document.write ( "<tr><td valign=bottom>" );
	document.write ( "<img src=\"" + iconurl + "\"></td><td " + (wrap ? "" : "nowrap=true ") + "valign=center>" );
	
	if ( !isdisabled )
	{	
		var is_javascript = ( navigateurl.substring ( 0, 10 ) == "javascript" );
		
		if ( !is_javascript )
		{
			document.write ( "<a style=\"cursor: pointer;\" class=\"" + classname + "\" href=\"" + unescape ( navigateurl ) + "\">" + strspaces + unescape ( caption ) + "</a>" );
		}
		else
		{
			document.write ( "<span style=\"cursor: pointer;\" onclick=\"" + unescape ( navigateurl ) + "\"><a href=\"#\" class=\"" + classname + "\">" + strspaces + unescape (caption) + "</a></span>" );
		}			
	}
	else
	{
		document.write ( "<span class=\"" + classname + "\">" + strspaces + unescape (caption) + "</span>" );
	}
	
	document.write ( "</td></tr></table>" );
	document.close ();
}


var blnCreatePopup = (window.createPopup) ? true : false; // IE 5.5 
var objPopup;
var popupStandby=true;

if (navigator.appName == 'Microsoft Internet Explorer' ) {
	var oPopupMessage = window.createPopup();
	var oPopMessageBody					= oPopupMessage.document.body;
}

if (blnCreatePopup)
{
    oPopMessageBody.style.backgroundColor	= "#136b88";
	oPopMessageBody.style.borderRight		= "solid #FAE8B0 1px"; 
	oPopMessageBody.style.borderBottom		= "solid #FAE8B0 1px";
	oPopMessageBody.style.borderTop			= "solid #FFFFFF 1px";
	oPopMessageBody.style.fontFamily		= "verdana";
	oPopMessageBody.style.color		    	= "#FFFFFF";
	oPopMessageBody.style.weight			= "bold";
}


function ShowUserMessage(sMessage)
{
	if (navigator.appName == 'Microsoft Internet Explorer' ) 
	{
		var sFullMessage = "<table cellpadding=\"0\" width=\"100%\" height=\"100%\" cellspacing=\"0\" border=\"0\" style=\"border:outset 1px; #E4D196;border-top:solid 1px #FFFFFF\;\">";
		sFullMessage += "<tr valign=\"top\" style=\"padding: 4px;\">";
		sFullMessage += "<td style=\"font-weight:bold;padding-left:10px;font-size:13px;color:#FFFFFF\"> Dating.dk</td>";
		sFullMessage += "</tr>";
		sFullMessage += "<tr valign\"top\">";
		sFullMessage += "<td style=\"padding:1;\"><div style=\"padding-left:4px; padding-right: 8px; color: #B23428; padding-top: 4px; padding-bottom: 4px; ;font-size:11px;font-weight:bold;height:110px; background-color:#FAE8B0; border:inset 2px #E4D196; \"><br /><img runat=\"server\" src=\"/Graphics/Icons/MailBox/mail_unread_v5.gif\"><br /><br />"+ sMessage +"</div></td>";
		sFullMessage += "</tr>";
		sFullMessage += "</table>";	
		
		dWidth	= 200;
		dHeight	= 140;
		dTop	= screen.availHeight-dHeight;
		dLeft	= screen.width-dWidth;
		
		// Set message
		if(typeof(sMessage)!='undefined'){
			oPopupMessage.document.body.innerHTML = sFullMessage;	
		}
		
		dStart=0;
		popupInt = window.setInterval("showPopup()",120);
		popupStandby=false;
	}
}

function showPopup(){
	popupStandby=false;
	dStart+=(dHeight/15);
	if (dStart<dHeight){
		oPopupMessage.show((screen.width-dWidth),(screen.availHeight-dStart-1),dWidth,dStart);
	} else {
		window.clearInterval(popupInt);
		window.setTimeout("hidingPopup()",4000);
		oPopupMessage.show((screen.width-dWidth),(screen.availHeight-dHeight-1),dWidth,dHeight);
		popupStandby=true;
	}
}

function hidePopup(){
	popupStandby=false;
	dStart-=(dHeight/15);
	if (dStart>0){
		oPopupMessage.show((screen.width-dWidth),(screen.availHeight-dStart-1),dWidth,dStart);
	} else {
		window.clearInterval(popupInt);
		oPopupMessage.hide();
		popupStandby=true;
	}
}

function hidingPopup(){
	if ((popupStandby)&&(oPopupMessage.isOpen)){dStart=dHeight;
		popupInt = window.setInterval("hidePopup()",35);
		popupStandby=false;
	}
}

