var descriptionDiv = null;
var sourceSpan = null;
function launchCalendarWindow(url){
    var width = 550;
    var height;
    if (screen.height)
    {
        if (screen.height > 700)
            height = 700;
        else
            height = screen.height;
    }
    else
        height = 700;
        
    window.open(url,'','width='+width+',height='+height+',left=0,top=0,resizable=1,status=0,toolbar=0,location=0,menubar=1,directories=0,scrollbars=1');
};
function showDescriptionDiv(srcId,content){
	if (!descriptionDiv) {
	    var srcX = findPosX(srcId);
	    var srcY = findPosY(srcId);
	    if (srcY + 100 > screen.height)
	        srcY = screen.height - 100;
	    sourceSpan = document.getElementById(srcId);
	    sourceSpan.style.backgroundColor = '#FEF0B3';
	    descriptionDiv = document.createElement('DIV');
	    descriptionDiv.style.position = 'absolute';
	    descriptionDiv.style.width = '200px';
	    descriptionDiv.style.height = '100px';
	    descriptionDiv.style.backgroundColor = 'White';
	    descriptionDiv.style.left = srcX + 70 + 'px';
	    descriptionDiv.style.top = srcY + 'px';
	    descriptionDiv.style.zIndex = '99';
	    descriptionDiv.innerHTML = '<div><img src="images/DescDiv_Top.gif" width="200" height="4"/></div>' +
            '<div style="text-align: left; background-image: url(images/DescDiv_Background.gif); background-position: 0 0; background-repeat: repeat-y;">' +
	            '<img src="images/DescDiv_TopX.gif" title="Close" width="11" height="12" style="float: right; cursor: pointer; margin: 0px 4px 1px 1px;" onclick="javascript:closeDescriptionDiv();" />' +
	            '<div style="height: 93px; overflow: auto; overflow-x: hidden; font-family: Arial, Helvetica, Sans-Serif; font-size: 8pt; color: #666666; margin: 0px 0px 0px 5px;">' + content + '</div>' +
            '</div>' +
            '<div><img src="images/DescDiv_Bottom.gif" width="200" height="3"/></div>';
	    document.body.appendChild(descriptionDiv);
	}
};
function showDescriptionEditDiv(srcId,editLink,deleteLink) {
    if (!descriptionDiv) {
        var srcX = findPosX(srcId);
        var srcY = findPosY(srcId);
        if (srcY + 40 > screen.height)
            srcY = screen.height - 40;
        sourceSpan = document.getElementById(srcId);
        sourceSpan.style.backgroundColor = '#FEF0B3';
        descriptionDiv = document.createElement('DIV');
	    descriptionDiv.style.position = 'absolute';
	    descriptionDiv.style.width = '150px';
	    descriptionDiv.style.height = '20px';
	    descriptionDiv.style.backgroundColor = 'White';
	    descriptionDiv.style.border = 'solid 1px #0095CC';
	    descriptionDiv.style.left = srcX + 50 + 'px';
	    descriptionDiv.style.top = srcY + 'px';
	    descriptionDiv.style.zIndex = '99';
	    descriptionDiv.innerHTML = '<table width="100%" border="0" cellpadding="0" cellspacing="0">' +
	            '<tr><td valign="center" style="padding: 2px 0px 2px 2px; font-family: Arial, Helvetica, Sans-Serif; font-size: 8pt; color: #666666;"><a href="' + editLink + 
	            '">Edit Event</a> / <a href="' + deleteLink + '">Delete Event</a></td>' + 
	            '<td valign="center" width="13" style="padding: 2px 2px 2px 2px;"><img src="../../images/DescDiv_TopXBlue.gif" title="Close" width="11" height="12" style="float: right; cursor: pointer;" onclick="javascript:closeDescriptionDiv();" />' + 
	            '</td></tr></table>';
	    
	    document.body.appendChild(descriptionDiv);
    }
};
function closeDescriptionDiv(){
    if (descriptionDiv) {
        descriptionDiv.parentNode.removeChild(descriptionDiv);
        descriptionDiv = null;
    }
    if (sourceSpan) {
        sourceSpan.style.backgroundColor = 'White';
        sourceSpan = null;
    }
};
function getTarget(e){
	var value;
	if (checkBrowser() == "ie"){
		value = window.event.srcElement;
	}
	else{
		value = e.target;
	}
	theTarget = value;
};
function findPosX(object){
	var curleft = 0;
	var obj = document.getElementById(object);
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft - obj.scrollLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x){
		curleft += obj.x;
	}
	return curleft;
};
function findPosY(object){
	var curtop = 0;
	var obj = document.getElementById(object);
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop - obj.scrollTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
};
function checkBrowser(){
	var theAgent = navigator.userAgent.toLowerCase();
	if(theAgent.indexOf("msie") != -1){
		if(theAgent.indexOf("opera") != -1){
			return "opera";
		}
		else{
			return "ie";
		}
	}
	else if(theAgent.indexOf("netscape") != -1){
		return "netscape";
	}
	else if(theAgent.indexOf("firefox") != -1){
		return "firefox";
	}
	else if(theAgent.indexOf("mozilla/5.0") != -1){
		return "mozilla";
	}
	else if(theAgent.indexOf("\/") != -1){
		if (theAgent.substr(0,theAgent.indexOf('\/')) != 'mozilla'){
			return navigator.userAgent.substr(0,theAgent.indexOf('\/'));
		}
		else{
			return "netscape";
		} 
	}
	else if(theAgent.indexOf(' ') != -1){
		return navigator.userAgent.substr(0,theAgent.indexOf(' '));
	}
	else{ 
		return navigator.userAgent;
	}
};
function positionOptionsDiv() {
    var optionsDiv = document.getElementById('ROptionsDiv');
    var left = findPosX('RCheckBoxDiv');
    var top = findPosY('RCheckBoxDiv');
    optionsDiv.style.left = left + 125 + 'px';
    optionsDiv.style.top = top + 'px';
}