
/**
 *	@package Output
 */

var _o1t_page_contentArea = document.getElementById('page_contentArea');

if ( ! o1t_webdir_pics) {
	var o1t_webdir_pics = 'http://localhost/_gfx/'; // String
}
if ( ! o1t_webdir_component) {
	var o1t_webdir_component = 'http://localhost/xxphpxx/s12n/s5l/component/'; // String
}

function o1t_innerHTML(element, toValue) {
		
	if (typeof(element.innerHTML) != 'undefined') {
		 element.innerHTML = toValue;
	} else {
				
		var range = document.createRange();
		range.selectNodeContents(element);
		range.deleteContents();
		element.appendChild(range.createContextualFragment(toValue));
	}
}

function o1t_outerHTML(_object) {

	if ( ! _object) {
		return null;
	}

	var element = document.createElement('div');

	element.appendChild(_object.cloneNode(true));
	
    return element.innerHTML;
}

function o1t_arearizeContent(code) {

	if ( ! _o1t_page_contentArea) {
		_o1t_page_contentArea = document.getElementById('page_contentArea');
	}

	_o1t_page_contentArea.innerHTML = code;		
}

function o1t_createCase(code, padding, pic, color, fontColor, fontWeight, addyStyle, addyAttribute) {
	
	if ( ! color) {
		color = '#ffffff';	
	}
	if ( ! fontColor) {
		fontColor = '#000000';	
	}
	if ( ! fontWeight) {
		fontWeight = 'normal';	
	}
	if ( ! addyStyle) {
		addyStyle = '';	
	}
	if ( ! addyAttribute) {
		addyAttribute = '';		
	}
	
	caseCode = '';
	
	if (pic) {
	
		picCode = '';
		picCode += '<table cellspacing="0" cellpadding="0">';
		picCode += '<tr>';
		picCode += '<td>'+pic+'</td>';
		picCode += '<td width="5" nowrap></td>';
		picCode += '<td style="color: '+fontColor+'; font-weight: '+fontWeight+';">'+code+'</td>';
		picCode += '</tr>';
		picCode += '</table>';
		
		code = picCode;
	}

	caseCode += '<table cellspacing="0" cellpadding="0" style="background: '+color+'; color: '+fontColor+';'+addyStyle+'" '+addyAttribute+'>';
	caseCode += '<tr>';
	caseCode += '<td width="6" height="6" background="'+o1t_webdir_component+'case/gfx/box_top_left.bmp" nowrap></td>';
	caseCode += '<td height="6" background="'+o1t_webdir_component+'case/gfx/box_top_middle.bmp" nowrap></td>';
	caseCode += '<td width="6" height="6" background="'+o1t_webdir_component+'case/gfx/box_top_right.bmp" nowrap></td>';
	caseCode += '</tr>';
	caseCode += '<tr>';
	caseCode += '<td width="6" height="6" background="'+o1t_webdir_component+'case/gfx/box_middle_left.bmp" nowrap></td>';
	caseCode += '<td height="6" style="padding: '+padding+'px; background: '+color+'; color: '+fontColor+'; font-weight: '+fontWeight+';" nowrap>';
	caseCode += code;
	caseCode += '<td width="6" height="6" background="'+o1t_webdir_component+'case/gfx/box_middle_right.bmp" nowrap></td>';
	caseCode += '</tr>';
	caseCode += '<tr>';
	caseCode += '<td width="6" height="6" background="'+o1t_webdir_component+'case/gfx/box_bottom_left.bmp" nowrap></td>';
	caseCode += '<td height="6" background="'+o1t_webdir_component+'case/gfx/box_bottom_middle.bmp" nowrap></td>';
	caseCode += '<td width="6" height="6" background="'+o1t_webdir_component+'case/gfx/box_bottom_right.bmp" nowrap></td>';
	caseCode += '</tr>';
	caseCode += '</table>';
	
	return caseCode;
}

function o1t_createLoading(perCent) {
	
	code = '';
	table = '';
	
	code += '<table cellspacing="0" cellpadding="0" border="0">';
	code += '<tr>';
	code += '<td><img src="'+o1t_webdir_component+'loading/gfx/loading.gif" /></td>';
	code += '<td width="10" nowrap></td>';
	code += '<td>';
	code += '<table cellspacing="0" cellpadding="0">';
	code += '<tr>';
	code += '<td style="font-family: Verdana; font-size: 14px;">Loading</td>';
	code += '</tr>';
	code += '<tr>';
	code += '<td style="font-family: Verdana; font-size: 10px; text-align: center; font-weight: bold;">'+perCent+' %</td>';
	code += '</tr>';
	code += '</table>';
	code += '</tr>';
	code += '</table>';
	
	return '<br/><br/><center>'+o1t_createCase(code)+'</center>';
}

