
//for quicktime
/*
function createAudioPlayers(){
	jQuery(function($){
		$('a[href$=.mp3]').each(function(){
			$(this).before("<embed src='"+this.href+"' width='134' height='16' type='audio/mpeg' kioskmode='true' autoplay='false' style='marginRight:0.5em' />&nbsp;")
		})
	})
}
*/
//dewplayer
/*
function createAudioPlayers(){
	jQuery(function($){
		$('a[href$=.mp3]').each(function(){
			$(this).before('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="200" height="20" id="dewplayer" align="middle"><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/includes/dewplayer.swf?mp3='+this.href+'&amp;showtime=1" /><param name="quality" value="high" /><param name="bgcolor" value="FFFFFF" /><embed src="/includes/dewplayer.swf?mp3='+this.href+'&amp;showtime=1" quality="high" bgcolor="FFFFFF" width="200" height="20" name="dewplayer" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>')
		})
	})
}
*/
function validateDependent(){
	message = "";
	status = true;
	if (document.dependent.firstname.value == ""){
		status = false;
		message = message + "Firstname cannot be blank \n";
	}
	if (document.dependent.lastname.value == ""){
		status = false;
		message = message + "Lastname cannot be blank \n";
	}
	month = document.dependent.month.value;
	day = document.dependent.day.value;
	year = document.dependent.year.value;
	if (month == 0 || month > 12 || day == 0 || day > 31 || year < 1900 || year == "" || month == "" || day == ""){
		status = false;
		message = message + "Invalid birthdate \n";
	}
	insnum = document.dependent.insnum.value;
	insnuml = insnum.length;
	if (document.dependent.instype_id.value == 3 && insnuml != 9){
		status = false;
		message = message + "Insurance number not correct length\n\tDMBA 9 digits\n\tAltius 11 digits\n\tCash 0 digits";
	}
	if (document.dependent.instype_id.value == 4 && insnuml != 11){
		status = false;
		message = message + "Insurance number not correct length\n\tDMBA 9 digits\n\tAltius 11 digits\n\tCash 0 digits";
	}
	if (document.dependent.instype_id.value == 5 && insnuml != 0){
		status = false;
		message = message + "Insurance number not correct length\n\tDMBA 9 digits\n\tAltius 11 digits\n\tCash 0 digits";
	}
	if ((status == false) && (message != "")){
		alert(message);
		return false;
	}
	else{
		return true;
	}
}
/**
 * KEEP EMPLOYEES FROM DELETING SENSITIVE ITEMS
 *
**/
function cdel(allowed){
	if (allowed){
		yesno = confirm('Are you sure you want to delete this item?')
		if (yesno){
			return true
		}
		else{
			return false
		}
	}
	else{
		alert('Please ask webmaster to delete this item')
		return false
	}
}

function showHide(id){
		n = document.getElementById(id);
		//alert(n.style['display'])
		if (n.style['display'] == 'none')
			n.style['display'] = 'block'
		else
			n.style['display'] = 'none'
		return false
}
function clearLogin(){
	bbl = document.getElementById('ByuBarLogin');
	//alert('hey');
	document.routeYLoginByuBar.action = 'https://wellness.byu.edu/login.php';
	//bbl.innerHTML = '';
}
function fillLogin(){
	bbl = document.getElementById('ByuBarLogin');
	content = '<form action="https://wellness.byu.edu/login.php" method="post" name="routeYLoginByuBar">';
	content += '<table cellpadding="0" cellspacing="0" border="0" align="right">';
	content += '<tr>';
	//bbl.innerHTML = content;
	content += '<td class="loginPrompt"><b>Route Y</b> Secure Sign In</a></td>';
	content += '<td><label accesskey="n" for="User_">Net ID</label></td>';
	content += '<td><input type="text" name="netID" id="User_" title="Route Y Net ID" class="ByuBarTextBox" tabindex="1" /></td>';
	content += '<td><label accesskey="p" for="Password_">Password</label></td>';
	content += '<td><input type="password" name="pass" id="Password_" title="Route Y Password" class="ByuBarTextBox" tabindex="2" /></td>';
	//content += '<td><input type="image" tabindex="3" src="collage/images/buttonUp.gif" class="goButton" onmousedown="this.src=\'collage/images/buttonDown.gif\';" onmouseout="this.src=\'collage/images/buttonUp.gif\';" /></td>';
	content += '<td><input type="image" tabindex="3" src="collage/images/buttonUp.gif" class="goButton" /></td>';
	content += '</tr>';
	content += '</table>';
	content += '</form>';
	//alert(content);
	//bbl.innerHTML = 'LOGIN';
	//bbl.innerHTML = content;
}
var async = new Asynchronous();
/*
async.complete = function(status, statusText, responseText, responseXML) {
	document.getElementById("weather-information").innerHTML = responseText;
}
*/
function adminAjax(vals) {
	url = "ajax.php";
	if (vals != ""){
		url += "?";
		url += vals;
		url += "&end=true";
	}
	//alert(url);
	async.get(url);
	//async.get("weatherData.php?user_id=1&schedule_id=297&signup_id=8821&action=delete_registrant&end=true");
	//async.get("weatherData.php");
}

