﻿
function selectSportAngebot(getCheck){
	if(getCheck == 1){
		if(document.getElementById('sport_ch').checked == true){
			document.getElementById('sportangebot').options[0].selected = true;
		}else{
			document.getElementById('sportangebot').value = -1;
		}
	}else{
		if(document.getElementById('sportangebot').value == -1){
			document.getElementById('sport_ch').checked = false;
		}else{
			document.getElementById('sport_ch').checked = true;
		}
	}
}

/*------------------------------SUWAK-------------------------------------

function findPos(obj) {
	var curleft = curtop =  0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	return [curleft,curtop];
	}
}	

movingON = false;
//pressedButton = 0;

window.onload = function events(){
	document.onmousemove = mouseMove;
	document.onmouseup = mouseRelease;
	try{
	if(IBE.req.preis){
		document.getElementById('pointer').style.left = parseInt(putPLNprice((IBE.req.preis*(document.getElementById('div_sel_bottom').offsetWidth-10))/8000,euroPriceFromFile))+'px';
		document.getElementById('preis_cloud').style.left = parseInt(putPLNprice((IBE.req.preis*(document.getElementById('div_sel_bottom').offsetWidth-10))/8000,euroPriceFromFile))+'px';
		document.getElementById('preis_cloud').innerHTML = ((putPLNprice(IBE.req.preis,euroPriceFromFile))+3)+' zł';	
	}
	if((IBE)&&(IBE.hidf.preis)){
		document.getElementById('pointer').style.left = parseInt(putPLNprice((IBE.hidf.preis.substr(2)*(document.getElementById('div_sel_bottom').offsetWidth-10))/8000,euroPriceFromFile))+'px';
		document.getElementById('preis_cloud').style.left = parseInt(putPLNprice((IBE.hidf.preis.substr(2)*(document.getElementById('div_sel_bottom').offsetWidth-10))/8000,euroPriceFromFile))+'px';
		document.getElementById('preis_cloud').innerHTML = ((putPLNprice(IBE.hidf.preis.substr(2),euroPriceFromFile))+3)+' zł';
	}
	}catch(e){}
};


function mouseMove(event){
	if(
		(document.getElementById('pointer'))&&
		(document.getElementById('div_sel_bottom')&&
		(document.getElementById('select_preis'))
		)
	){
		var pointerPosition = findPos(document.getElementById('pointer'));
		var pointerWidth = document.getElementById('div_sel_bottom').offsetWidth-10;
		var pointerPositionLeft = findPos(document.getElementById('div_sel_bottom'));
		var pointerPositionRight = pointerPositionLeft[0]+pointerWidth;
		var preis_for_person = parseInt(8000*(parseInt(document.getElementById('pointer').style.left)/pointerWidth));

		var posxCursor = 0;
		try{
			posxCursor = event.pageX;//firefox		
			visualMoveSlider(posxCursor,pointerPositionLeft,pointerPositionRight,pointerWidth,preis_for_person);
		}catch(e){
			try{
			posxCursor = event.clientX+document.body.scrollLeft;//ie
			visualMoveSlider(posxCursor,pointerPositionLeft,pointerPositionRight,pointerWidth,preis_for_person);
			}catch(e){}
		}
	}
	
	//document.getElementById('abc').innerHTML = pointerPosition[0]+' : '+pointerPosition[1] +'  '+movingON+' '+pointerPositionRight;
}
function visualMoveSlider(cursorPositionX,pointerLeft01,pointerRight01,pointerWidth01,pointerPreis01){
	if(movingON){
		if(cursorPositionX <= pointerLeft01[0]){
			document.getElementById('pointer').style.left = 0+'px';
			document.getElementById('preis_cloud').innerHTML = 'dowolna';
			document.getElementById('select_preis').value = '';
			//mouseRelease(event);
		}else if(cursorPositionX >= pointerRight01){
			document.getElementById('pointer').style.left = pointerWidth01+'px';
			document.getElementById('preis_cloud').innerHTML = '8000 zł';
			//mouseRelease(event);
		}else{
		
			document.getElementById('pointer').style.left = ((cursorPositionX-10)-pointerLeft01[0])+'px';
			document.getElementById('preis_cloud').style.left = ((cursorPositionX)-pointerLeft01[0])+'px';
			document.getElementById('preis_cloud').innerHTML = pointerPreis01+' zł';
				//alert(document.getElementById('preis_cloud').style.left);
			 document.getElementById('select_preis').value = ''+putEURprice(pointerPreis01,euroPriceFromFile)+'';
		 }		
	}
}
function mouseClick(event){
//pressedButton
	if(document.getElementById('pointer')){
		movingON = true;
	}
}

function mouseRelease(event){  
//	pressedButton = 0;
		movingON = false;
}
/*function change_the_pointer_position(event){
		var pointerPosition = findPos(document.getElementById('pointer'));
		var pointerWidth = document.getElementById('div_sel_bottom').offsetWidth-10;
		var pointerPositionLeft = findPos(document.getElementById('div_sel_bottom'));
		var pointerPositionRight = pointerPositionLeft[0]+pointerWidth;
		var preis_for_person = parseInt(8000*(parseInt(document.getElementById('pointer').style.left)/pointerWidth));

		var posxCursor = 0;
	if(event.pageX){
		posxCursor = event.pageX;
		document.getElementById('pointer').style.left = ((posxCursor)-pointerPositionLeft[0])+'px';
		document.getElementById('preis_cloud').style.left = ((posxCursor)-pointerPositionLeft[0])+'px';
		document.getElementById('preis_cloud').innerHTML = preis_for_person+' zł';
		//alert(document.getElementById('preis_cloud').style.left);
		document.getElementById('select_preis').value = ''+putEURprice(preis_for_person,euroPriceFromFile)+'';
	}else{
		posxCursor = event.clientX+document.body.scrollLeft;
		document.getElementById('pointer').style.left = ((posxCursor)-pointerPositionLeft[0])+'px';
		document.getElementById('preis_cloud').style.left = ((posxCursor)-pointerPositionLeft[0])+'px';
		document.getElementById('preis_cloud').innerHTML = preis_for_person+' zł';
		//alert(document.getElementById('preis_cloud').style.left);
		document.getElementById('select_preis').value = ''+putEURprice(preis_for_person,euroPriceFromFile)+'';
	}
}*/
/*----------------------------------------------------------------------------*/
/*---------------suwak_ver2---------------------------*/
window.onload = function events(){
	try{
	if(IBE.req.preis){
		movMeId.style.left = parseInt(putPLNprice((IBE.req.preis*(skala.offsetWidth-10))/8000,RatesOfExchange['_DEF_']))+'px';
		movCloudId.style.left = parseInt(putPLNprice((IBE.req.preis*(skala.offsetWidth-10))/8000,RatesOfExchange['_DEF_']))+'px';
		movCloudId.innerHTML = ((putPLNprice(IBE.req.preis,RatesOfExchange['_DEF_']))+3)+' zł';	
	}
	if((IBE)&&(IBE.hidf.preis)){
		movMeId.style.left = parseInt(putPLNprice((IBE.hidf.preis.substr(2)*(skala.offsetWidth-10))/8000,RatesOfExchange['_DEF_']))+'px';
		movCloudId.style.left = parseInt(putPLNprice((IBE.hidf.preis.substr(2)*(skala.offsetWidth-10))/8000,RatesOfExchange['_DEF_']))+'px';
		movCloudId.innerHTML = ((putPLNprice(IBE.hidf.preis.substr(2),RatesOfExchange['_DEF_']))+3)+' zł';
	}
	}catch(e){}
};
document.onmouseup=mouseup;

