// JavaScript Document

// http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
// end http://www.quirksmode.org/js/cookies.html


function ua_default_font_size(){
	textsizeobj = readCookie( 'ua_font_size' );
	if( textsizeobj == null ){
		textsizeobj = 'text_sm'
	}
	textsizeobj = document.getElementById( textsizeobj );
	ua_font_size( textsizeobj );
}



function ua_font_size( textsizeobj ){
	
	if( !textsizeobj ){
		var size = '0.625em';
	}else{
		if(textsizeobj.id == 'text_sm'){
			var size = '0.625em';
		}else if(textsizeobj.id == 'text_m'){
			var size = '0.75em';
		}else if(textsizeobj.id == 'text_lg'){
			var size = '0.875em';
		}
	}
	
  document.body.style.fontSize = size;
	var children = textsizeobj.parentNode.childNodes;
	for ( var i in children ){
    children[i].className = '';
	}
	textsizeobj.className = 'current';
	
	createCookie( 'ua_font_size', textsizeobj.id, 60 );
	//console.log( readCookie( 'ua_font_size' ) );
}


function ua_active_field( obj, val, objclass ){
	//console.log('obj ' + obj);
	//console.log('val ' + val);
	//console.log('objclass ' + objclass);
		if( obj.value == val ){
			obj.className = objclass;
			obj.value = '';
		}
}

function ua_default_field( obj, val, objclass ){
		if( obj.value == '' ){
			obj.className = objclass + ' default';
			obj.value = val;
		}
}

function ua_read_more_appear_toggle( this_obj, target_obj ){
	if( this_obj.className == 'show_more_open' ){
		this_obj.className = 'show_more_closed';
	}else if(this_obj.className == 'show_more_closed'){
		this_obj.className = 'show_more_open';
	}
	
	Effect.toggle( target_obj, 'appear', { duration: 0.25 });
}

function ua_read_more_appear_toggle_query( this_obj, target_obj ){
	if( this_obj.className == 'show_more_open' ){
		this_obj.className = 'show_more_closed';
	}else if(this_obj.className == 'show_more_closed'){
		this_obj.className = 'show_more_open';
	}
	
	jQuery('#'+target_obj).toggle();
	
	//Effect.toggle( target_obj, 'appear', { duration: 0.25 });
}



function by_name_or_by_subject( obj_id ){
	if( obj_id == 'name' ){
		other_id = 'subject';
	}else{
		other_id = 'name';
	}
	id_div = obj_id + '_div';
	other_div = other_id + '_div';
	document.getElementById( obj_id ).className = "current";
	document.getElementById( id_div ).style.display = "block";
	document.getElementById( other_id ).className = "";
	document.getElementById( other_div ).style.display = "none";
}


