/*
A thumb lista bal és jobb irányba történő scroll-ozását végző függvények.

Egy példa a html struktúra:
<div style="text-align:center; display:table; width:350px;">
	<table class="termek_reszletes_thumbs" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td><img name="left" src="../_application/images/termek_reszletes/pager_left.gif" border="0" onmouseover="start_scroll(0,'left','../_application/images/termek_reszletes/pager_left_hv.gif');" onmouseout="stop_scroll(0,'left','../_application/images/termek_reszletes/pager_left.gif');"></td>
			<td>
				<div class="container_horizontal" id="container_horizontal">
					<table border="0" cellspacing="0" cellpadding="0" id="container_list_horizontal">
						<tr>
							<td><img class="thumb_img" onClick="kepcsere('1','6','termek_reszletes_kep')" onmouseover="this.className='thumb_img_hv'" onmouseout="this.className='thumb_img'" src="../_framework/provider/cachingdbfield/?exportid=dF90ZXJtZWtfa2Vw_a2VwX3RodW1i_OQ,,&amp;magic=NGIwMjcyOWNkNDA3Nzc1ZjQ5NWUzMjliNzgwNjMzMjg," border="0" alt="" title=""></td>
							<td><div class="thumb_sep" style="width:10px; display:block;"><img src="../_application/images/termek_reszletes/thumb_sep.jpg" alt="" title="" width="2" /></div></td>
							<td><img class="thumb_img" onClick="kepcsere('2','6','termek_reszletes_kep')" onmouseover="this.className='thumb_img_hv'" onmouseout="this.className='thumb_img'" src="../_framework/provider/cachingdbfield/?exportid=dF90ZXJtZWtfa2Vw_a2VwX3RodW1i_Nw,,&amp;magic=NGIwMjcyOWNkNDA3Nzc1ZjQ5NWUzMjliNzgwNjMzMjg," border="0" alt="" title=""></td>
							<td><div class="thumb_sep" style="width:10px; display:block;"><img src="../_application/images/termek_reszletes/thumb_sep.jpg" alt="" title="" width="2" /></div></td>
							<td><img class="thumb_img" onClick="kepcsere('3','6','termek_reszletes_kep')" onmouseover="this.className='thumb_img_hv'" onmouseout="this.className='thumb_img'" src="../_framework/provider/cachingdbfield/?exportid=dF90ZXJtZWtfa2Vw_a2VwX3RodW1i_MTM,&amp;magic=NGIwMjcyOWNkNDA3Nzc1ZjQ5NWUzMjliNzgwNjMzMjg," border="0" alt="" title=""></td>
							<td><div class="thumb_sep" style="width:10px; display:block;"><img src="../_application/images/termek_reszletes/thumb_sep.jpg" alt="" title="" width="2" /></div></td>
							<td><img class="thumb_img" onClick="kepcsere('4','6','termek_reszletes_kep')" onmouseover="this.className='thumb_img_hv'" onmouseout="this.className='thumb_img'" src="../_framework/provider/cachingdbfield/?exportid=dF90ZXJtZWtfa2Vw_a2VwX3RodW1i_MTQ,&amp;magic=NGIwMjcyOWNkNDA3Nzc1ZjQ5NWUzMjliNzgwNjMzMjg," border="0" alt="" title=""></td>
							<td><div class="thumb_sep" style="width:10px; display:block;"><img src="../_application/images/termek_reszletes/thumb_sep.jpg" alt="" title="" width="2" /></div></td>
							<td><img class="thumb_img" onClick="kepcsere('5','6','termek_reszletes_kep')" onmouseover="this.className='thumb_img_hv'" onmouseout="this.className='thumb_img'" src="../_framework/provider/cachingdbfield/?exportid=dF90ZXJtZWtfa2Vw_a2VwX3RodW1i_MTU,&amp;magic=NGIwMjcyOWNkNDA3Nzc1ZjQ5NWUzMjliNzgwNjMzMjg," border="0" alt="" title=""></td>
							<td><div class="thumb_sep" style="width:10px; display:block;"><img src="../_application/images/termek_reszletes/thumb_sep.jpg" alt="" title="" width="2" /></div></td>
							<td><img class="thumb_img" onClick="kepcsere('6','6','termek_reszletes_kep')" onmouseover="this.className='thumb_img_hv'" onmouseout="this.className='thumb_img'" src="../_framework/provider/cachingdbfield/?exportid=dF90ZXJtZWtfa2Vw_a2VwX3RodW1i_MTY,&amp;magic=NGIwMjcyOWNkNDA3Nzc1ZjQ5NWUzMjliNzgwNjMzMjg," border="0" alt="" title=""></td>
						</tr>
					</table>
				</div>
			</td>
			<td><img name="right" src="../_application/images/termek_reszletes/pager_right.gif" border="0" onmouseover="start_scroll(1,'right','../_application/images/termek_reszletes/pager_right_hv.gif');" onmouseout="stop_scroll(1,'right','../_application/images/termek_reszletes/pager_right.gif');"></td>
		</tr>
	</table>
</div>

A fenti html struktúrához tartozó css-ek:
table.termek_reszletes_thumbs{width:234px; height:120px; margin:0px 0px 0px 0px; margin-left:auto; margin-right:auto;}
div.container_horizontal{height:120px; margin:0px; overflow:hidden; padding:0px; text-align:center; width:210px; text-align:left;}
div.container_horizontal table{height:120px; margin:0px; padding:0px; text-align:center; position:relative;}
.thumb_sep{width:10px; display:table;}
.thumb_sep img{margin:0px 0px 0px 0px;}
.thumb_img, .thumb_img_hv{cursor:pointer;}
*/

