// JavaScript Document

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function set_full_width()
{
	document.getElementById('colArea').style.width = (f_clientWidth()-258)+'px';
	document.getElementById('sizeHolder').style.width = (f_clientWidth())+'px';
	document.getElementById('content_container').style.width = (f_clientWidth()-258)+'px';
	document.getElementById('slider1').style.width = (f_clientWidth()-258)+'px';
	document.getElementById('siteFunctions').style.width = (f_clientWidth()-60)+'px';
	resize_set();
}

function resize_set()
{
	var ocontainer;
    var ocontent;
    var spaceToScroll;
	ocontainer = $('div.container');
	ocontent = $('div.content');
	
	containerSize = jQuery.iUtil.getSize(ocontainer.get(0));
	containerPosition = jQuery.iUtil.getPosition(ocontainer.get(0));
	containerInner = jQuery.iUtil.getClient(ocontainer.get(0));
	
	contentSize = jQuery.iUtil.getSize(ocontent.get(0));
	
	$('div.slider1')
		.css('top', (containerPosition.y + containerSize.hb) + 'px')
		.css('left', containerPosition.x + 'px')
		.css('width', containerSize.wb-190 + 'px');
	
	spaceToScroll = contentSize.wb - containerInner.w;
	
	//$('div.indicator')
		//.css('width', containerInner.w * containerSize.wb / contentSize.wb + 'px')
	
	$('.slider1').Slider(
		{
			accept : '.indicator',
			onSlide : function( cordx, cordy, x , y)
			{
				ocontent
					.css('left', - spaceToScroll * cordx / 100 + 'px');
			}
		}
	);
}

function CreateBookmarkLink(Title, URL) {
	if (window.sidebar) {
		window.sidebar.addPanel(Title, URL, "");
	} else if( window.external ) {
		window.external.AddFavorite(URL, Title);
	}
	return true;
}

function ID(id){
	return document.getElementById(id);
}

function adjustWidth(id, width){
	witdh = new String(ID(id).style.width);
	witdh = witdh.replace('px', '');
	witdh = witdh.replace('px;', '');
	witdh = new Number(witdh);
	witdh += width;
	witdh += 'px';
	ID(id).style.width = witdh;
}

/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/

var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

function createFlashObject(path, id){
	var flashObject= new FlashObject(path, "mySWF", "642", "330", "6", "#FFFFFF");	
	flashObject.write(id);
}

		