/////////////////////// Icon Line Element

var o1t_iconLineElement_BlockElement = new Array();

/**
 * @desc Creates a straight Line of selected Icons (if select 4 than 1-4 are selected others not)  
 * @used r4g 
 * @param Integer numStop (How many Icons at position?)
 * @param Integer numAll (How many Icons at all?)
 * @param String urlPrefix (Which URL should be linked?)
 * @param String selectedIcon (How looks the Icon for selection?)
 * @param String unselectedIcon (How looks the Icon for non selection?)
 * @param String actualIcon (How looks the Icon for actual Element?)
 * @param Boolean changeMode (Should the Icons be edited?)
 * @param Array TextContent (Which Step is which content?)
 * @param String id_content_div (Which ID has the Content DIV Element?)
 * @return Boolean (Successful?)
 */
function o1t_createIconLineElement(numStop, numAll, iconPrefix, urlPrefix, selectedIcon, actualIcon, unselectedIcon, changeMode, TextContent, id_content_div) {  

	if (o1t_iconLineElement_BlockElement.length > 0) {

		for (var i=0; i<o1t_iconLineElement_BlockElement.length; i++) {
			if (o1t_iconLineElement_BlockElement[i] == id_content_div) {
				return false;
			}
		}
	}
	
	if ( ! changeMode) {
		return false;
	}
	
	var icon = null;
	var _icon = null;
	
	for (var i=1; i<=numAll; i++) {
		
		if (i < numStop) {
			icon = selectedIcon;
		}
		else if (i == numStop) {
			icon = actualIcon;
		}
		else {
			icon = unselectedIcon;
		}
		
		_icon = document.getElementById(iconPrefix+i);
		_icon.style.cursor = 'pointer';
		_icon.src = o1t_webdir_pics+icon;
	}
	
	if (TextContent[numStop]) {
		o1t_innerHTML(document.getElementById(id_content_div), TextContent[numStop]);
	}
	
	return true;
}
/**
 * @desc Sends AJAX Request and selects Icon Line Element
 * @param Integer id_content_div
 * @param String scriptUrl
 * @param String scriptParams
 * @param String successMessage
 * @return Boolean
 */
function o1t_selectIconLineElement(id_content_div, scriptUrl, scriptParams, successMessage) { 

	var _div = document.getElementById(id_content_div);
	var response = a2x_sendRequest(scriptUrl, scriptParams);
	
	if (response == 1) {
		o1t_innerHTML(_div, successMessage);
		o1t_iconLineElement_BlockElement[o1t_iconLineElement_BlockElement.length] = id_content_div;
	}
	else {
		o1t_innerHTML(_div, response);
	}
}

/**
 *	Zooming 
 ********************************
 *	@package Viewer
 *	@area Input
 */
  
/**
 *	@type base
 *	@access private
 */
function v4r_i3t_zoom(id_textarea, id_font_size, mode) {
 	
 	var regex = /(\d\d)/;
 	var _ = document.getElementById(id_textarea);
 	var size = null;

 	if (regex.exec(_.style.fontSize)) {
 		size = regex.exec(_.style.fontSize)[1];
 	} else {
 		size = 4;
 	}
 	
 	if (mode == 1) {
 		size++;
 	}
 	else {
 		size--;	
 	}
 	
 	_.style.fontSize = size+'px';
 	
 	v4r_i3t_font_size(id_textarea, id_font_size);
}
/**
 *	@type executor
 *	@access public
 */
function v4r_i3t_zoom_plus(id_textarea, id_font_size) {
 	
 	v4r_i3t_zoom(id_textarea, id_font_size, 1);	
}
/**
 *	@type executor
 *	@access public
 */
function v4r_i3t_zoom_minus(id_textarea, id_font_size) {
 	
	v4r_i3t_zoom(id_textarea, id_font_size, 2);	
}
 
/**
 *	Numerizing
 ********************************
 *	@package Viewer
 *	@area Input
 */
 
 /**
 *	@access public
 *	@param String id_num
 *	@param Element _text
 */