/*Módosítható változók:*/
/*A befoglaló és a benne mozgó html elem id-je:*/
var out_tag_id = 'partner_belso_tarolo';
var inner_tag_id = 'partner_lista_horizontalis';
/*A sebességet befolyásoló változók:*/
var max_speed = 8;
var speed_rise_up = 0.5;
var speed_rise_down = 0.5;

/*Nem módosítható változók:*/
var t;
var t_lassit;
var scroll_in_progress;
var pos = 0;
var curr_speed = 0;
var slideshow_pager_width = 0;

//visszatér -1-vel, ha nem Explorer, különben a verziószámmal
function IEVer(){
	var rv = -1;
	if (navigator.appName == 'Microsoft Internet Explorer'){
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null){
			rv = parseFloat( RegExp.$1 );
		}
	}
	return rv;
}

//az IE verziójától függően vizsgálom a html elem szélességét és adom értékül a változónak
function IEVerEllenorzes(){
	var ver = IEVer();
	if ( ver> -1 ){
		if ( ver>= 8.0 ){
			slideshow_pager_width = document.getElementById(inner_tag_id).clientWidth;
		}
		else if ( ver == 7.0 ){
			slideshow_pager_width = document.getElementById(inner_tag_id).clientWidth;
		}
		else if ( ver == 6.0 ){
			slideshow_pager_width = document.getElementById(inner_tag_id).clientWidth;
		}
		else{
			slideshow_pager_width = 0;
		}
	}
	else{
		slideshow_pager_width = document.getElementById(inner_tag_id).clientWidth;
	}
}

//a scroll-t elindítja
function start_scroll(direction,img_name,img_src){
	document.cookie = "scroll_speed=((start))";
	// IEVerEllenorzes();
	slideshow_pager_width = document.getElementById(inner_tag_id).clientWidth;
	if (scroll_in_progress!=1) {
		srcoll_in_progress=1;
		document[img_name].src=img_src;
		scroll(direction,speed_rise_up);
	}
}

//direction: left=0, right=1;
//a scroll irányától függően balra vagy jobbra tolom a tartalmat
function scroll(direction,curr_speed){
	w=document.getElementById(inner_tag_id);
	v=document.getElementById(out_tag_id);
	
	//a jobb oldali lapozón állva balra csúsztatom, a sebességet folyamatosan növelve
	if (direction==1){
		if( (curr_speed + speed_rise_up) < max_speed ) curr_speed = curr_speed + speed_rise_up;
		var inner_width = (slideshow_pager_width+pos);
		var outer_width = (v.clientWidth);
		if (inner_width>outer_width){
			pos-=curr_speed;
			w.style.left = ""+pos+"px";
		}
	}
	//a bal oldali lapozón állva jobbra csúsztatom, a sebességet folyamatosan növelve.
	else {
		if (pos<0){
			if( (curr_speed + speed_rise_up) < max_speed ) curr_speed = curr_speed + speed_rise_up;
			pos+=curr_speed;
			w.style.left = ""+pos+"px";
		}
	}
	
	var speedCookie = document.cookie;
	var speed = speedCookie.substring((speedCookie.indexOf("scroll_speed=((")+15),speedCookie.indexOf("))"));
	if(speed=='stop'){
		clearTimeout(t);
	}
	else{
		//eltárolom sütiben az aktuális sebességet
		document.cookie = "scroll_speed=(("+curr_speed+"))";
		t=setTimeout("scroll("+direction+","+curr_speed+")",40);
	}
}

//az iránytól függően folyamatosan lassítva (míg el nem éri a nullát) csúsztatom a listát
function scroll_lassit(direction,curr_speed){
	w=document.getElementById(inner_tag_id);
	v=document.getElementById(out_tag_id);
	
	if (direction==1){
		if( (curr_speed - speed_rise_down) >= 0 ) curr_speed = curr_speed - speed_rise_down;
		var inner_width = (slideshow_pager_width+pos);
		var outer_width = (v.clientWidth);
		if (inner_width>outer_width){
			pos-=curr_speed;
			w.style.left = ""+pos+"px";
		}
	}
	else {
		if (pos<0){
			if( (curr_speed - speed_rise_down) >= 0 ) curr_speed = curr_speed - speed_rise_down;
			pos+=curr_speed;
			w.style.left = ""+pos+"px";
		}
	}
	if(curr_speed==0){
		clearTimeout(t_lassit);
		clearTimeout(t);
	}
	else{
		t_lassit = setTimeout("scroll_lassit("+direction+","+curr_speed+")",40);
	}
}