function initSuwak(){
	document.onmousedown=coordinates;
}
function destroySuwak(){
	document.onmousedown=null;
}
function findPos(obj) {
	var curleft = curtop =  0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	return [curleft,curtop];
	}
}
function coordinates(e){
	if (e == null) { e = window.event;}
	var sender = (typeof( window.event ) != "undefined" ) ? e.srcElement : e.target;

	if (sender.id=="moveMe"){
		mouseover=true;
		pleft=parseInt(movMeId.style.left);
		ptop=parseInt(movMeId.style.top);
		xcoor=e.clientX;
		ycoor=e.clientY;
		document.onmousemove=moveImage;
		//document.onclick=moveImageToPoint;
		return false;
	}else { return false; }
}

function moveImage(e){
	var scaleWidth = skala.offsetWidth;
	var scalePositionLeft = findPos(skala);
	var pointerPositionRight = scalePositionLeft[0]+scaleWidth;
	var preis_for_person = parseInt(8000*(parseInt(movMeId.style.left)/scaleWidth));
if (e == null) { e = window.event;}
	movMeId.style.left=pleft+e.clientX-xcoor+"px";
	movCloudId.style.left=pleft+e.clientX-xcoor+"px";
	if(e.clientX<=scalePositionLeft[0]){
		movCloudId.innerHTML="dowolna";
		movMeId.style.left="0px";
		movCloudId.style.left="0px";
		cena.value = '';
	}else if(e.clientX>=pointerPositionRight){
		movCloudId.innerHTML="8000 zł";
		movMeId.style.left=scaleWidth+"px";
		movCloudId.style.left=scaleWidth+"px";
	}else{
		if(preis_for_person<0){
			movCloudId.innerHTML="dowolna";
		}else{
			movCloudId.innerHTML=parseInt(8000*(parseInt(movCloudId.style.left)/scaleWidth))+" zł";
			cena.value = ''+putEURprice(preis_for_person,RatesOfExchange['_DEF_'])+'';
		}
	}
	//movMeId.style.top=ptop+e.clientY-ycoor+"px";
return false;
}



/*
function moveImageToPoint(e){
	var scaleWidth = skala.offsetWidth;
	var scalePositionLeft = findPos(skala);
	var pointerPositionRight = scalePositionLeft[0]+scaleWidth;
	if (e == null) { e = window.event;}
	skala.onclick=movMeId.style.left=pleft+e.clientX-xcoor+"px";
	skala.onclick=movCloudId.style.left=pleft+e.clientX-xcoor+"px";
	movCloudId.innerHTML=parseInt(8000*(parseInt(movCloudId.style.left)/scaleWidth))+" zł";
	if(e.clientX<=scalePositionLeft[0]){
		movCloudId.innerHTML="dowolna";
		skala.onclick=movMeId.style.left="0px";
		skala.onclick=movCloudId.style.left="0px";
		cena.value = '';
	}else if(e.clientX>=pointerPositionRight){
		movCloudId.innerHTML="8000 zł";
		skala.onclick=movMeId.style.left=scaleWidth+"px";
		skala.onclick=movCloudId.style.left=scaleWidth+"px";
	}
	return false;
}
*/
function mouseup(e){
	document.onmousemove=null;
}

/*-------------------konwerter_cen---------------------------*/
function putEURprice(getPLNprice,RecalculateRatio){
	return parseInt(getPLNprice*RecalculateRatio);
}
function putPLNprice(getEURprice,RecalculateRatio){
	return parseInt(getEURprice/RecalculateRatio);
}

/*--------------selecty-----------------*/