function v4r_i3t_num(id_num, _text) {
	
	document.getElementById(id_num).value = _text.value.length;
}

/**
 *	Font
 ********************************
 *	@package Viewer
 *	@area Input
 */
 
 /**
 *	@access public
 *	@param String id_textarea
 *	@param Element _select
 */
function v4r_i3t_font_family(id_textarea, _select) {
	
	var _textarea = document.getElementById(id_textarea);
	
	_textarea.style.fontFamily = _select.value;
}

/**
 *	@access public
 *	@param String id_textarea
 *	@param String id_font_size
 */
function v4r_i3t_font_size(id_textarea, id_font_size) {
	
	var _textarea = document.getElementById(id_textarea);
	var _size = document.getElementById(id_font_size);
	var regex = /(\d\d)/;
	
 	if (regex.exec(_textarea.style.fontSize)) {
 		size = regex.exec(_textarea.style.fontSize)[1];
 	}
	
	_size.value = size;
}

/////////////////////////////////////////////////////////////////////////////

/**
 *	@subpackage MouseMenu
 */

var o1t_m7u_selection = null;

var o1t_m7u_Parent = new Array();
var o1t_m7u_Child = new Array();

function o1t_m7u_setSelection(type, id) {
	
	var _selection = new Object();
	_selection.type = type;
	_selection.id = id;
	
	var _o1t_m7u_selection = _selection;
}

function o1t_m7u_addParent(link, value) {
		
	var id = (o1t_m7u_Parent.length+1);
		
	var _parent = new Object();
	_parent.id = id;
	_parent.parentLink = link;
	_parent.parentValue = value;
	
	o1t_m7u_Parent[id] = _parent;
}

function o1t_m7e_addChild(parent, link, value) {
	
	var id = (o1t_m7u_Child.length+1);
	
	var _child = new Object();
	_child.parentID = parent;
	_child.childLink = link;
	_child.childValue = value;
	
	o1t_m7u_Child[id] = _child;
}

/** Tab Area **/

function o1t_tab_changeTabActivation(table_id, mode) {

    var _table = document.getElementById(table_id);
    var TableCell = _table.getElementsByTagName('td');
    var background = null;

    for (var i = 0; i < TableCell.length; i++) {
      background = TableCell[i].getAttribute('background');

      if (mode == 1) {
        background = background.replace('marked', 'selected');
        if (TableCell[i].width == 8) {
          TableCell[i].width = 9;
        }
      }
      else if (mode == 2) {
        background = background.replace('selected', 'marked');
      }
      TableCell[i].setAttribute('background', background);
    }
}

function o1t_tab_selectTab(table_id) {

  return o1t_tab_changeTabActivation(table_id, 1);
}
function o1t_tab_deselectTab(table_id) {

  return o1t_tab_changeTabActivation(table_id, 2);
}

var rowBorder = false;

function SetBgColor(thisRow, thisAction, thisColor, thisHREF) { 
	var thePointerColor = '#fedc8d';
	
	if (thisColor == '') {
		thisColor = thePointerColor;
	}
	
	if (thisAction == 'href') {

		if (thisHREF != '') {
			top.location.href=thisHREF;
			return true;
		} 
		
		return false;
	}
	
	if (thisAction == 'href_this') {

		if (thisHREF != '') {

			this.location.href=thisHREF;
			return true;
		}
		
		return false;
	}

	if (thisAction == 'over') {

		var col = thisRow.getElementsByTagName('td');
		
		for (c = 0; c < col.length; c++) {
			
			if (rowBorder == true) {

				col[c].style.borderTop = '1px #000000 solid';
				col[c].style.borderBottom = '1px #000000 solid';
				
				if (c == 0) {
					col[c].style.borderLeft = '1px #000000 solid';
				} else if (c == col.length-1) {
					col[c].style.borderRight = '1px #000000 solid';
				}
			}
			
			col[c].style.backgroundColor = thisColor;
		}
	}

	if (thisAction == 'out') {

		var col = thisRow.getElementsByTagName('td');

		for (c = 0; c < col.length; c++) {
			
			if (rowBorder == true) {
				col[c].style.borderTop = '1px #ffffff solid';
				col[c].style.borderBottom = '1px #ffffff solid';
			
				if (c == 0) {
					col[c].style.borderLeft = '1px #ffffff solid';
				} else if (c == col.length-1) {
					col[c].style.borderRight = '1px #ffffff solid';
				}
			}
			
			col[c].style.backgroundColor = '';
		}
	}

   	return true;
}

