function input_events_go(focus_elem,textfield_class_name, textarea_class_name, control_popup)
	{
	var elem_arr = new Array();
	input_events_focused = new Array();
	input_events_mouseover = new Array();
	input_events_popup_class = new Array();
	
	input_events_existing_blur = new Array();
	input_events_existing_focus = new Array();
	
	//textfield
	if (textfield_class_name)
		{elem_arr = input_events_get_elements(document, 'input', textfield_class_name);
		
		for (var i = 0;i < elem_arr.length;i++)
			{
			elem_arr[i].onmouseover = function() {input_events_action(this, 'mouse_over',textfield_class_name + '_focus',textfield_class_name + '_error');}
			elem_arr[i].onmouseout = function() {input_events_action(this, 'mouse_out',textfield_class_name,textfield_class_name + '_error',textfield_class_name + '_error');}
			elem_arr[i].onchange = function() {input_events_action(this, 'keypress',textfield_class_name + '_focus',textfield_class_name + '_error');}
			
			var tmp = String(elem_arr[i].getAttribute("onfocus"));
			///////////////////////
			//fukin IE fix
			tmp = tmp.replace("function anonymous()\n{","");
			tmp = tmp.replace("\n}","");
			///////////////////////			
			input_events_existing_focus[elem_arr[i].id] = tmp;
			
			elem_arr[i].onfocus = function() {input_events_action(this, 'focus',textfield_class_name + '_focus',textfield_class_name + '_error');}
			
			var tmp = String(elem_arr[i].getAttribute("onblur"));
			///////////////////////
			//fukin IE fix
			tmp = tmp.replace("function anonymous()\n{","");
			tmp = tmp.replace("\n}","");
			///////////////////////			
			input_events_existing_blur[elem_arr[i].id] = tmp;
			
			elem_arr[i].onblur = function() {input_events_action(this, 'blur',textfield_class_name,textfield_class_name + '_error');}
			
			if (control_popup)
				{var tmp_id_popup = elem_arr[i].id + "_popup";
				if (document.getElementById(tmp_id_popup))
					{input_events_popup_class[tmp_id_popup] = new popup_object(tmp_id_popup);}
				}
			}
		}
	
	//textarea
	if (textarea_class_name)
		{elem_arr = input_events_get_elements(document, 'textarea', textarea_class_name);
		
		for (var i = 0;i < elem_arr.length;i++)
			{elem_arr[i].onmouseover = function() {input_events_action(this, 'mouse_over',textarea_class_name + '_focus',textarea_class_name + '_error');}
			elem_arr[i].onmouseout = function() {input_events_action(this, 'mouse_out',textarea_class_name,textarea_class_name + '_error',textarea_class_name + '_error');}
			elem_arr[i].onkeypress = function() {input_events_action(this, 'keypress',textarea_class_name + '_focus',textarea_class_name + '_error');}
			elem_arr[i].onfocus = function() {input_events_action(this, 'focus',textarea_class_name + '_focus',textarea_class_name + '_error');}
			elem_arr[i].onblur = function() {input_events_action(this, 'blur',textarea_class_name,textarea_class_name + '_error');}
			
			if (control_popup)
				{var tmp_id_popup = elem_arr[i].id + "_popup";
				if (document.getElementById(tmp_id_popup))
					{input_events_popup_class[tmp_id_popup] = new popup_object(tmp_id_popup);}
				}
			}
		}
	
	if (focus_elem)
		{document.getElementById(focus_elem).focus();}
	}

//////////////////////////////////

function input_events_action(input_obj,action_type,new_class_name,error_class)
	{
	var tmp_id = input_obj.id;
	
	switch (action_type)
		{case "mouse_over": 
			if (input_obj.className == error_class) {return 0;}
			input_obj.className = new_class_name;
			input_events_mouseover[tmp_id] = true;
		break;
		case "mouse_out":
			if (input_obj.className == error_class) {return 0;}
			if (!input_events_focused[tmp_id])
				{input_obj.className = new_class_name;}
			input_events_mouseover[tmp_id] = false;
		break;
		case "keypress": 
			if (input_obj.className == error_class)
				{input_obj.className = new_class_name;
				input_events_msg_control(tmp_id,'','',false,'error');
				}
		break;
		case "focus":
			//popup control
			var tmp_id_popup = tmp_id + "_popup";
			if (input_events_popup_class[tmp_id_popup])
				{input_events_popup_class[tmp_id_popup].fade_in();}
			
			//bg change
			if (input_obj.className == error_class) {return 0;}
			input_events_focused[tmp_id] = true;
			input_obj.className = new_class_name;
			
			//existing focus
			if (input_events_existing_focus[tmp_id])
				{eval(input_events_existing_focus[tmp_id]);}
		break;
		case "blur":
			//popup control
			var tmp_id_popup = tmp_id + "_popup";
			if (input_events_popup_class[tmp_id_popup])
				{input_events_popup_class[tmp_id_popup].fade_out();}
			
			//bg change
			if (input_obj.className == error_class) {return 0;}
			if (!input_events_mouseover[tmp_id])
				{input_obj.className = new_class_name;}
			input_events_focused[tmp_id] = false;
			
			//existing blur
			if (input_events_existing_blur[tmp_id])
				{eval(input_events_existing_blur[tmp_id]);}
		break;
		}
	}

