function select_set_value (object, value) {
	if (!object.length && object.value==value) object.selected=true;
	for (var i=0; i<object.length; i++) {
		if (object[i].value==value) {
			object[i].selected=true;
			break } } }

function radio_set_value (object, value) {
	if (!object.length && object.value==value) object.checked=true;
	for (var i=0; i<object.length; i++) {
		if (object[i].value==value) {
			object[i].checked=true;
			break;
		}
	}
}

function checkbox_set_value (object, value) {
	if (!value) object.checked=true;
	if (!object.length && object.value==value) object.checked=true;
	for (var i=0; i<object.length; i++) {
		if (object[i].value==value) {
			object[i].checked=true;
		}
	}
}

function checkbox_disabled (object, disabled) {
	if (!value) object.disabled=disabled;
	if (!object.length && object.value==value) object.disabled=disabled;
	for (var i=0; i<object.length; i++) {
		object[i].disabled=disabled;
	}
}

function flash (movie, width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
		+ 'width="' + width + '" ' 
		+ 'height="' + height + '" '
		+ 'codebase="' + location.protocol + '//www.macromedia.com/go/getflashplayer' +'">'
		+ '<param name="movie" value="' + movie + '" />'
		+ '<param name="wmode" value="' + 'transparent' + '" />'
		+ '<embed src="' + movie + '" ' 
		+ 'width="' + width + '" '
		+ 'height="' + height + '" '
		+ 'wmode="' + 'transparent' + '" '
		+ 'type="application/x-shockwave-flash" '
		+ 'pluginspage="' + location.protocol + '//www.macromedia.com/go/getflashplayer' +'">'
		+ '</embed>'
		+ '</object>');
}

/* //////////////////////////////////////////////////////////////////////////////////////
Variables needed:
filepath, width, height, align, pluginspage, name, id, quality, wmode, bgcolor, loop
////////////////////////////////////////////////////////////////////////////////////// */ 
function flash_adv (movie, width, height, align, name, id, quality, wmode, bgcolor, loop){
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
    + 'width="' + width + '" ' 
	+ 'height="' + height + '" '
    + 'codebase="' + location.protocol + '//www.macromedia.com/go/getflashplayer' +'">'
    + '<param name="movie" value="' + movie + '" />'
	+ '<param name="quality" value="' + quality + '" />'
	+ '<param name="wmode" value="' + wmode + '" />'
    + '<param name="bgcolor" value="' + bgcolor + '" />'
	+ '<param name="loop" value="' + loop + '" />'
	+ '<param name="play" value="true" />'
    + '<embed src="' + movie + '" ' 
	+ 'bgcolor="' + bgcolor + '" '
    + 'width="' + width + '" '
	+ 'height="' + height + '" '
    + 'wmode="' + wmode + '" '
	+ 'play="true" '
    + 'loop="' + loop + '" '
    + 'quality="' + quality + '" '
    + 'allowScriptAccess="sameDomain" '
    + 'type="application/x-shockwave-flash" '
    + 'pluginspage="' + location.protocol + '//www.macromedia.com/go/getflashplayer' +'">'
    + '<\/embed>'
    + '<\/object>');
}

function window_pop_up (location, name, width, height) {

	winPop = window.open(location, name, 'width=' + width + ', height=' + height + ', toolbar=0, resizable=0, status=0');

	winPop.focus();

}