/**
 *	o1t_locate
 *
 *	@desc	Finds the absolute position of one html element
 */
function o1t_locate(element) { 

	var elem=element,tagname="",x=0,y=0;
	
	/* solange elem ein Objekt ist und die Eigenschaft offsetTop enthaelt
	wird diese Schleife fuer das Element und all seine Offset-Eltern ausgefuehrt */
	while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))
	{
		y+=elem.offsetTop;     /* Offset des jeweiligen Elements addieren */
		x+=elem.offsetLeft;    /* Offset des jeweiligen Elements addieren */
		tagname=elem.tagName.toUpperCase(); /* tag-Name ermitteln, Grossbuchstaben */
		
		/* wenn beim Body-tag angekommen elem fuer Abbruch auf 0 setzen */
		if (tagname=="BODY")
		  	elem=0;
		
		/* wenn elem ein Objekt ist und offsetParent enthaelt
		Offset-Elternelement ermitteln */
		if (typeof(elem)=="object")
			if (typeof(elem.offsetParent)=="object")
		    		elem=elem.offsetParent;
	}
	
	position = new Object();
	position.x = x;
	position.y = y;
	
	return position;
}

function o1t_fill_count_sign(id_number, _input, type, maxLength) {
	
	var actualInputLength = _input.value.length;
	var insertNumberValue = null;
	var _number = document.getElementById(id_number);
	
	// Substrate
	if (type == 1) {
		insertNumberValue = maxLength-actualInputLength;
	}
	// 
	else {
		insertNumberValue = actualInputLength;
	}

	_number.innerHTML = insertNumberValue;
}
	
function o1t_i7y_setHop(id, value) {

	var regex_number = /\d/;

	var _arrow = document.getElementById(id+'_div');
	var _table = document.getElementById(id);
	var Cell = _table.getElementsByTagName('td');
	
	var _cell = null;
	var _position = null;
	
	var step = 0;
	if (regex_number.exec(value)) {
		step++;
	}
	if (value.length > 6) {
		step++;	
	}
	if (value.length > 10) {
		step++;
	}
	
	_cell = Cell[step];
	_position = o1t_locate(_cell);
	_arrow.style.left = _position.x+5;		
	_arrow.style.top = _position.y+5;
}

function o1t_checkAll(formName, checked) {
	
	var Input = document.getElementsByTagName('input');

	for (var i=0; i<Input.length; i++) {
		Input[i].checked = checked;
	}
}

function o1t_createOverlay() {

	var _overlay = null;
	
	_overlay = document.createElement('div');
	_overlay.setAttribute('id', 'o1t_overlay');
	_overlay.style.backgroundColor = '#fff';
	_overlay.style.textAlign = 'center';
	_overlay.style.position = 'absolute';
	_overlay.style.top = '0px';
	_overlay.style.left = '0px';
	_overlay.style.width = '100%';
	_overlay.style.height = '100%';
	_overlay.style.zIndex = '10001';
	_overlay.style.opacity = '0.75';
	_overlay.style.filter = 'alpha(opacity=75)';
	_overlay.style.display = 'block';
	
	_parent = document.getElementsByTagName('body')[0];
	_parent.appendChild(_overlay);
	
	setTimeout( function(){
		_overlay.style.backgroundColor = '#444';	
	}, 100);
	setTimeout( function(){
		_overlay.style.backgroundColor = '#333';	
	}, 200);
	setTimeout( function(){
		_overlay.style.backgroundColor = '#222';	
	}, 300);
	setTimeout( function(){
		_overlay.style.backgroundColor = '#111';	
	}, 400);
	setTimeout( function(){
		_overlay.style.backgroundColor = '#000';	
	}, 500);
	
	return _overlay;
}
function o1t_killOverlay() {
	
	var _overlay = document.getElementById('o1t_overlay');
	
	setTimeout( function(){
		_overlay.style.backgroundColor = '#111';	
	}, 100);
	setTimeout( function(){
		_overlay.style.backgroundColor = '#222';	
	}, 200);
	setTimeout( function(){
		_overlay.style.backgroundColor = '#333';	
	}, 300);
	setTimeout( function(){
		_overlay.style.backgroundColor = '#444';	
	}, 400);
	setTimeout( function(){
		_overlay.style.backgroundColor = '#555';	
	}, 500);
	
	_overlay.style.display = 'none';
}
