/*************************************
 *
 *  Code By Attenzione
 *  Started at 21.04.2008
 *
 *************************************/

/*document.onkeyup  = function(e) {
	e = _fixE( e );
	if (e.keyCode == 8) {
		refreshPage();
	}
}*/

//var oldHref = window.location.href;
//setInterval( function() { if (oldHref != window.location.href) { refreshPage(); } }, 500 );
 
var lastAjaxUrl = "";

var iw = new Object();

iw.functions = {
	
	getAjaxBody : function( responseText ) {
		var bodyStart = responseText.toLowerCase().indexOf("<body>");
		var bodyEnd = responseText.toLowerCase().indexOf("</body>");

		if (bodyStart > -1 && bodyEnd > -1)	{
			responseText = responseText.substring( bodyStart + 6, bodyEnd );
		}
		return responseText;
	},
	
	scrollToName: function( name, offset ) {
		var o = $('[name='+name+']');
		if (!o.length) return false;
		if (typeof offset == 'undefined') offset = 0;
		window.scroll( 0, o.offset().top - offset );
	}
	
};

iw.viewport = {
	windowX : function() { return (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth },
	windowY : function() { return (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || self.innerHeight || document.body.clientHeight },
	scrollX : function() { return (document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft },
	scrollY : function() { return (document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop },
	pageX 	: function() { return (document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth },
	pageY 	: function() { return (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight }
}

iw.preloader = {
	o : null,
	p : null,
	show : function( selector ) {
		if (!this.init( selector )) return false;
		this.p.removeClass('preloader-instance').prependTo( this.o ).show();
		return true;
	},
	hide : function( selector ) {
		if (!this.init( selector )) return false;
		this.o.find('div.preloader').remove();
		return true;
	},
	init : function( selector ) {
		var o = $( selector );
		if (!o.length) return false;
		this.o = o;
		//var p = $('div.preloader-instance');
		//if (!p.length) return false;
		var msg = typeof settings.preloader != 'undefined' ? settings.preloader : '';
		this.p = $('<div class="preloader"><div><span>'+msg+'</span></div></div>');
		var height = this.o.height();
		var padding = height < 600 ? Math.max(0, Math.round( height / 2 ) - 40) : 250;
		this.p.find('div').css({
			'padding-top' : padding,
			'height' : height - padding
		});
		return true;
	}
}

function _$( id ) {
	return document.getElementById( id );
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.onlyLatinChars = function() {
	
	var chars = {
		'ā' : 'a',
		'ē' : 'e',
		'ī' : 'i',
		'ū' : 'u',
		'õ' : 'o',
		'ŗ' : 'r',
		'š' : 's',
		'ģ' : 'g',
		'ķ' : 'k',
		'ļ' : 'l',
		'ž' : 'z',
		'č' : 'c',
		'ņ' : 'n'
	};	
	var str = this;	
	var r = new RegExp();
	for ( i in chars ) {
		r = new RegExp( i, 'g' );
		str = str.replace( r, chars[i] );
		r = new RegExp( i.toUpperCase(), 'g' );
		str = str.replace( r, chars[i].toUpperCase() );
	}
	return str;
	
}

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/number/fmt-money [rev. #2]
Number.prototype.currency = function(c, d, t) {
    var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
    i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t)
    + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

function in_array(myValue,myArray) {
    function equals(a,b) {
        return (a == b);
    }

    for (var i in myArray) {
        if (equals(myArray[i],myValue))
            return true;
    }

    return false;
}

function _noBubbling( e ) {
	e = _fixE( e );
	if (!e.cancelBubble) e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
    return false;
}

function _fixE( e ) {
	if (!e) e = window.event;
	return e;
}


function getSelectionPositions( element ) {
	if( document.selection ){
		// The current selection
		var range = document.selection.createRange();
		// We'll use this as a 'dummy'
		var stored_range = range.duplicate();
		// Select all text
		stored_range.moveToElementText( element );
		// Now move 'dummy' end point to end point of original range
		stored_range.setEndPoint( 'EndToEnd', range );
		// Now we can calculate start and end points
		element.selectionStart = stored_range.text.length - range.text.length;
		element.selectionEnd = element.selectionStart + range.text.length;
	}
	return { start: element.selectionStart, end: element.selectionEnd };
}
function setSelectionPositions( element, start, end ) {

	if (!end || typeof end == 'undefined') end = start;
	// IE Support
	if (document.selection) {

		// Set focus on the element
		element.focus ();

		// Create empty selection range
		var oSel = document.selection.createRange ();

		// Move selection start and end to 0 position
		//oSel.moveStart ('character', -element.value.length);

		// Move selection start and end to desired position
		oSel.moveStart ('character', start);
		oSel.moveEnd ('character', -element.value.length + end);
		oSel.select ();
		
	} else if (element.selectionStart || element.selectionStart == '0') {
	
		element.focus ();
		element.selectionStart = start;
		element.selectionEnd = end;

		
	}

}

function formSubmit( actionObj, preloader ) {

	var callerObj;
	callerObj = actionObj = $( actionObj );
	if (callerObj.attr('__iw_busy')) return false;
	callerObj.attr('__iw_busy', true);

	if ( actionObj.get(0).tagName.toLowerCase() == 'form') {
		var parentForm = actionObj;
	} else {
		if (actionObj.get(0).tagName.toLowerCase() == 'a') {
			actionObj.get(0).blur();
		}
		var parentForm = actionObj.parents('form:first');
	}
	
	var url = parentForm.get(0).action;
	if (!url) url = document.location.href;
	url = fixUrl( url );
	
	var options = {
		beforeSubmit: function() {
			document.body.style.cursor = 'wait';
			if (typeof preloader != 'undefined') {
				iw.preloader.show( preloader );
			}
		},
		url : url,
		type: "POST",
		complete: function() {
			document.body.style.cursor = 'default';
			if (typeof preloader != 'undefined') {
				iw.preloader.hide( preloader );
			}
			callerObj.removeAttr('__iw_busy');
		},
		success: function( responseText, statusText ) {

			document.body.style.cursor = 'default';
		
			var bodyStart = responseText.toLowerCase().indexOf("<body>");
			var bodyEnd = responseText.toLowerCase().indexOf("</body>");

			if (bodyStart > -1 && bodyEnd > -1)	{
				responseText = responseText.substring( bodyStart + 6, bodyEnd );
			}
		
			evalScriptsOnResponse( responseText );
			
		}
	};
	parentForm.ajaxSubmit( options );

	return false;

}

function setAction( action, force, preloader ) {

	if (typeof action == 'object' && action.tagName.toLowerCase() == 'a') {
		action.blur();
		var actionObj = action;
		action = action.href;
	}
	var url = fixUrl(action);

	lastAjaxUrl = url;

	var options = {
		beforeSend: function() {
			document.body.style.cursor = 'wait';
			if (typeof preloader != 'undefined') {
				iw.preloader.show( preloader );
			}
		},
		url : url,
		type  : "GET",
		dataType: "text",
		complete: function() {
			document.body.style.cursor = 'default';
			if (typeof preloader != 'undefined') {
				iw.preloader.hide( preloader );
			}
		},
		success: function( responseText, statusText ) {

			var bodyStart = responseText.toLowerCase().indexOf("<body>");
			var bodyEnd = responseText.toLowerCase().indexOf("</body>");

			if (bodyStart > -1 && bodyEnd > -1)	{
				responseText = responseText.substring( bodyStart + 6, bodyEnd );
			}
			
			evalScriptsOnResponse( responseText );
			
		}
	};
	$.ajax( options );
	return false;

}

function setPageAction( action, force ) {

	if (typeof action == 'object' && action.tagName.toLowerCase() == 'a') {
		action.blur();
		var actionObj = action;
		action = action.href;
	} else {
		window.location.href = action;
	}
	oldHref = window.location.href;
	var url = action.replace('#', '');
	window.location.href = url;
	
	return false;
	
	//setAction( url, force );

}

function fixUrl( url ) {
	url = url.replace(/ajax\.php$/, '');
	//var host = document.location.protocol + '//' + document.location.host + settings.url;
	//url = url.replace(host, '');
	urls = url.split("?");
	url = urls[0];
	if (typeof urls[1] != 'undefined' && urls[1].length) {
		urls[1] = '?'+urls[1];
	} else {
		urls[1] = "";
	}
	url = url.replace(/\/$/, '');
	url += /*'/ajax.php' +*/ '/' + urls[1];
	return url;
}

function evalScriptsOnResponse( text ) {

	//var aObj = $("<div>"+text+"</div>");
	var scriptIndex = 0;
	var IWScripts = new Array();
	document.onIWRun = null;
	document.IWLoaded = true;

	/* It's Toooooo LONG! */
	/*aObj.find("script").each( function() {
		document.onIWComplete = null;
		eval( this.innerHTML );
		if (document.onIWComplete) {
			IWScripts[scriptIndex] = document.onIWComplete;
			scriptIndex++;
		}
	});*/

	/* remove all scripts */
	text = text.replace(/<(\/?)script/gi, "<$1script");
	var scriptStart = text.indexOf("<script");
	var scriptEnd = -1;
	var scriptBody = "";

	while(scriptStart > -1) {
		scriptEnd = text.indexOf("</script>")+9;
		scriptBody = text.substring(text.indexOf(">", scriptStart)+1, scriptEnd - 9);

		//reset collection function
		document.onIWComplete = null;
		try {
			eval( scriptBody );
		} catch (e) {
			window.console.log( e );
		}
		if (document.onIWComplete) {
			IWScripts[scriptIndex] = document.onIWComplete;
			scriptIndex++;
		}

		//new html without executed script;
		text = text.substring(0,scriptStart)+text.substring(scriptEnd, text.length);
		scriptStart = text.indexOf("<script");
	}

	if (typeof document.onIWRun == 'function') {
		document.onIWRun( text );
	}

	if (IWScripts.length) {
		for (var i = 0; i < IWScripts.length; i++) {
			try {
				IWScripts[i]( );
			} catch (e) {
				window.console.log( e );
			}
		}
	}

}

var floatLayerID = 1000;
function floatContent( content, params ) {
	floatLayerID++;
	var zIndex = (floatLayerID - 999) * 3 + 100;
	var html =	'<div id="float-layer-bg-'+floatLayerID+'" class="float-layer-bg" style="display:none;z-index:'+zIndex+';"></div>'+
				'<div id="float-layer-'+floatLayerID+'" class="float-layer" style="display:none;z-index:'+(zIndex+1)+';">'+ 
					'<table class="float-layer">'+
						'<tr>'+
							'<td class="float-layer-inner">'+
								content +
							'</td>'+
						'</tr>'+
					'</table>'+
				'</div>';
	//attachSubmit( 'float-layer-inner' );
	$('body').prepend( html );
	showFloatLayer( floatLayerID, params );
}

function showFloatLayer( ID, params ) {

	var $floatLayer = $('#float-layer-' + ID);
	var $floatLayerPositioner = $('table.float-layer', $floatLayer);
	
	if (typeof params != 'undefined') {
		$.data( $floatLayer.get(0), '__params', params );
		if (params.top) {
			if (params.top != 'window') {
				$floatLayerPositioner.find('td.float-layer-inner').css({'vertical-align' : 'top'});
				$floatLayerPositioner.css({'height' : 'auto'});
				$floatLayer.css('top', params.top + iw.viewport.scrollY());
			}
		} else if (params.top === 0 ) {
			$floatLayer.css('top', 0);
		} else {
			$floatLayer.css('top', iw.viewport.scrollY());
		}
		if ( (params.left && params.left == 'click') || (params.right && params.right == 'click') ) {
			if ( typeof __iw_click.x != 'undefined' ) {
				var procL = parseInt( __iw_click.x / iw.viewport.pageX() * 100 );
				var procR = parseInt( (iw.viewport.pageX() - __iw_click.x ) / iw.viewport.pageX() * 100 );
				if (procL <= procR && procL < 30) {
					$floatLayerPositioner.css({'margin-left' : procL+'%'});
				} else if (procR < 30) {
					$floatLayerPositioner.css({'margin-right' : procR+'%'});
				}
			}			
		} else if ( params.left ) {
			$floatLayerPositioner.css({'margin-left' : params.left, 'width' : 'auto'});
		} else if ( params.right ) {
			$floatLayerPositioner.css({'margin-right' : params.right, 'width' : 'auto'});
		}
		if ( params.width ) {
			$floatLayerPositioner.css({'width' : params.width});
		}
		showColorLayer( ID );
		if ( params.slide ) {
			$floatLayer.css({'visibility': 'hidden', 'display' : 'block'});
			var top = $floatLayer.offset().top;
			//var height = $floatLayerPositioner.height();
			$floatLayer.css('top', top - 30 );
			$floatLayer.css({'visibility': 'visible', 'display' : 'block' });
			$floatLayer.animate({ 'top': top }, 'slow', 'easeOutExpo');
		} else {
			$floatLayer.show();
		}
	} else {
		$floatLayer.css('top', iw.viewport.scrollY())
		showColorLayer( ID );
		$floatLayer.show();
	}
	//$(window).unbind('click', hideFloatLayer );
	//$(window).bind('click', hideFloatLayer );
}
function showColorLayer( ID ) { $('#float-layer-bg-'+ID).show(); }
function hideColorLayer( ID ) { $('#float-layer-bg-'+ID).remove(); }
function hideFloatLayer( ) {
	while (floatLayerID > 1000) {
		var l = $('#float-layer-'+floatLayerID);
		if (l.length) {
			if ($.data( l.get(0), '__params') && $.data( l.get(0), '__params').slide) {
				hideColorLayer( floatLayerID );
				l.animate({ 'top': l.offset().top - 30, 'opacity' : 0 }, 'fast', '', function() {
					l.remove();
				});
			} else {
				l.remove();
				hideColorLayer( floatLayerID );
			}
			floatLayerID--;
			break;
		}
		floatLayerID--;
	}
}
function resizeFloatLayer() {
	return false;
	var contentHeight = $('#float-layer-inner').height();
	var top = Math.abs(Math.round((viewport.windowY() - contentHeight) / 2));
	top += view.scrollY;
	$('#float-layer').css('top', top);
}

function refreshPage( url, oldStyle ) {

	oldStyle = true;
	
	if (oldStyle) {
		if (typeof url == 'undefined' || !url) {
			window.location.reload(true);
		} else {
			window.location.href = url;
		}
	} else {
		if (typeof url == 'undefined' || !url) {
			setPageAction( window.location.href );
		} else {
			window.location.href = url;
			setPageAction(url);
		}
	}

}

function pageRefresh( url, oldStyle ) {
	refreshPage ( url, oldStyle );
}

function switchImage( target, src, oncomplete ) {

	var im = new Image();
	target = $(target);
	//iw.preloader.show( target.parent() );
	im.onload = function() {
		var img = target.find('img');
		if (target.length && img.length) {
			var targetDOM = target.get(0);
			var imgDOM = img.get(0);
			var width = im.width;
			var height = im.height;
			targetDOM.style.width = imgDOM.width + 'px';
			targetDOM.style.height = imgDOM.height + 'px';
			target.css('overflow', 'hidden');
			var f = function() {
				target.find('.prev').css('height', height);
				target.find('.next').css('height', height);
			};
			if ($.browser.msie) {
				target.css({'width': width, 'height': height});
				img.attr({
					'src' : src,
					'width' : width,
					'height' : height
				});
				f();
				if (typeof oncomplete == 'function') { oncomplete(); }
			} else {
				target.animate({'opacity': 0}, 200, false, function() {
					$(this).animate({'width': width, 'height': height}, 300, false, function() {
						img.attr({
							'src' : src,
							'width' : width,
							'height' : height
						});
						$(this).animate({'opacity': 1}, 200, false, function() { 
							f();
							if (typeof oncomplete == 'function') { oncomplete(); }
						});
					});
				});
			}
		}
	}
	im.src = src;

}

function resizeTextarea( element ) {

	if (typeof element.constantHeight == 'undefined') {
		element.constantHeight = element.offsetHeight;
	}
	
	if (element.scrollHeight > element.offsetHeight) {
		element.style.height = element.scrollHeight + 'px';
	}

}

function scroller( id, params ) {
	
	this.id = id;
	this.$id = $(id);
	if (!this.$id.length) return false;
	this.$wrapper = this.$id.find('.scroll-wrapper:first');
	this.$content = this.$id.find('.scroll-content:first');
	this.$leftScroller = this.$id.find('.scroll-left:first');
	this.$rightScroller = this.$id.find('.scroll-right:first');
	this.$scroller = this.$id.find('.scroll-button');
	this.$scrollButton = this.$id.find('.scroll-button div');
	this.direction = 'right';
	this.timer = 0;
	this.autoTimer = 0;
	
	//this.$wrapper.css('width', this.$wrapper.parent().width() );
	this.$wrapper.css('height', this.$content.height() );
	this.$id.find('.fade').css('height', this.$content.height() );
	this.$content.fadeIn(1000, function() { $(this).parent().css('background-image', 'none'); } ).css('visibility', 'visible');
	var self = this;
	this.$leftScroller
		.mouseover(function() {
			//clearInterval( self.autoTimer );
			self.mouseover('left');
			return false;
		})
		.mouseout(function() {
			self.mouseout();
		})
		.click(function() {
			self.click('left');
			return false;
		});
	this.$rightScroller
		.mouseover(function() {
			//clearInterval( self.autoTimer );
			self.mouseover('right');
			return false;
		})
		.mouseout(function() {
			self.mouseout();
		})
		.click(function(){
			self.click('right');
			return false;
		});
	this.$wrapper
		.mouseover(function() {
			clearInterval( self.autoTimer );
		})
		.mouseout(function() {
			self.mouseout();
		});
	this.$scrollButton
		.mousedown(function() {
			self.mousedown();
			return false;
		});
	//this.$wrapper.find('*:first').show();
	$(window)
		.resize(function(){
			self.resize();
		});
	
	this.mouseover = function( direction ) {
		if (typeof this.stopAutoActions != 'undefined' && this.stopAutoActions) return false;
		if (this.$wrapper.attr('scrollWidth') <= this.$wrapper.attr('offsetWidth')) return false;
		if (!this.timer && (direction == 'left' || direction == 'right')) {
			this.direction = direction;
			var self = this;
			clearInterval( this.autoTimer );
			this.autoTimer = 0;
			this.timer = setInterval( function() { self.scroll(); }, 10 );
		}
	};
	
	this.mouseout = function() {
		clearInterval( this.timer );
		this.timer = 0;
		this.autoTimer = setInterval( function() { self.autoScroll(); }, 50 );
	};
	
	this.mousedown = function() {
		clearInterval( this.timer );
		this.timer = 0;
		clearInterval( this.autoTimer );
		this.autoTimer = 0;
		var self = this;
		this.stopAutoActions = true;
		this.mouseMoveFunction = function( e ) {
			self.mousemove( e );
		}
		this.mouseUpFunction = function( e ) {
			self.mouseup( e );
			self.stopAutoActions = false;
		}
		$( document ).bind('mousemove', this.mouseMoveFunction );
		$( document ).bind('mouseup', this.mouseUpFunction );
	};
	
	this.mouseup = function( e ) {
		$( document ).unbind('mousemove', this.mouseMoveFunction );
		$( document ).unbind('mouseup', this.mouseUpFunction );
	};
	
	this.mousemove = function( e ) {
		var newX = e.clientX - this.$scroller.offset().left;
		newX -= Math.round( this.$scrollButton.width() / 2 );
		this.setScrollPosition( newX );
	};
	
	this.scroll = function( by ) {
		if (typeof by == 'undefined') by = 3;
		if (this.direction == 'left' && this.$wrapper.attr('scrollLeft') > 0) {
			this.$wrapper.attr('scrollLeft', this.$wrapper.attr('scrollLeft') - by);
		} else if (this.direction == 'right' && this.$wrapper.attr('scrollLeft') < this.$wrapper.attr('scrollWidth')  - this.$wrapper.attr('offsetWidth')) {
			this.$wrapper.attr('scrollLeft', this.$wrapper.attr('scrollLeft') + by);
		}
		this.setScrollPosition();
	};
	
	this.click = function( direction ) {
		if (this.$wrapper.attr('scrollWidth') <= this.$wrapper.attr('offsetWidth')) return;
		clearInterval( this.autoTimer );
		var self = this;
		var pos = new Array();
		this.$wrapper.find('.objects').each(function() {
			if (direction == 'right') {
				if ($(this).position().left + $(this).width() > self.$wrapper.attr('scrollLeft') + self.$wrapper.attr('offsetWidth')) {
					pos[pos.length] = $(this).position().left + $(this).width() - self.$wrapper.width() + 6; // 2*3 is padding
					//return false;
				}
			} else if (direction == 'left') {
				if ($(this).position().left < self.$wrapper.attr('scrollLeft')) {
					pos[pos.length] = $(this).position().left; // 2*3 is padding
					//return false;
				}
			}
		});
		if (!pos.length) return false;
		if (direction == 'right') {
			pos = pos.length > 2 ? pos[2] : pos[pos.length-1];
		} else {
			pos = pos.length - 3 >= 0 ? pos[pos.length-3] : pos[0];
		}
		if (!pos) pos = 0;
		if (pos == 0) this.$leftScroller.css('opacity', 0.2); 
		else this.$leftScroller.css('opacity', 1);
		if (pos >= this.$wrapper.attr('scrollWidth') - this.$wrapper.width()) this.$rightScroller.css('opacity', 0.2);
		else this.$rightScroller.css('opacity', 1);
		self.$wrapper.animate( {'scrollLeft' : pos }, 'slow', 'easeOutExpo', function() {
			self.setScrollPosition();
		});
	};
	
	this.autoScroll = function() {
		if (typeof this.stopAutoActions != 'undefined' && this.stopAutoActions) return false;
		if (this.direction == 'left') {
			if (this.$wrapper.attr('scrollLeft') > 0) {
				this.$wrapper.attr('scrollLeft', this.$wrapper.attr('scrollLeft') - 1);
			} else {
				this.direction = 'right';
			}
		} else if (this.direction == 'right') {
			if (this.$wrapper.attr('scrollLeft') < this.$wrapper.attr('scrollWidth') - this.$wrapper.attr('offsetWidth')) {
				this.$wrapper.attr('scrollLeft', this.$wrapper.attr('scrollLeft') + 1);
			} else {
				this.direction = 'left';
			}
		}
		this.setScrollPosition();
	};
	
	this.scrollToObject = function( ID ) {
		var self = this;
		this.$wrapper.find('.objects').each(function() {
			var q = this.id.match(/\d+/);
			if (q == ID) {
				var pos = $(this).position().left + $(this).width() / 2 - self.$wrapper.width() / 2;
				self.$wrapper.attr('scrollLeft', pos);
				self.setScrollPosition();
				return false;
			}
		});
	};
	
	this.setScrollPosition = function( newX ) {
		if (typeof newX == 'undefined') {
			newX = Math.round( this.$wrapper.attr('scrollLeft') / (this.$wrapper.attr('scrollWidth') - this.$wrapper.attr('offsetWidth')) * (this.$scroller.width() - this.$scrollButton.width()) );
			if (newX < 0) newX = 0;
			if (newX > this.$scroller.width() - this.$scrollButton.width()) newX = this.$scroller.width() - this.$scrollButton.width();
		} else {
			if (newX < 0) newX = 0;
			else if (newX > this.$scroller.width() - this.$scrollButton.width()) newX = this.$scroller.width() - this.$scrollButton.width();
			//set content
			this.setContentPosition( newX / (this.$wrapper.attr('offsetWidth') - this.$scrollButton.width() ) );
		}
		this.$scrollButton.css('left', newX);
	};
	
	this.setContentPosition = function( percent ) {
		if (this.$wrapper.attr('scrollWidth') <= this.$wrapper.attr('offsetWidth')) return false;
		var maxLeft = this.$wrapper.attr('scrollWidth') - this.$wrapper.attr('offsetWidth');
		var newX = maxLeft * percent;
		if (newX < 0) newX = 0;
		if (newX > maxLeft) newX = maxLeft;
		newX = Math.round( newX );
		//alert( newX );
		this.$wrapper.attr( 'scrollLeft', newX );
	};
	
	this.resize = function() {
		//do something :)
	};
	
	if (this.$wrapper.attr('scrollWidth') > this.$wrapper.attr('offsetWidth')) { 
		//we have scroll!
		if (typeof params.scrollToObject != 'undefined' && params.scrollToObject > 0) {
			this.scrollToObject( params.scrollToObject );
		} else {
			this.mouseout();
		}
	} else {
		this.$leftScroller.css('visibility', 'hidden');
		this.$rightScroller.css('visibility', 'hidden');
		this.$scroller.css('visibility', 'hidden');
	}
	
}

function checkFirebug() {
	return (typeof window.console == 'object' && typeof window.console.firebug != 'undefined');
}

function checkPass() {

	var pass = $('input[name=password]');
	var pass2 = $('input[name=password2]');
	if (pass.length && pass2.length) {
		if (pass.get(0).value && pass2.get(0).value) {
			if (pass.get(0).value == pass2.get(0).value) {
				$('#password-field').removeClass('field-false').addClass('field-true').find('div.error').remove();
				$('#password-field2').removeClass('field-false').addClass('field-true').find('div.error').remove();
			} else {
				$('#password-field').removeClass('field-true').addClass('field-false');
				$('#password-field2').removeClass('field-true').addClass('field-false');
			}
		} else {
			//$('#password-field').removeClass('field-true').removeClass('field-false');
			//$('#password-field2').removeClass('field-true').removeClass('field-false');
		}
	}
	
}

/*########################################*/

function recaptcha( _this ) {
	var dt = new Date();
	var im = $(_this).parents('div:first').find('img.captcha');
	im.attr('src', im.attr('src').replace(/\?(.*)$/, '?'+dt.getTime() ));
	return false;
}


