﻿function checkGroup(className, checked) {
	$$('.'+className+' input[type="checkbox"]').each(function(n) { n.checked = checked; });
}
function formTarget(el,target) {
  el.form.target = target;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function siteSearch(event) {
  if(event.keyCode == Event.KEY_RETURN) {
    Event.stop(event);
    $('goSearch').click();
  }
}
Event.observe(window,'load', function() { Event.observe($('search'),'keypress',siteSearch); },false);

Event.observe(window,'load',automateSWF,false);
function automateSWF() { 
  /*if(navigator.appVersion.match(/\bMSIE\b/) && $$('embed').length > 0) {
    var i = 0;
    $$('embed').each(function(n) {
      var n = $(n);
      source = n.src;
      height = !n.height ? n.getHeight() : n.height;
      width = !n.width ? n.getWidth() : n.width;
      var id = n.src.replace(" ","").replace(".","-") + "-" + i;
      new Insertion.After(n,'<span id="' + id + '">...</span>');
      Element.remove(n);
      so = new SWFObject(source, id, width, height,"6");
      so.write(id);
      i++;
    });
  }*/
}
