var inputId = "";
function setDateForInput(id,frameId,AJAXFunc)
{
	if(!AJAXFunc)
		var AJAXFunc = "";
	if(document.getElementById(id))
	{
		try
		{
			document.getElementById(id).focus();
		}
		catch(e){window.status = e;};
	}
	if(document.all)
		var frame = document.getElementById(frameId).contentWindow.document;
	else
		var frame = document.getElementById(frameId).contentDocument;
	var data = frame.getElementById('date').value;
	if(data)
	{
		if(document.getElementById(id))
		{
			document.getElementById(id).value = data;
			var frameContainerId = document.getElementById(frameId).parentNode.id;
			if(typeof AJAXFunc === 'function')
				hideCalendar(id,frameContainerId,AJAXFunc);
			else
				hideCalendar(id,frameContainerId);
		}
	}
	bugFix(frameId);
}

function hideCalendar(id,caledarFrameId,AJAXFunc)
{
	vizibil[id] = false;
	if(!caledarFrameId)
		{
		var caledarFrameId = 'frameContainer';
		}
	overCalendar = false;
	document.getElementById(caledarFrameId).style.display='none';
	if(typeof AJAXFunc === 'function')
		AJAXFunc();
}

function showCalendar(id,caledarFrameId)
{
	vizibil[id] = true;
	if(!caledarFrameId)
		{
		var caledarFrameId = 'frameContainer';
		}
	document.getElementById(caledarFrameId).style.display='';
}
function keepDate(date,caledarFrameId)
{
		if(!caledarFrameId)
		{
		var caledarFrameId = 'calendarFrame';
		}
		if(date)
		{
			var frameSrc = document.getElementById(caledarFrameId).src;
			var blankSrc = frameSrc.substr(0,frameSrc.indexOf('&date'));
			//var getCalType = frameSrc.substr(frameSrc.indexOf('?calType'));
			//if(getCalType=="")
			//	getCalType = frameSrc.substr(frameSrc.indexOf('&calType'));
			if(blankSrc!="")
				document.getElementById(caledarFrameId).src = blankSrc+'&date='+date;
			else
				document.getElementById(caledarFrameId).src+='&date='+date;
		}
}

function bugFix(caledarFrameId)
{
	if(!caledarFrameId)
	{
		var caledarFrameId = 'frameContainer';
	}
		if(document.addEventListener)
		{
			document.getElementById(caledarFrameId).addEventListener("mouseout",function(){document.getElementById(inputId).focus();},false);
		}
		else if(document.attachEvent)
		{
			document.getElementById(caledarFrameId).attachEvent("onmouseout",function(){document.getElementById(inputId).focus();});
		}
	var calendarFrames = $$('frameContainer');
	
	for(var s in calendarFrames)
	{
		if(calendarFrames[s].tagName)
		{
			if(calendarFrames[s].tagName.toUpperCase()=="FRAME")
			{
				if(document.addEventListener)
				{
					calendarFrames[s].addEventListener("mouseout",function(){document.getElementById(inputId).focus();},false);
				}
				else if(document.attachEvent)
				{
					calendarFrames[s].attachEvent("onmouseout",function(){document.getElementById(inputId).focus();});
				}
			}
		}
	}
}