/*
    Copyright 2006 Christian Gross http://www.devspace.com
    From the book Ajax Patterns and Best Practices

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
function Asynchronous( ) {
    this._xmlhttp = new FactoryXMLHttpRequest();
    this.username = null;
    this.password = null;
}

function Asynchronous_call( action, url, data) {
	url = this.noCacheIE(url);
    var instance = this;
    this._xmlhttp.open( action, url, true, this.username, this.password);
    this.openCallback( this._xmlhttp);
    this._xmlhttp.onreadystatechange = function() {
        switch( instance._xmlhttp.readyState) {
        case 1:
            instance.loading();
            break;
        case 2:
            instance.loaded();
            break;
        case 3:
            instance.interactive();
            break;
        case 4:
            if( instance.complete) {
                try {
                    instance.complete(instance._xmlhttp.status, instance._xmlhttp.statusText,
                            instance._xmlhttp.responseText, instance._xmlhttp.responseXML);
                }
                catch (e) {
                }
            }
            break;
        }
    }
    try {
        this._xmlhttp.send( data);
    }
    catch( e) {
    }
}

function Asynchronous_get( url) {
    this.call( "GET", url, null);
}

function Asynchronous_noCacheIE( url ) {
	return url + '?noCacheIE=' + (new Date()).getTime();	
}

function Asynchronous_put( url, mimetype, datalength, data) {
    this.openCallback = function( xmlhttp) {
        xmlhttp.setRequestHeader( "Content-type", mimetype);
        xmlhttp.setRequestHeader( "Content-Length", datalength);
    }
    this.call( "PUT", url, data);
}

function Asynchronous_delete( url) {
    this.call( "DELETE", url, null);
}

function Asynchronous_post( url, mimetype, datalength, data) {
    var thisReference = this;
    this.userOpenCallback = this.openCallback;
    this.openCallback = function( xmlhttp) {
        xmlhttp.setRequestHeader( "Content-type", mimetype);
        xmlhttp.setRequestHeader( "Content-Length", datalength);
        thisReference.userOpenCallback( xmlhttp);
        thisReference.openCallback = thisReference.userOpenCallback;
    }
    this.call( "POST", url, data);
}

function Asynchronous_openCallback( obj) { 
}
function Asynchronous_loading() {
}
function Asynchronous_loaded() {
}
function Asynchronous_interactive() {
}
function Asynchronous_complete( status, statusText, responseText, responseHTML) {
}

Asynchronous.prototype.openCallback = Asynchronous_openCallback;
Asynchronous.prototype.loading = Asynchronous_loading;
Asynchronous.prototype.loaded = Asynchronous_loaded;
Asynchronous.prototype.interactive = Asynchronous_interactive;
Asynchronous.prototype.complete = Asynchronous_complete;
Asynchronous.prototype.get = Asynchronous_get;
Asynchronous.prototype.put = Asynchronous_put;
Asynchronous.prototype.del = Asynchronous_delete;
Asynchronous.prototype.post = Asynchronous_post;

Asynchronous.prototype.noCacheIE = Asynchronous_noCacheIE;

Asynchronous.prototype.call = Asynchronous_call;

/*
    Copyright 2006 Christian Gross http://www.devspace.com
    From the book Ajax Patterns and Best Practices

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
function FactoryXMLHttpRequest() {
    if( window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
    else if( window.ActiveXObject) {
        var msxmls = new Array(
            'Msxml2.XMLHTTP.5.0',
            'Msxml2.XMLHTTP.4.0',
            'Msxml2.XMLHTTP.3.0',
            'Msxml2.XMLHTTP',
            'Microsoft.XMLHTTP');
        for (var i = 0; i < msxmls.length; i++) {
            try {
                return new ActiveXObject(msxmls[i]);
            } catch (e) {
            }
        }
    }
    throw new Error( "Could not instantiate factory");
}