//a scroll-t leállítja
function stop_scroll(direction,img_name,img_src){
	// IEVerEllenorzes();
	slideshow_pager_width = document.getElementById(inner_tag_id).clientWidth;
	//kiszedem a sütiből az aktuális sebességet és a sütit kiürítem
	var speedCookie = document.cookie;
	var speed = speedCookie.substring((speedCookie.indexOf("scroll_speed=((")+15),speedCookie.indexOf("))"));
	document.cookie = "scroll_speed=((stop))";

	//kikapcsolom az időzítőt
	clearTimeout(t);
	
	//elindítom a lassítót
	scroll_lassit(direction,speed)
	document[img_name].src=img_src;
	scroll_in_progress=0;
}


//--------------------------------------------------------------------------------------------------------------------------------------
var out_tag_id_ref = 'referencia_belso_tarolo';
var inner_tag_id_ref = 'referencia_lista_horizontalis';

var t_ref;
var t_lassit_ref;
var scroll_in_progress_ref;
var pos_ref = 0;
var curr_speed_ref = 0;

//a scroll-t elindítja
function start_scroll_ref(direction,img_name,img_src){
	document.cookie = "scroll_speed=((start))";
	// IEVerEllenorzes();
	slideshow_pager_width = document.getElementById(inner_tag_id).clientWidth;
	if (scroll_in_progress_ref!=1) {
		scroll_in_progress_ref=1;
		document[img_name].src=img_src;
		scroll_ref(direction,speed_rise_up);
	}
}

//direction: left=0, right=1;
//a scroll irányától függően balra vagy jobbra tolom a tartalmat
function scroll_ref(direction,curr_speed_ref){
	w=document.getElementById(inner_tag_id_ref);
	v=document.getElementById(out_tag_id_ref);
	
	//a jobb oldali lapozón állva balra csúsztatom, a sebességet folyamatosan növelve
	if (direction==1){
		if( (curr_speed_ref + speed_rise_up) < max_speed ) curr_speed_ref = curr_speed_ref + speed_rise_up;
		var inner_width = (slideshow_pager_width+pos_ref);
		var outer_width = (v.clientWidth);
		if (inner_width>outer_width){
			pos_ref-=curr_speed_ref;
			w.style.left = ""+pos_ref+"px";
		}
	}
	//a bal oldali lapozón állva jobbra csúsztatom, a sebességet folyamatosan növelve.
	else {
		if (pos_ref<0){
			if( (curr_speed_ref + speed_rise_up) < max_speed ) curr_speed_ref = curr_speed_ref + speed_rise_up;
			pos_ref+=curr_speed_ref;
			w.style.left = ""+pos_ref+"px";
		}
	}
	
	var speedCookie = document.cookie;
	var speed = speedCookie.substring((speedCookie.indexOf("scroll_speed=((")+15),speedCookie.indexOf("))"));
	if(speed=='stop'){
		clearTimeout(t_ref);
	}
	else{
		//eltárolom sütiben az aktuális sebességet
		document.cookie = "scroll_speed=(("+curr_speed_ref+"))";
		t_ref=setTimeout("scroll_ref("+direction+","+curr_speed_ref+")",40);
	}
}

//az iránytól függően folyamatosan lassítva (míg el nem éri a nullát) csúsztatom a listát
function scroll_lassit_ref(direction,curr_speed_ref){
	w=document.getElementById(inner_tag_id_ref);
	v=document.getElementById(out_tag_id_ref);
	
	if (direction==1){
		if( (curr_speed_ref - speed_rise_down) >= 0 ) curr_speed_ref = curr_speed_ref - speed_rise_down;
		var inner_width = (slideshow_pager_width+pos_ref);
		var outer_width = (v.clientWidth);
		if (inner_width>outer_width){
			pos_ref-=curr_speed_ref;
			w.style.left = ""+pos_ref+"px";
		}
	}
	else {
		if (pos_ref<0){
			if( (curr_speed_ref - speed_rise_down) >= 0 ) curr_speed_ref = curr_speed_ref - speed_rise_down;
			pos_ref+=curr_speed_ref;
			w.style.left = ""+pos_ref+"px";
		}
	}
	if(curr_speed_ref==0){
		clearTimeout(t_lassit_ref);
		clearTimeout(t_ref);
	}
	else{
		t_lassit_ref = setTimeout("scroll_lassit_ref("+direction+","+curr_speed_ref+")",40);
	}
}

//a scroll-t leállítja
function stop_scroll_ref(direction,img_name,img_src){
	// IEVerEllenorzes();
	slideshow_pager_width = document.getElementById(inner_tag_id).clientWidth;
	//kiszedem a sütiből az aktuális sebességet és a sütit kiürítem
	var speedCookie = document.cookie;
	var speed = speedCookie.substring((speedCookie.indexOf("scroll_speed=((")+15),speedCookie.indexOf("))"));
	document.cookie = "scroll_speed=((stop))";

	//kikapcsolom az időzítőt
	clearTimeout(t_ref);
	
	//elindítom a lassítót
	scroll_lassit_ref(direction,speed)
	document[img_name].src=img_src;
	scroll_in_progress_ref=0;
}