function setCookie(name, value, expire) {
          document.cookie = name + "=" + escape(value)
          + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function getCookie(Name) {
          var search = Name + "="
          if (document.cookie.length > 0) { // if there are any cookies
                    offset = document.cookie.indexOf(search)
                    if (offset != -1) { // if cookie exists
                              offset += search.length
                              // set index of beginning of value
                              end = document.cookie.indexOf(";", offset)
                              // set index of end of cookie value
                              if (end == -1)
                                        end = document.cookie.length
                              return unescape(document.cookie.substring(offset, end))
                    }
          }
}

function jump_select( select ) {
    if (select.options[select.selectedIndex].value != '') { 
        window.location = select.options[select.selectedIndex].value;
    }
}

function toggleItem(id)
{
    itm = document.getElementById(id);

    if(!itm)
    {
        return false;
    }

    if(itm.style.display == 'none')
        itm.style.display = '';
    else
        itm.style.display = 'none';
    
    return false;
}

function changeTab(anchor){
    
    var tabbox = anchor;
    var target;

    while(tabbox != null && (tabbox.className == null || tabbox.className.indexOf("tabbox") == -1)){
        tabbox = tabbox.parentNode;

        if(tabbox.className.indexOf("tabname") != -1)
        {
            target = tabbox.parentNode;
        }
    }
    if(tabbox == null || target == null){
        return false;
    }
                
    
    var tag;
    for(var i = 0; i < tabbox.childNodes.length; i++){
        tag = tabbox.childNodes[i];
        
        if(tag.nodeName.toLowerCase() == "div" && tag.className != null && tag.className.indexOf("selected") > -1){
            tag.className = tag.className.replace("selected", "");
            break;
        }
    }
    
    if(target != null){
        target.className = (target.className || "") +" selected";
    }
    
    return false;
}

function getElementsByClass(searchClass,node,tag) {
    var classElements = new Array();
    if ( node == null )
        node = document;
    if ( tag == null )
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
    for (i = 0, j = 0; i < elsLen; i++) {
        if ( pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}

function include_dom() {
    var args = Array.prototype.slice.apply(arguments);
    var script_filename = args[0];

    if( args.length > 1 ) {
        include_queue_add.apply( null, args );
    }

    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.language = 'javascript';
    js.type = 'text/javascript';
    js.src = script_filename;

    html_doc.appendChild(js);

    js.onload = function() { // Firefox
        var script = included_files[include_queue_find(script_filename)];
        script.loaded = true;
        include_queue_run( script_filename );
    }

    js.onreadystatechange = function () { // IE
        if ( (js.readyState == 'complete') || (js.readyState == 'loaded')) {
            var script = included_files[include_queue_find(script_filename)];
            script.loaded = true;
            include_queue_run( script_filename );
        }
    }

    return false;
}

function include_once() {
    var args = Array.prototype.slice.apply(arguments);
    var script_filename = args[0];
    var script = included_files[include_queue_find(script_filename)];

    if( ! script ) {
        var script = new Object;
        script.filename = script_filename;
        script.queue = new Array();
        script.loaded = false;

        included_files[included_files.length] = script;
        include_queue_add.apply(null,args);
        include_dom(script_filename);
    }
    else {
        if( script.loaded ) {
            args[1].apply( null, args.slice(2) );
        }
        else {
            include_queue_add.apply(null,args);
        }
    }

}

var included_files = new Array();

function include_queue_add() {
    var args = Array.prototype.slice.apply(arguments);
    var script_filename = args[0];

    if( args.length ) {

        var script = included_files[include_queue_find(script_filename)];

        var funcs = script.queue;

        funcs.push( args.slice(1) );
    }

}
    
function include_queue_run(script_filename) {

    var script = included_files[include_queue_find(script_filename)];

    var funcs = script.queue;

    while( funcs.length ) {
        var func_call;
        func_call = funcs.pop(); // Funcs is an array of arrays, func_pointer followed by arguments for each entry
        var func = func_call[0];
        var args = func_call.slice(1);

        func.apply( null, func_call.slice(1) )
    }

}

function include_queue_find( script_filename ) {
    for (var i = 0; i < included_files.length; i++) {
        if (included_files[i].filename == script_filename) {
            return i;
        }
    }
    return false;
}


var flash_inc = 0;

function flash_rep( movie, width, height )
{

    flash_inc = flash_inc + 1;
    var span_id = 'flash-' + flash_inc;
    document.write(
        '<span align="center" id="' + span_id + '" style="visibility:hidden" width="' + width + '" height:"' + height + '"></span>' );

    include_once('js/swfobject.js',
        function () {
            var span = document.getElementById(span_id);
            span.style.visibility = 'visible';

            var so = new SWFObject(movie, span_id, width, height, '8');
            so.write(span_id);

            if( (span_id == "flash-1") && !(so.installedVer.major >= 8) ) {
                var body = document.getElementsByTagName("body")[0];

                var div = document.createElement('div');
                div.style.backgroundColor = '#FFFFE1';
                div.style.borderBottomStyle = 'ridge';
                div.style.fontFamily = 'Tahoma, sans-serif';
                div.style.fontSize = '9pt';

                div.innerHTML = '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"> <img src="//www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="" border="0" align="left" style="padding: 7px"></a>' +
'<div style="padding: 7px;"> This site requires the latest <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" style="font-weight: bold;">Adobe Flash plug-in. </a> <br /> Please ensure that you have the latest latest Adobe Flash plug-in. <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" style="font-weight: bold;">Download here.</a> </div>'

                body.insertBefore( div, body.firstChild );
            }
        } );
}

