﻿function MeetingView(meetingId) {
    return window.open("MeetingView.aspx?meeting_id="+meetingId, "MeetingView", "width=950,height=680,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes", false)!=null ? true:false;
} // MeetingView

function DocumentView(documentId) {
    return window.open("DocumentView.aspx?document_id="+documentId, "DocumentView", "width=950,height=680,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes", false)!=null ? true:false;
} // DocumentView

function MemberView(memberId) {
    return window.open("MemberView.aspx?meeting_id="+memberId, "MemberView", "width=950,height=680,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes", false)!=null ? true:false;
} // MemberView

function TipEnVen(url) {
    return window.open(url,'TipEnVen','height=350,width=500,status=no,toolbar=no,menubar=no,location=no')!=null ? true:false;
} // TipEnVen

function PostView(postId) {
    return window.open("PostView.aspx?id="+postId, "PostView", "width=950,height=680,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes", false)!=null ? true:false;
} // PostView

function Subscribe(url) {
    return window.open(url,'Subscribe','height=600,width=700,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes')!=null ? true:false;
} // Subscribe

function SetSource(mediaurl){
        var array = mediaurl.split("&");
    
        var player = document.getElementById('VIDEO');
        player.URL = array[0];
        var offsetarray = array[1].split("=");
        player.Controls.currentPosition = offsetarray[1];
        player.Controls.play();
        return false;
}

var selectIsKeyboardArrow=false;
function SelectIsKeyboardArrow(e) {
    e = e || window.event;

    var code=null;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    
    switch (code) {
        case 37: // left
        case 38: // up
        case 39: // right
        case 40: // down
            selectIsKeyboardArrow=true;
        break;
        default:
            selectIsKeyboardArrow=false;
        break;
    }
} // IsKeyboardArrow

var onLoadCat=window.onload;
window.onload=function () {
	var di=0; // dot index
	with (document)if(domain)if((di=domain.lastIndexOf("."))!=-1)if((di=domain.lastIndexOf(".",di-1))!=-1)domain=domain.substring(di+1,domain.length);

	if (typeof(onLoadCat)=='function') onLoadCat();
	if (typeof(ca)=='object' && typeof(cia)=='object' && typeof(ia)=='object') {
		var srcSelect=document.getElementById('ctl00_ContentPlaceHolder_ddlCom');
		var dstSelect=document.getElementById('ctl00_ContentPlaceHolder_ddlCom2');
		var dstSelectContainer=document.getElementById('ctl00_ContentPlaceHolder_ddlCom2Cont');
		
		if (srcSelect && dstSelect && dstSelectContainer) {
			// Copy all options from src.
			for (var i=1; i<srcSelect.options.length; i+=1) {
				var optionValue=srcSelect.options[i].value;
				var optionText=srcSelect.options[i].text;
				var cat=cia[optionValue];
				ia[ia.length]={'value':optionValue,'text':optionText,'cat':cat}
			}
			// Reset length of src
			srcSelect.options.length=1;
			
			// Inset all categories.
			var fixCatArray=new Array();
			for (var i=0; i<ia.length; i+=1) {
				if (ia[i].cat) {
					if (!fixCatArray[ia[i].cat]) {
						fixCatArray[ia[i].cat]=true;
						srcSelect.options[srcSelect.options.length]=new Option(">> "+ca[ia[i].cat], ia[i].cat);
					}
				}
			}
			// Insert all noncategories.
			for (var i=0; i<ia.length; i+=1) {
				if (!ia[i].cat) srcSelect.options[srcSelect.options.length]=new Option(ia[i].text, ia[i].value);
			}
			
			srcSelect.xChange=srcSelect.onchange;
			srcSelect.onchange=function () {
				if (srcSelect.selectedIndex>-1) {
					var optionValue=this.options[this.selectedIndex].value;
					if (optionValue) {
						if (!ca[optionValue]) {
                            // Hide container.
						    dstSelectContainer.style.display="none";
							dstSelect.options.length=0;
						    this.xChange();
						    
						} else {
							// Insert all in category.
							dstSelect.options.length=0;
							dstSelect.options[dstSelect.options.length]=new Option("-- "+ca[optionValue]+" --", "");

							for (var i=0; i<ia.length; i+=1) {
								if (ia[i].cat==optionValue) {
									dstSelect.options[dstSelect.options.length]=new Option(ia[i].text, ia[i].value);
								}
							}
                            // Show container.
						    dstSelectContainer.style.display="block";
						}
					}
				}
			}
		}
	}
	
    window.focus();
} // onload

