phoneImagePopUp = {

	popUpImage : function(e) {
		var e  = evt.fix(e);
		var a  = e.target;
		while (a.tagName!='A') {
			a = a.parentNode;
		}
		var w  = a.imgWidth;
		var h  = a.imgHeight; 
		var scrollbars = 'no';
		if ((screen.width > w)&&(screen.height > h)) {
			var left = (screen.width - w) / 2;
			var top  = (screen.height - h) / 2;
		} else {
			scrollbars = 'yes';
			var top 	= 0;
			var left = 0;
			w = screen.width;
			h = screen.height;
		}
	
		// rozdil mezi Netscape/mozilla a IE
		if (window.innerWidth) {
			imgWin = window.open('about:blank','', 'scrollbars='+scrollbars+', innerWidth='+w+', innerHeight='+h+', top='+top+', left='+left);
		}
		else {
			imgWin = window.open('about:blank','', 'scrollbars='+scrollbars+', width='+w+', height='+h+', top='+top+', left='+left);
		}
	
		imgWin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>');
		imgWin.document.write('<title>' + a.title+ '</title>');
		imgWin.document.write('<style media="screen" type="text/css">');
		imgWin.document.write('img {cursor: hand; cursor: pointer;}');
		imgWin.document.write('</style>');
		imgWin.document.write('</head>');
		imgWin.document.write('<body style="margin: 0; padding: 0;">');
		imgWin.document.write('<img src="'+a.href+'" onclick="window.close();" alt="Zav&#248;ít okno">');
		if (window.opera) {imgWin.document.write('<br>');}	// <BR> nakonci tam musi byt kvuli Opere
		imgWin.document.write('</body></html>');
		e.preventDefault();
		return false;
	},

	// pro Mozillu se musi vyckat na nahrani obrazku a az pak ho dostranit
	destroyImage : function(e) {
		var e   	= evt.fix(e);
if (document.all)	{var img 	= e.target;} else {var img = e.currentTarget}
		var body = document.getElementsByTagName('BODY')[0];
	
		img.anchor.imgWidth   = img.width;
		img.anchor.imgHeight  = img.height;
		body.removeChild(img);
		evt.add(img.anchor, "click", phoneImagePopUp.popUpImage);
	},

	init : function() {
		var anchors = document.getElementsByTagName('A');
		var body    = document.getElementsByTagName('BODY')[0];
		var img     = new Array;
		for (i=0; i<anchors.length; i++) {
			// projde jen linky na obrazky
			if (((anchors[i].href.indexOf('.jpg')!=-1)||(anchors[i].href.indexOf('.gif')!=-1)||(anchors[i].href.indexOf('.png')!=-1))&&(anchors[i].className!="noPopUp")) {
				img[i] = document.createElement('IMG');
				img[i].src = anchors[i].href;
				img[i].style.position   = "absolute"; // prednacte rozmery odkazovaneho obrazku
				img[i].style.top   					= "-10000px";
				img[i].style.left  					= "-10000px";
				body.appendChild(img[i]);
				img[i].anchor	=	anchors[i];
				evt.add(img[i], "load", phoneImagePopUp.destroyImage);			

				/*if (document.all) {
					anchors[i].imgWidth   = img[i].width;
					anchors[i].imgHeight  = img[i].height;
					body.removeChild(img[i]);
					evt.add(anchors[i], "click", phoneImagePopUp.popUpImage); //IEcku tohle staci
				}	
				else {
					img[i].anchor	=	anchors[i];
					evt.add(img[i], "load", phoneImagePopUp.destroyImage);			
				}	*/
			}	
		}
	}

}


var myDraqueInited = false;
var myDraqueStr = '';

