function loadVideo( filename, div ) {
	var s1 = new SWFObject( "flvplayer.swf", "single", "512", "413", "7");
	s1.addParam( "allowfullscreen", "true" );
	s1.addVariable( "file", "video/" + filename + ".flv" );
	s1.addVariable( "image", "video/" + filename + ".jpg" );
	s1.write( div );
}

function loadMP3( filename, div ) {
	var s1 = new SWFObject( "flvplayer.swf", "single", "512", "29", "7");
	s1.addParam( "allowfullscreen", "true" );
	s1.addVariable( "file", "video/" + filename + ".mp3" );
	s1.write( div );
}

tabbox = function( elm ) {
	this.init( elm );
}

tabbox.prototype = {

	init : function( elm ) {

		if ( ! document.getElementById( elm ) ) {
			return false;
		}

		var ul = document.getElementById( elm );

		ul.onclick = function(evt) {
			var event = evt || window.event;
			var target = event.target || event.srcElement;

			if ( target.nodeName.toLowerCase() == 'a' && target.parentNode.nodeName.toLowerCase() == 'h3' ) {
				tabbox.focusTab( target );
				return false;
			}
		}

		var arrUl = ul.getElementsByTagName('ul');

		for ( var i = 0, il = arrUl.length; i < il; i++ ) {
			if ( i > 0 ) {
				arrUl[i].style.display = 'none';
			}
		}
		
	},

	focusTab : function(elm) {

		var actLi = elm.parentNode.parentNode;
		var ul = actLi.parentNode;

		var arrLi = ul.getElementsByTagName('li');

		for (var i = 0, il = arrLi.length; i < il; i++) {
			if ( arrLi[i].parentNode == ul ) {
				arrLi[i].className = '';
				if ( arrLi[i].getElementsByTagName('ul')[0] ) {
					arrLi[i].getElementsByTagName('ul')[0].style.display = 'none';
				}
			}
		}

		actLi.className = 'sel';
		actLi.getElementsByTagName('ul')[0].style.display = 'block';

	}

}

scrollbox = function (scrollname, div_name, left_name, right_name) {
	this.init( scrollname, div_name, left_name, right_name );
}

scrollbox.prototype = {

	init : function( scrollname, div_name, left_name, right_name ) {

		this.div_name = div_name;
		this.name = scrollname;
		this.scrollCursor = 0;
		this.startCursor = 0;
		this.speed = 30;
		this.slidePx = 300;
		this.scrollMoving = false;
		this.timeoutID = 0;
		this.div_obj = null;
		this.left_name = left_name;
		this.right_name = right_name;
		this.maxwidth = 0;

		if (document.getElementById) {
			div_obj = document.getElementById(this.div_name);
			if (div_obj) {
				this.div_obj = div_obj;
			} else {
				return false;
			}
			div_left_obj = document.getElementById(this.left_name);
			div_right_obj = document.getElementById(this.right_name);

			if (div_left_obj && div_right_obj) {

				div_left_obj.onclick = ( function(scrollbox) {
					return function() {
						scrollbox.scrollLft('start');
						return false;
					}
				} ) (this);

				div_right_obj.onclick = ( function(scrollbox) {
					return function() {
						scrollbox.scrollRght('start');
						return false;
					}
				} ) (this);

			}

			// a galeriaban szereplo kepek + oldalso margo + a mozgo ablak szelessege
			this.maxwidth = div_obj.getElementsByTagName('li').length * 107 + 9 - 478;
			/*@cc_on
			this.maxwidth = div_obj.getElementsByTagName('li').length * 107 + 9 - 465;
			@*/

		}

	},

	scrollLft : function( start ) {

		if ( ! this.div_obj || ( start && this.scrollMoving )) {
			return false;
		}

		if ( start ) {
			this.startCursor = this.scrollCursor;
			this.scrollMoving = true;
		}

		if ( ( this.scrollCursor - this.speed ) < 0 ) {
			this.scrollCursor = 0;
			this.div_obj.scrollLeft = this.scrollCursor;
			this.scrollMoving = false;
			return true;
		} else if ( ( this.scrollCursor - this.speed ) < ( this.startCursor - this.slidePx ) ) {
			this.scrollCursor = this.startCursor - this.slidePx;
			this.div_obj.scrollLeft = this.scrollCursor;
			this.scrollMoving = false;
			return true;
		} else {
			this.scrollCursor -= this.speed;
		}

		//this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
		this.div_obj.scrollLeft = this.scrollCursor;
		this.timeoutID = setTimeout(this.name + ".scrollLft()", 60);
	},

	scrollRght : function( start ) {

		if ( ! this.div_obj || ( start && this.scrollMoving )) {
			return false;
		}

		if ( start ) {
			this.startCursor = this.scrollCursor;
			this.scrollMoving = true;
		}

		if ( ( this.scrollCursor + this.speed ) >= this.maxwidth ) {
			this.scrollCursor = this.maxwidth;
			this.div_obj.scrollLeft = this.scrollCursor;
			this.scrollMoving = false;
			return true;
		} else if ( ( this.scrollCursor + this.speed ) >= ( this.startCursor + this.slidePx ) ) {
			this.scrollCursor = this.startCursor + this.slidePx;
			this.div_obj.scrollLeft = this.scrollCursor;
			this.scrollMoving = false;
			return true;
		} else {
			this.scrollCursor += this.speed;
		}

		//this.scrollCursor = ( this.scrollCursor + this.speed ) >= this.maxwidth ? this.maxwidth : this.scrollCursor + this.speed;
		this.div_obj.scrollLeft = this.scrollCursor;
		this.timeoutID = setTimeout(this.name + ".scrollRght()", 60);
	}
}


/* Init */

var tabbox = new tabbox( 'korabbi_tabbox' );
