var ShowDiv='ShowCalendar';

function SetDate(SelectedDate,target) {    
    var DetailView=document.getElementById(ShowDiv);                           
    DetailView.style.display="block"
    var obj=document.getElementById(target);
    DetailView.style.left=getLeft(obj) + 10;
    DetailView.style.top=getTop(obj)-20;

    AjaxCalendar('/Popup/Calendar_Popup.aspx','StartDT='+SelectedDate);    
}

function HideCalendar()
{
	var DetailView=document.getElementById(ShowDiv);                           
    DetailView.style.display=""
}

function getLeft(e){ 
    var offset=e.offsetLeft; 
    if(e.offsetParent!=null) offset+=getLeft(e.offsetParent); 
    return offset; 
} 
function getTop(e){ 
    var offset=e.offsetTop; 
    if(e.offsetParent!=null) offset+=getTop(e.offsetParent); 
    return offset; 
} 


function AjaxCalendar(url,paraStr)
{
	//設定呼叫參數 objpara
	var objpara=new Object;
		objpara.method='get';
		objpara.parameters=paraStr;				
		objpara.onFailure=showCError;	//設定失敗處理Function		
		objpara.onSuccess=showCSuccess;	//設定成功處理Function		
	var myAjax=new Ajax.Request(url,objpara);		
}

function showCError(originalRequest)
{	
	$(ShowDiv).innerHTML='敬請期待!#0#';
}

function showCSuccess(oRequest)
{	        
	if (oRequest.responseText.length <10)
		{
			//$(ShowDiv).innerHTML='敬請期待!#1#';
			//return;
		}
	else
	{
        $(ShowDiv).innerHTML=oRequest.responseText;
	}	
}
