	// Globals
	// Major version of Flash required
	var requiredMajorVersion = 8;
	// Minor version of Flash required
	var requiredMinorVersion = 0;
	// Minor version of Flash required
	var requiredRevision = 0;
	// -->
	
function remove(x){
  	/*$('#'+ x).remove();*/
  	$('#'+ x).attr('class','completely_empty');
  	$('#'+ x).html('');
  	if(x == 'pop_up_div')
  		document.getElementById('pop_up_div').innerHTML = '<div id=\"videoPlayer\"></div>';
}

function displayvideo(x){
	$('#back_div').attr('class','back_div');		  
	$('#pop_up_div').attr('class','pop_up_div');
	('#pop_up_div').html('');
	document.getElementById('back_div').style.height ='100%';
	
     if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
 	   width = window.innerWidth;
 	   height = window.innerHeight;
	 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    width = document.documentElement.clientWidth;
	    height = document.documentElement.clientHeight;
	 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    width = document.body.clientWidth;
	    height = document.body.clientHeight;
	 }
	 var ScrollTop = document.body.scrollTop;
	 if(!ScrollTop){
		 if (window.pageYOffset)
	        ScrollTop = window.pageYOffset;
	    else
    	    ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	 }
    document.getElementById('pop_up_div').innerHTML += '<div onclick=\"remove(\'pop_up_div\'); remove(\'back_div\');\" style=\"padding:5px; cursor:pointer; font-weight:bold; font-size:15px\">Close</div>';
     document.getElementById('pop_up_div').style.left = width/2 +'px';
     document.getElementById('pop_up_div').style.top = height/2-document.getElementById('pop_up_div').offsetHeight/2+ScrollTop +'px';
	  //alert(document.getElementById('pop_up_div').offsetHeight);
	  //alert(document.getElementById('pop_up_div').offsetWidth);
	$('#back_div').bind('click',function(){ remove('pop_up_div'); remove('back_div'); });
	
	//ytvbp.VIDEO_PLAYER_DIV = 'videoPlayer';
	//ytvbp.presentVideo(x);
	$('#pop_up_div').css({'width':'430px','margin-left':'-215px'});
	$('#pop_up_div').append(display_video_popup(x));
}

function show_chairman_msg(){
	$('#back_div').attr('class','back_div');		  
	$('#pop_up_div').attr('class','pop_up_div');
	$('#pop_up_div').html('');
	document.getElementById('back_div').style.height ='100%';
	
     if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
 	   width = window.innerWidth;
 	   height = window.innerHeight;
	 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    width = document.documentElement.clientWidth;
	    height = document.documentElement.clientHeight;
	 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    width = document.body.clientWidth;
	    height = document.body.clientHeight;
	 }
	 var ScrollTop = document.body.scrollTop;
	 if(!ScrollTop){
		 if (window.pageYOffset)
	        ScrollTop = window.pageYOffset;
	    else
    	    ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	 }
    document.getElementById('pop_up_div').innerHTML += '<div onclick=\"remove(\'pop_up_div\'); remove(\'back_div\');\" style=\"padding:5px; cursor:pointer; font-weight:bold; font-size:15px\">Close</div>';
     document.getElementById('pop_up_div').style.left = width/2 +'px';
     document.getElementById('pop_up_div').style.top = height/2-document.getElementById('pop_up_div').offsetHeight/2+ScrollTop +'px';
	  //alert(document.getElementById('pop_up_div').offsetHeight);
	  //alert(document.getElementById('pop_up_div').offsetWidth);
	$('#back_div').bind('click',function(){ remove('pop_up_div'); remove('back_div'); });
	
	//ytvbp.VIDEO_PLAYER_DIV = 'videoPlayer';
	//ytvbp.presentVideo(x);
	//$('#pop_up_div').append(display_video_popup(x));
	$('#pop_up_div').css({'width':'600px','margin-left':'-300px'});
	$('#pop_up_div').append("<embed src=\'http://blip.tv/play/r2XF4yWKxB4\' type=\'application/x-shockwave-flash\' width=\'575\' height=\'300\' allowscriptaccess=\'always\' allowfullscreen=\'true\'></embed>");
}


function playsong(song, title, div){
	// Version check based upon the values entered above in Globals
//	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	// Check to see if the version meets the requirements for playback
	//if(hasReqestedVersion){
		$('#'+div).css("border", "1px solid #123");
		//if we detect an acceptable version
		/*var so = new SWFObject('music/xspf/xspf_player_slim.swf?playlist_url=music/xspf/test.xspf&song_title='+title+'&autoplay=1&main_image=http://www.phalanxserver.com/adeql/music/xspf/skin_wimpy_horiz.jpg&color=000000 ', 'mainnav', '200', '20', '7', '');
		so.addParam('wmode', 'transparent');
		so.addParam('loop', 'false');
		so.addParam('movie', 'music/xspf/xspf_player_slim.swf?playlist_url=music/xspf/test.xspf&song_title='+title+'&autoplay=1&main_image=http://www.phalanxserver.com/adeql/music/xspf/skin_wimpy_horiz.jpg&color=000000 ');
		so.write(div);*/
		var so = new SWFObject('music/xspf/xspf_player_slim2.swf?song_url=radio/'+song+'&song_title='+title+'&autoplay=1&color=000 ', 'mainnav', '200', '20', '7', '');
		so.addParam('wmode', 'transparent');
		so.addParam('loop', 'false');
		so.addParam('movie', 'music/xspf/xspf_player_slim2.swf?song_url=radio/'+song+'&song_title='+title+'&autoplay=1&color=000 ');
		so.write(div);
//	}
	/*else{  // flash is too old or we cannot detect the plugin
		var alternateContent = 'Your browser does not support flash';
		document.write(alternateContent);  // insert non-flash content
	}
	*/
}

function displayMedia(id){
	$("#radioplayer").html("");
	$("#radioplayer").css("border", "0");
	if(id=='sidevideos'){
		$("#"+id).css('display','block');
		$("#videotab").css('background-image','url(images/media_tab_01.jpg)');
		$("#phototab").css('background-image','url(images/media_02.jpg)');
		$("#radiotab").css('background-image','url(images/media_03.jpg)');
		$("#sidephotos").css('display','none');
		$("#sideradio").css('display','none');			
	}else if(id=='sidephotos'){				
		$("#"+id).css('display','block');
		$("#videotab").css('background-image','url(images/media_01.jpg)');
		$("#phototab").css('background-image','url(images/media_tab_02.jpg)');
		$("#radiotab").css('background-image','url(images/media_03.jpg)');
		$("#sideradio").css('display','none');
		$("#sidevideos").css('display','none');		
	}else if(id=='sideradio'){			
		$("#"+id).css('display','block');
		$("#videotab").css('background-image','url(images/media_01.jpg)');
		$("#phototab").css('background-image','url(images/media_02.jpg)');
		$("#radiotab").css('background-image','url(images/media_tab_03.jpg)');
		$("#sidephotos").css('display','none');
		$("#sidevideos").css('display','none');	
		
		$('#sideradio').supersleight({shim: 'images/x.gif'});
	}
}

function check_email(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail Address")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail Address")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Invalid E-mail Address")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid E-mail Address")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid E-mail Address")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Invalid E-mail Address")
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    alert("Invalid E-mail Address")
	    return false
	 }

		 return true					
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
