/************************************************************************************************

************************************************************************************************/
function winOpen(url, x, y) {
	
		leftPos = 0
	
		win = "status=0,scrollbars=1,resizable=1,scrollbars=yes,width=" + x +",height=" + y +",left="+ leftPos + ",top=0"; 
 		wind = window.open(url,'retail',win);	
		window.wind.focus();
}

/************************************************************************************************

************************************************************************************************/
function newWindow(eventID, sClient) 
{
	
	
	if (sClient=='bny'){
		audioURL ="/Format/bny/popup_leaving_bny.asp?url=" + "/conferencecallhost.asp%3Fevent%3D" + eventID + "%26client%3D" + sClient;
		audioWindow = window.open(audioURL.toLowerCase(), 'yesNoWin', 'width=500,height=400,resizeable=yes,toolbars=1')
	}else{
		audioURL = "conferencecallhost.asp?event=" + eventID + "&client=" + sClient;
		/* QAI 131495 - added location=1') for itrade client to display the title of the window as [title] instead of [url] - [title]*/
		if (sClient == 'itrade')
			audioWindow = window.open(audioURL.toLowerCase(), 'audioWin','width=500,height=400,resizeable=yes,toolbars=1,location=1')
		else
			audioWindow = window.open(audioURL.toLowerCase(), 'audioWin','width=500,height=400,resizeable=yes,toolbars=1')
			
	}
}

/************************************************************************************************

************************************************************************************************/
function newBNYWindow(mediaURL) 
{	
		mediaURL = mediaURL.replace("?", "%3F");
		mediaURL = mediaURL.replace("&", "%26");
		audioURL = "/Format/bny/popup_leaving_bny.asp?url=" + mediaURL;
		audioWindow = window.open(audioURL, 'yesNoWin', 'width=500,height=400,resizeable=yes,toolbars=1')
	
}

/************************************************************************************************


************************************************************************************************/
function setNavDate(oFrm,oSel)
{
	var dDate = oFrm.month.options[oFrm.month.selectedIndex].value.substring(0,6) + 
	oFrm.day.options[oFrm.day.selectedIndex].value.substring(6,8);
	oFrm.date.value = dDate;
	
	if (oSel == oFrm.month)
	{			
		updateDays(oFrm, oFrm.month.options[oFrm.month.selectedIndex].value.substring(0,6));		
		dDate = oFrm.month.options[oFrm.month.selectedIndex].value.substring(0,6) + 
			oFrm.day.options[oFrm.day.selectedIndex].value.substring(6,8);
		oFrm.date.value = dDate;		
	}
	
	//alert(dDate);
	//document.frmNav.submit();	
}

/************************************************************************************************
	QAI 100441 - fix for days dropdown
	10/29/08

************************************************************************************************/

function updateDays(oFrm, yearMonth)
{
	var date_arr = new Array;
	var days_arr = new Array;
	var dayDD_arr = new Array;
	
	date_arr[0]=new Option("January",31);
	date_arr[1]=new Option("February",28);
	date_arr[2]=new Option("March",31);
	date_arr[3]=new Option("April",30);
	date_arr[4]=new Option("May",31);
	date_arr[5]=new Option("June",30);
	date_arr[6]=new Option("July",31);
	date_arr[7]=new Option("August",31);
	date_arr[8]=new Option("September",30);
	date_arr[9]=new Option("October",31);
	date_arr[10]=new Option("November",30);
	date_arr[11]=new Option("December",31);
	
	for(i=1; i<= 31; i++)
    {
		if (i < 10)
			day = "0" + i;
		else 
			day = i;
			
		dayDD_arr[i-1]=new Option(i, yearMonth + day);;
        
    }    
	
	var month = parseInt(yearMonth.substring(4,6), 10);
	var year = yearMonth.substring(0,4);
	
	//alert("m = " + month);
	//alert("y = " + year);
	 
	temp=oFrm.day.options[oFrm.day.selectedIndex].value.substring(6,8);	
    
    for (i=oFrm.day.length-1;i>=0;i--)
    {
		oFrm.day.options[i]=null;
    }   
    
    ret_val = 0;
    
    selection=parseInt(date_arr[month - 1].value);      
    
    if(selection == 28)
    {		
		if (year % 4 != 0 || year % 100 == 0 ) ret_val=0;
        else
			if (year % 400 == 0)  ret_val=1;
            else
				ret_val=0;
    }
    
    selection = selection + ret_val;    
    
    for (i=1; i <= selection; i++)
    {		
		oFrm.day.options[i-1] = new Option(dayDD_arr[i-1].text, dayDD_arr[i-1].value);		
    }       
	
	if (temp > selection) temp = -1;	
	
    if (temp == -1) oFrm.day.options[0].selected=true;
    else
		oFrm.day.options[temp-1].selected=true;
}

/************************************************************************************************

************************************************************************************************/
function RadioDayWeekView(dayweek, dDate, sClient, datatype) 
{
	if (dayweek == 'week') 
		document.location = datatype + "_week.asp?date=" + dDate + "&client=" + sClient;
	else if (dayweek == 'day')
		document.location = datatype + ".asp?date=" + dDate + "&client=" + sClient;
	else if (dayweek =='all')
		document.location = datatype + "_full.asp?date=" + dDate + "&client=" + sClient;		
}

/************************************************************************************************

************************************************************************************************/
function closeWindow() 
{
	openWindow = window.close()
}

/************************************************************************************************

************************************************************************************************/
function changeParent(newURL)
{				
	opener.document.location = newURL;
	window.focus();
}				

/************************************************************************************************

************************************************************************************************/
function AllowNoSingleSpace()
{
	if( event.keyCode==32 && document.search.text.value.length==0) {
		event.returnValue=false;
	}
}

	
/************************************************************************************************

************************************************************************************************/
function newPurchaseWindow(eventID, sClient) 
{
	purchaseURL = "purchase.asp?event=" + eventID + "&client=" + sClient;
	
	purchaseWindow = window.open(purchaseURL.toLowerCase(), 'purchaseWin', 'width=750, height=465,resizable=yes,toolbars=1,scrollbars=yes')
}
/************************************************************************************************

************************************************************************************************/
function PayPage(eventID, sClient, btorboth) 
{
	

	DownloadURL = "Download.asp?event=" + eventID + "&client=" + sClient;
	if (btorboth=="b") {DownloadURL=DownloadURL + "&briefid="+eventID};
	if (btorboth=="t") {DownloadURL=DownloadURL + "&transcriptid=" + eventID};
	if (btorboth=="bt") {DownloadURL=DownloadURL + "&transcriptid=" + eventID + "&briefid=" + eventID};
    document.location.href = DownloadURL;
    window.resizeTo(750, 445);
}