scroller = {
	step 			: 16,
	viewW   : 632,
	
	timeout : null,
	
	slide			: function(where) {
		scroller.timeout = setInterval('scroller.move("'+where+'")',25);
	},
	
	init 			: function() {
		if (document.getElementById('scrollLeft')) {
			var scrollLeft 	= document.getElementById('scrollLeft');
			var scrollRight = document.getElementById('scrollRight');
			evt.add(scrollLeft, 'mousedown', function() {scroller.slide('right')});
			evt.add(scrollRight, 'mousedown', function() {scroller.slide('left')});
			evt.add(scrollLeft, 'mouseup', function() {clearInterval(scroller.timeout)});
			evt.add(scrollRight, 'mouseup', function() {clearInterval(scroller.timeout)});
			evt.add(scrollLeft, 'mouseout', function() {clearInterval(scroller.timeout)});
			evt.add(scrollRight, 'mouseout', function() {clearInterval(scroller.timeout)});
		}	
	},

	move 			: function(where) {
		var content = document.getElementById('scrollerContent');
		/* alert(content.offsetWidth); */
		var left    = (parseInt(content.style.left));
		if (where == 'left') {
if (Math.abs(left-scroller.step) + scroller.viewW <= content.offsetWidth) {content.style.left = left - scroller.step + 'px';}
		else {content.style.left = (scroller.viewW-content.offsetWidth+4)+'px';}
}
		if (where == 'right') {
if (left+scroller.step<=0) {content.style.left = left + scroller.step + 'px';}
else {content.style.left='0px';}
}
}
}


function callEval(str) {
		myDraqueStr = str;
  if(myDraqueInited) {
    eval(str);
  }
}

function Draque(elm, min, max) {

	this.elm = elm;
	this.min = 0;
	this.max = 0;
	
	if (min) {this.setMin(min);}
	if (max) {this.setMax(max);}
}

Draque.prototype = {
	
	setMin : function(n) {
		if (!isNaN(n)) {
			this.min = n;
			if (this.elm) {this.elm.setMin(n);}
			this.onChange();
			return n;
		}
		return false;
	},
	
	setMax : function(n) {
		if (!isNaN(n)) {
			this.max = n;
			if (this.elm) {this.elm.setMax(n);}
			this.onChange()	;
			return n;
		}
		return false;
	},

	set : function(m, n) {
		return (this.setMin(m) && this.setMax((n) ? n : m));
	},

	getMin : function() {
		return this.min;
	},
	
	getMax : function() {
		return this.max;
	},
	
	get : function() {
		return {min: this.min, max: this.max};
	},

	change : function(m, n) {
		if (!isNaN(m)) {this.min = m;}
		if (!isNaN(n)) {this.max = n;}
		this.onChange();
		return ((!m || (m && !isNaN(m))) && ( !n || (n && !isNaN(n))));
	},
	
	onChange : function() {
		return;
	}

}

carouselO2 = {
	init : function() {
		if (document.getElementById('phoneEquipment')) {
			var equipment = document.getElementById('phoneEquipment');
			var expander  = document.getElementById('phoneEquipment-expander');
			evt.add(expander, 'click', carouselO2.change);
			carouselO2.hide();
			var checkboxes = equipment.getElementsByTagName('INPUT');
			for(var i = 0; i < 6; i++) {
				evt.add(checkboxes[i], 'change', carouselO2.show);
			}
		}
	},

	hide : function() {
		var equipment = document.getElementById('phoneEquipment');
		var expander  = document.getElementById('phoneEquipment-expander');
		cls.add(equipment, 'hide');
		expander.innerHTML = ostatni_vlastnosti;
	},

	show : function() {
		var equipment = document.getElementById('phoneEquipment');
		var expander  = document.getElementById('phoneEquipment-expander');
		cls.remove(equipment, 'hide');
		expander.innerHTML = schovat_ostatni_vlastnosti;
	},

	change : function(e) {
		var equipment = document.getElementById('phoneEquipment');
		if (cls.has(equipment, 'hide')) {
			carouselO2.show();
		} else {
			carouselO2.hide();
		}
	}
}

var myDraque = null;

function drInit() {
	myDraque = new Draque(document.getElementById('draque'));

	myDraque.onChange = function() {
		document.getElementById('priceFrom').value = myDraque.min;
		document.getElementById('priceTo').value = myDraque.max;
		if (document.getElementById('priceToString')) {
			document.getElementById('priceFromString').innerHTML = document.getElementById('priceFrom').value;
			document.getElementById('priceToString').innerHTML = document.getElementById('priceTo').value;
		}
	}
 myDraqueInited = true;
 if(myDraqueStr!='') {
   callEvent(myDraqueStr);
 }
}



evt.add(window, "load", phoneImagePopUp.init);
evt.add(window, "load", drInit);
evt.add(window, 'load', carouselO2.init);
evt.add(window, "load", scroller.init);