function input_events_get_elements(elm, tag_name, class_name)
	{
	var arr_elem = new Array();
	if (tag_name == "*" && document.all)
		{arr_elem = document.all;}
	else
		{arr_elem = elm.getElementsByTagName(tag_name);}
	
	var arr_output = new Array();
	class_name = class_name.replace(/\-/g, "\\-");
	
	var oRegExp = new RegExp("(^|\\s)" + class_name + "(\\s|$)");
	
	var new_elm;
	for (var i = 0;i < arr_elem.length;i++)
		{new_elm = arr_elem[i];
		if(oRegExp.test(new_elm.className))
			{arr_output.push(new_elm);}
		}
	return arr_output;
	}

function input_events_msg_control(input_id,error_class,msg,do_open,msg_state,is_top_space)
	{var div_obj = document.getElementById(input_id + "_msg");
	var inp_obj = document.getElementById(input_id);
	
	var output_txt = '';
	
	if (do_open) 
		{
		if (msg_state == 'error' && error_class)
			{inp_obj.className = error_class;}
		
		output_txt += msg;
		}
	if (div_obj) {div_obj.innerHTML = output_txt;}
	}

//////////////////////////////
// side popup class
function popup_object(popup_obj_id)
	{
	var popup_obj = this.bar_obj = document.getElementById(popup_obj_id);
	var popup_obj_id = popup_obj_id;
	
	var opacity_speed = 10;
	var opacity_step = 5;
	var timer_obj = new Object();

	this.fade_in = function() 
		{clearTimeout(timer_obj);
		this.fade_loop('in');
		}
	this.fade_out = function() 
		{clearTimeout(timer_obj);
		this.fade_loop('out');
		}
	
	set_opacity(0);
	popup_obj.style.display = "none";
	
	this.fade_loop = fade_loop;
	function fade_loop(dir)
		{var curr_opacity = Math.round(Number(popup_obj.style.opacity) * 100);

		switch(dir)
			{case "in": 
				if (popup_obj.style.display == "none")
					{popup_obj.style.display = "block";}
				
				curr_opacity += opacity_step;
				if (curr_opacity >= 100)
					{curr_opacity = 100;
					set_opacity(curr_opacity);
					}
				else
					{this.set_opacity(curr_opacity);
					clearTimeout(timer_obj);
					timer_obj = setTimeout("input_events_popup_class['" + popup_obj_id + "'].fade_loop('in');",opacity_speed);
					}
			break;
			case "out": 
				if (popup_obj.style.display == "none")
					{popup_obj.style.display = "block";}
				
				curr_opacity -= opacity_step;
				if (curr_opacity <= 0)
					{curr_opacity = 0;
					set_opacity(curr_opacity);
					popup_obj.style.display = "none";
					}
				else
					{this.set_opacity(curr_opacity);
					clearTimeout(timer_obj);
					timer_obj = setTimeout("input_events_popup_class['" + popup_obj_id + "'].fade_loop('out');",opacity_speed);
					}
			break;
			}
		}
	
	this.set_opacity = set_opacity;
	function set_opacity(new_value)
		{		
		popup_obj.style.filter = "alpha(opacity=" + new_value + ")";	
		popup_obj.style.MozOpacity = new_value / 100;
		popup_obj.style.opacity = new_value / 100;
		}
	}
	
function clear_field (del_value,input)
	{
		if (input.value==del_value)
			{input.value="";}
	}
function write_field(start_value,input)
	{
		if (input.value=="")
			{input.value=start_value;}
	}
	
function PrintContent() {
		var DocumentContainer = document.getElementById('content_right_layout');
		var WindowObject = window.open('', 'PrintWindow', 'width=750,height=500,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes');
		var strHtml = "<html>\n<head>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"/printwindow.css\">\n</head><body><div style=\"testStyle\">\n"+ DocumentContainer.innerHTML + "\n</div>\n</body>\n</html>";
		WindowObject.document.writeln(strHtml);
		
		//WindowObject.document.close();
		//WindowObject.focus();
		//WindowObject.print();
		//WindowObject.close();
  }
