
String.prototype.startsWith = function(s) {return (s==null)? false : (this.substring(0, s.length)==s);}
String.prototype.endsWith = function(s) {return (s==null)? false : (this.substr(this.length-s.length,s.length)==s);}

/* utils */
hasClass = function(elm, cls) {
	if (!elm || !elm.className) return null;
	return (' '+elm.className+' ').indexOf(' '+cls+' ')+1;
}
changeClass = function(elm, oldcls, newcls) {
	if (!elm) return null;
	var c = elm.className.split(' ');
	for (var i=0;i<c.length;i++) {
		if (c[i]==oldcls || c[i]==newcls || c[i]=='') c.splice(i,1);
	}
	c.push(newcls);
	elm.className = c.join(' ');
}
toggleClass = function(elm, cls) {
	if (hasClass(elm,cls)) changeClass(elm,cls,'');
	else changeClass(elm,'',cls);
}
__ebi = function(id) {
	var elm = document.getElementById(id);
	if (arguments.length>1) {
		var elms = {};
		elms[id] = elm;
		for (var i=1;i<arguments.length;i++) elms[arguments[i]] = __ebi(arguments[i]);
		return elms;
	}
	return elm;
}
__ebt = function(tag,elm) {
	return (elm? elm : document).getElementsByTagName(tag);
}
/* forms */
submitChecktrip = function(formObject) {
	var alerts = [];
	if (formObject['RECORD_LOCATOR'].value.length!=6) alerts.push(formObject['alerts_record'].value);
	if (formObject['LAST_NAME'].value=="") alerts.push(formObject['alerts_lastname'].value);
	if (alerts.length>0) {
		alert(formObject['alerts'].value+"\n- "+alerts.join("\n- "));
		return false;
  }
	formObject.target = "_blank";
  return true;
}
submitTimetable = function(link, direction, f) {
	var sel = f.options[f.selectedIndex].value;
	if (sel != "all" && sel != "") {
		if (link.indexOf("?") > -1) link += "&";
		else link += "?";
		link += direction + "=" + sel;
	}
	window.location = link;
}

/* enhance */
swaplines = function() {
	var uls = __ebt('ul');
	var cls, div, lis;
	var LIST_CLS = 'swaplines';
	for (var i=0;i<uls.length;i++) {
		cls = uls[i].className;
		if (cls.indexOf(LIST_CLS)>=0) {
			cls =  cls.substr(cls.indexOf(LIST_CLS));
			cls = (cls.indexOf(' ')>=0)? cls.substr(0,cls.indexOf(' ')) : cls;
			div = (cls.length>LIST_CLS.length)? parseInt(cls.substr(LIST_CLS)) : 2;
			if (isNaN(div)) div = 2;
			lis = uls[i].getElementsByTagName('li');
			for (var j=0;j<lis.length;j++) {
				if (lis[j].parentNode==uls[i]) lis[j].className += ' itm'+(j%div);
			}
		}
	}
}
switchframes = function(linkElement) {
	var frame = (linkElement.href.indexOf('check')>=0)? 'check' : 'book';
	var elms = __ebi('book','bookf','check','checkf');
	for (var p in elms) {
		if (!elms[p]) continue;
		toggleClass(elms[p],'selected');
	}
	return false;
}
enhanceLinks = function(classNames) {
	var elms = __ebt("a");
	var elm;
	for (var i=0;i<elms.length;i++) {
		elm = elms[i];
		for (var j=0;j<classNames.length;j++) {
			if (hasClass(elm,classNames[j])) {
				fn = eval(classNames[j]);
				if (typeof(fn)=='function') elm.onclick = function() {return fn(this);}
			}
		}
	}
}
frontScroller = function() {
	var wp = document.getElementById('quick-wrapper');
	if (wp) wp.className = 'js';
	var mt = document.getElementById('front-scroller');
	if (mt) {
		var hd = mt.getElementsByTagName('div')[0];
		var mwd = parseInt(hd.innerHTML.length) * -5;
		function scroll(mwd,hd) {
			var or = 1;
			mt.onmouseover = function() {clearInterval(s2);}
			mt.onmouseout = function() {s2 = setInterval(s,200);}
			var s = function() {
				if(!hd.style.marginLeft) {
					var mrg = 0;
				} else {
					var mrg = parseInt(hd.style.marginLeft);
				}
				if(or == 1) {
					if(mrg < mwd) {
						or = 0;
					} else {
						mrg -= 5;
					}
				} else {
					mrg = 410;
					or = 1;
				}
				hd.style.marginLeft = mrg + "px";
			}
			var s2 = setInterval(s,200);
		}
		scroll(mwd,hd);
	}
}

jump = function(url) {
	if (url != null && url != "") {
		return !(window.location.href = url);
	} else {
		return false;
	}
}
show = function(id) {
	document.getElementById(id).style.visibility = "visible";
}

hide = function(id) {
	document.getElementById(id).style.visibility = "hidden";
}

displaySwitch = function(id) {
   var elm = document.getElementById(id);
   if(elm.style.display != 'block'){
      elm.style.display = 'block';
   } else {
      elm.style.display = 'none';
   }
}

onFinishedPlaying = function() {
   var elm = document.getElementById('floater');
   if(elm){
      elm.style.display = 'none';
   }
}

dontDisplayFloaterAnymore = function(){
   createCookie("flower-floater-cookie","noFlowerFloater",43200);
   onFinishedPlaying();
}

readCookie = function(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
createCookie = function(name,value,min) {
	if (min) {
		var date = new Date();
		date.setTime(date.getTime()+(min*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
eraseCookie = function(name) {
	createCookie(name,"",-1);
}

iamGonnaBeGoneForever = function(name,value,min) {
	createCookie(name,value,min);
	window.location="/sl/index.cp2";
}

createUserTypeCookie = function(value) {
	eraseCookie('simobil-user-type');
	createCookie('simobil-user-type',value,525600);
	var parent = document.getElementById('user-type');
	if (parent) {
		var elms = parent.getElementsByTagName('li');
		if (elms) {
			for(var i = 0;i < elms.length; i++) {
				if(value == elms[i].id.substr(1,2)) {
					elms[i].className = 'active';
				} else {
					elms[i].className = '';
				}
			}
		}
	}
}
/* prepare the search filters */
prepareAF = function() {
	if(!document.getElementById) return false;
	if(document.getElementById('mf')) {
		var afs = document.getElementById('mf');
		var cnt = document.getElementById('filters');
		var acn = document.getElementById('more-filters');

		acn.className = '';
		adl = cnt.getElementsByTagName('li');
		for(var i=0;i < adl.length;i++) {
			if(adl[i].className.startsWith('additional')) {
				cls = adl[i].className;
				adl[i].className = 'hidden ' + cls;
			}
		}
		afs.onclick = function af() {
			if(cnt) {
				adl = cnt.getElementsByTagName('li');
				for(var i=0;i < adl.length;i++) {
					if(adl[i].className.startsWith('hidden')) {
						if(adl[i].style.display === 'block') {
							adl[i].style.display = 'none';
							afs.className = 'closed';
							afs.innerHTML = 'Več funkcij';
						} else {
							adl[i].style.display = 'block';
							afs.className = 'open';
							afs.innerHTML = 'Manj funkcij';
						}
					}
				}
				return false;
			}
		}
	}
}

/* populating accorsion links */
populateAccordionLinks = function() {
	var arrLinks = document.getElementsByTagName('a');
	var arrBlocks = document.getElementsByTagName('div');
	for(var i=0; i<arrLinks.length; i++) {
		var link = arrLinks[i];
		var iH = link.href.indexOf('#header');
		if(iH != -1) {
			if(document.getElementById("accordionHolder")) {
				attachAccordionClickEvent(link, false);
			} else {
				attachAccordionClickEvent(link);
			}
		}
	}
}

attachAccordionClickEvent = function(el, co) {
	el.onclick = function() {
		var lel;
		if(this.href) {
			var iH = this.href.indexOf('#header');
			lel = document.getElementById(this.href.substr(iH+1));
		}
		accordion.process(lel, co);
	}
}

/* populating keyvisual with flash */
populateKeyvisual = function() {
	var elm = document.getElementById('keyvisual');
	if (elm) {
		var params = {
			scale: "noborder",
			align: "left",
			bgcolor: "#ffffff"
		}
		var flashvars = {
			xmlPlaylist: "/sl/keyvisual.cp2?cid=7E4E59E3-C3C9-8789-8EFA-2E0A54CD045B"
		}
		swfobject.embedSWF("/_common/flash/keySlideShow.swf", "keyvisual", "438", "203", "9", false, flashvars, params);
	}
}

/* populating new keyvisual with flash */
populateNewKeyvisual = function() {
	var elm = document.getElementById('keyvisual-new');
	if (elm) {
		var params = {
			scale: "noborder",
			align: "left",
			bgcolor: "#ffffff"
		}
		var flashvars = {
			xmlPlaylist: "/sl/keyvisual.cp2?cid=7E4E59E3-C3C9-8789-8EFA-2E0A54CD045B"
		}
		swfobject.embedSWF("/_common/flash/keySlideShow.swf", "keyvisual-new", "438", "203", "9", false, flashvars, params);
	}
}

populateKeyvisualFront = function() {
  var elm = document.getElementById('keyvisual_front_holder');
  if (elm) {
	  var params = {
		  scale: "noborder",
		  align: "left",
		  bgcoor: "#ffffff",
		  wmode: "transparent"
	  }
	  var flashvars = {
		  playlistXML: "/sl/keyvisual_front.cp2?cid=7E4E59E3-C3C9-8789-8EFA-2E0A54CD045B"
	  }
	  swfobject.embedSWF("/_common/flash/keySlideShowFront.swf", "keyvisual_front_holder", "438", "203", "9", false, flashvars, params);
  }
}

populateKeyvisualSimost = function() {
	var elm = document.getElementById('keyvisual-simost');
	if (elm) {
		var f = new Flash('/_common/flash/keySlideShow.swf',9,'662','380','#ffffff');
		f.addVar('xmlPlaylist','/sl/keyvisual.cp2?cid=7E4E59E3-C3C9-8789-8EFA-2E0A54CD045B');
		f.addParam('scale','noborder');
		f.addParam('align','left');
		f.addParam('wmode','transparent');
		f.write('keyvisual-simost');
	}
}
/* populating flash calculator with flash */
populateCalculator = function() {
	var elm = YAHOO.util.Dom.getElementsByClassName('flash-calculator')[0];
	if (elm != null) {
		elm.id = 'flash-calculator';
		var f = new Flash('/_sl/flash/calculator.swf',6,'300','320','#ffffff');
		f.write('flash-calculator');
	}
}

/* populating flash tree with flash */
populateFlashTree = function() {
	var elm = document.getElementById('tree');
	if (elm != null) {
//		if(readCookie("flash-tree")){
//			window.location="/sl/index.cp2";
//		} else {
			var f = new Flash('/_sl/flash/tree.swf',8,'1007','675','#ffffff');
			f.addVar('xmlThought', '/thoughtsXML.cp2');
			f.write('tree');
//		}
	}
}

/* populating flash tree with flash */
populateNyGreetings = function() {
	var elm = document.getElementById('nygreetings');
	if (elm != null) {
   if(readCookie("flash-tree")){
      window.location="/sl/index.cp2";
    } else {
       swfobject.embedSWF("/_sl/flash/voscilnica_02.swf", "nygreetings", "100%", "100%", "9");
    }
	}
}

/* populating coverage map with flash */
populateCoverageMap = function() {
    var elm = $("#coverage-map");
    if (elm.length > 0){
        swfobject.embedSWF("/_sl/flash/coverage_map.swf", "coverage-map", "640", "550", "9");
    }
}

/* populating bb_bold flash */
populateBold9700 = function() {
    var elm = $("#bold_flash");
    if (elm.length > 0){
        swfobject.embedSWF("/_common/flash/bb_bold_9700_500x400.swf", "bold_flash", "654", "400", "9");
    }
}
/* populating network map with flash */
populateNetworkMap = function() {
    var elm = $("#network-map");
    if (elm.length > 0){
        var params = {};
        var flashvars={
            dataxml: "/sl/networkMap.cp2?cid=7E4E59E3-C3C9-8789-8EFA-2E0A54CD045B"
        }
        swfobject.embedSWF("/_sl/flash/map.swf", "network-map", "637", "248", "9", false, flashvars, params);
    }
}

/* populating bb_bold flash */
populateMuziqApril = function() {
    var elm = $("#muziqApril");
    var params = {};
    var flashvars={
      source: "/_sl/flash/Music/MUZIQ_april_2010.flv",
      preview: "/_sl/images/muziq_april.jpg"
    };
    swfobject.embedSWF("/_common/flash/video_player.swf", "muziqApril", "660", "375", "8.0.0", false, flashvars, params);
}
/*  */
openUnit = function(xhrsrc, src) {
	var xhr = _xml();
	if (!xhr || !document.getElementById) {
		window.location.href = src;
	} else {
		xhr.open("GET", xhrsrc, true);
		xhr.onreadystatechange = function() {
			if (xhr.readyState==4) {
				if (xhr.status == 200) {
					a = document.createElement("div");
					a.innerHTML = xhr.responseText;
					var u = document.getElementById('orgunits');
					var fi = document.getElementById('flashinstruct');
					if (u) u.innerHTML = a.getElementsByTagName("div")[0].innerHTML;
					if (fi) fi.style.display = 'none';
				} else {
					window.location.href = src;
				}
			}
		}
		xhr.send(null);
	}
}

/* injecting back to phone list link */
injectBackToPhoneList = function() {
	var elm = document.getElementById('back-to-phone-list');
	var uri = '';
	if (elm != null && uri != null && uri != '') {
		var link = elm.getElementsByTagName('a')[0];
		if (link != null) {
			link.href = uri;
			elm.style.display = 'block';
		}
	}
}

/* displaying inBasket sign in phones list */
displayInBasket = function() {
	var phones = [];
	if (phones != null && phones.length > 0) {
		for (var i = 0, j = phones.length; i < j; i++) {
			var id = 'phone-' + phones[i];
			var elm = document.getElementById(id);
			if (elm != null) {
				var uls = elm.getElementsByTagName('ul');
				for (var m = 0, n = uls.length; m < n; m++) {
					var ul = uls[m];
					if (ul.className == 'tags') {
						var lis = ul.getElementsByTagName('li');
						for (var k = 0, l = uls.length; k < l; k++) {
							var li = lis[k];
							if (li.className == 'comparison') {
								li.innerHTML = 'Telefon je na seznamu primerjav';
								li.className = 'comparison inbasket'
								break;
							}
						}
						break;
					}
				}
			}
		}
	}
}

/* hiding and showing relevant data in the PNT form */
hidePNTformData = function() {
	var cType = document.getElementById('pnt-contract-type')
	var subv = document.getElementById('pnt-subvention')
	if (cType != null && subv != null) {
		cType.style.display = 'none';
		subv.style.display = 'none';
		showRelevantPNTData();
	}
}
showRelevantPNTData = function() {
	var contractDate = document.getElementById('contractDate')
	var cType = document.getElementById('pnt-contract-type')
	var cTypeSmall = document.getElementById('pnt-contract-type-small')
	var subv = document.getElementById('pnt-subvention')
	var subvSmall = document.getElementById('pnt-subvention-small')
	if (cType != null && subv != null && cTypeSmall != null && subvSmall != null && contractDate != null) {
		cType.style.display = 'none';
		subv.style.display = 'none';
		var chosenDate = contractDate.value;
		if (chosenDate != null && chosenDate != '' && chosenDate.length == 10) {
			var day = new Number(chosenDate.substr(0, 2));
			var month = new Number(chosenDate.substr(3, 2)) - 1;
			var year = new Number(chosenDate.substr(6, 4));
			var date = new Date();
			date.setHours(0, 0, 0, 0);
			date.setDate(day);
			date.setMonth(month);
			date.setYear(year);
			var thresholdDate = new Date();
			thresholdDate.setHours(0, 0, 0, 0);
			thresholdDate.setDate(28);
			thresholdDate.setMonth(4);
			thresholdDate.setYear(2007);
			if (date < thresholdDate) {
				cType.style.display = 'block';
				cTypeSmall.style.display = 'none';
			} else {
				subv.style.display = 'block';
				subvSmall.style.display = 'none';
			}
		}
	}
}


/* showing/hiding the property tab */


/* toggle the comparison data */
var toggleCompDataOnClick = function() {
	var bl = document.getElementById('bl-'+this.id.substr(3));
	if(bl.className === 'hidden') {
		bl.className = '';
	} else {
		bl.className = 'hidden';
	}
}
toggleCompData = function() {
	if(!document.getElementById('comparing-tables')) return false;
	var ct = document.getElementById('comparing-tables');
	var els = ct.getElementsByTagName('th');
	for (var i=0;i < els.length;i++) {
		if(els[i].id.startsWith('sw-')) {
			var sw = document.getElementById(els[i].id);
			sw.onclick = toggleCompDataOnClick;
		}
	}
}
/* frontpage tabs */
var toggleFrontPageTab = function() {
	clsid = this.className.substr(1,1);
	el = document.getElementById('qa-link-'+clsid);
	/* tab color */
	var qtc = document.getElementById('quick-access-tabs');
	var tabs = qtc.getElementsByTagName('li');
	for (var i=0;i < tabs.length;i++) {
		if(tabs[i].className.endsWith('ui-tabs-selected ui-state-active')) {
			j = i + 1;
			tabs[i].className = "p" + j + " ui-state-default ui-corner-top ";
		}
	}
	this.className = this.className + " ui-tabs-selected ui-state-active";
	/* show div */
	var els = YAHOO.util.Dom.getElementsByClassName('tab','div');
	for (var i=0;i < els.length;i++) {
		//if(els[i].className.endsWith('active')) {
			els[i].className = 'tab ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide';
		//}
	}
	if (el != null) el.className = "tab ui-tabs-panel ui-widget-content ui-corner-bottom";
	return false;
}
toggleFPTabs = function() {
	if(!document.getElementById('quick-access-tabs')) return false;
	var qtc = document.getElementById('quick-access-tabs');
	var els = qtc.getElementsByTagName('li');
	for (var i=0;i < els.length;i++) {
		els[i].onclick = toggleFrontPageTab;
	}
}
tbc = function(ut) {
	if(readCookie('simobil-user-tbpref')) {
		return false;
	} else {
		return TB.lh(this.href,tf,ut);
	}
}
writeRememberCookie = function() {
	tbr = document.getElementById('tb-remember');
	if(tbr.checked) {
		eraseCookie('simobil-user-tbpref');
		createCookie('simobil-user-tbpref','yes',43200);
	} else {
		eraseCookie('simobil-user-tbpref');
	}
}

/* thickbox */
TB = {
	s:false, // set up
	_:function(s,d) { // extend(sourceObject, destinationObject)
		for (var p in s) d[p] = s[p];
	},
	ce:function(t,a) { // createElement(tag, attributes)
		var e = document.createElement(t);
		this._(a,e);
		return e;
	},
	sc:function(o) { // setcontent(responseObject)
		var elm = o.argument.e.h;
		elm.innerHTML = o.responseText;
	},
	fc:function(o) { // failedcontent(responseObject)
		o.argument.cl();
	},
	tv:function(t,v) { // togglevisibility(tag,visibility)
		var e = document.getElementsByTagName(t);
		for (var i=0,j=e.length;i<j;i++) {
			e[i].style.visibility = (v)? 'visible' : 'hidden';
		}
	},
	cl:function() { // close
		clearInterval(this.i);
		this.e.c.style.display = 'none';
		this.tv('object',true);
		this.tv('embed',true);
		this.tv('select',true);
	},
	op:function() { // open
		var t = this;
		this.i = setInterval(function(){t.ss();},500);
		this.e.c.style.display = 'block';
		this.tv('object',false);
		this.tv('embed',false);
		this.tv('select',false);
	},
	su:function() { // setup
		if (this.s) return;
		var d = document;
		var b = d.getElementsByTagName('body')[0];
		var c = b.appendChild(this.ce('div',{id:'tb-cover'}));
		this.e = { // elements
			c:c, // cover
			b:c.appendChild(this.ce('div',{id:'tb-back'})), // back
			h:c.appendChild(this.ce('div',{id:'tb-holder'})) // holder
		};
		this.s = true;
	},
	lh:function(u,tf,ut) { // launch(href)
		this.su();
		this.ss();
		if (typeof(tf)=='function') u = tf(ut);
		this.rq = YAHOO.util.Connect.asyncRequest('GET', u, {success:this.sc, failure:this.fc, argument:this}, null);
		this.op();
		return false;
	},
	gs:function() { // getScroll
		var r = {y:0,x:0};
		var w = window;
		var d = document;
		if (w.pageYOffset) {
			r.y = w.pageYOffset;
			r.x = w.pageXOffset;
		} else {
			var b = (d.documentElement && d.documentElement.scrollTop)? d.documentElement : d.body;
			if (b) {
				r.y = b.scrollTop;
				r.x = b.scrollLeft;
			}
		}
		return r;
	},
	ss:function() { // setstage
		this.e.c.style.display = 'none';
		var h = YAHOO.util.Dom.getDocumentHeight();
		var w = YAHOO.util.Dom.getDocumentWidth();
		this.e.c.style.display = 'block';
		var ss = this.gs();
		var vh = YAHOO.util.Dom.getViewportHeight();
		this._({width:w+'px',height:h+'px'},this.e.c.style);
		var t = ss.y+(vh-parseInt(YAHOO.util.Dom.getStyle(this.e.h,'height')))/2;
		this._({top:t+'px'},this.e.h.style);
	}
}
/* manage thickbox */
tf = function(ut) {
	return('/_sl/pages/thickbox.jsp?ut=' + ut);
}

/* standards based external links */
externalLinks = function() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}
}
popupWindow = function(url,w,h) {
	if (document.all) {
		var xMax = screen.width, yMax = screen.height;
	} else {
		if (document.layers) {
			var xMax = window.outerWidth, yMax = window.outerHeight;
		} else {
			var xMax = 640, yMax=480;
		}
	}
	var xOffset = (xMax/2) - (w/2), yOffset = (yMax/2) - (h/2) - 50;
	windowprops = "height="+h+",width="+w+",screenX="+xOffset+",screenY="+yOffset+",top="+yOffset+",left="+xOffset+",location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,titlebar=no";
	window.open(url, "Anketa", windowprops);
}

displayFloater = function() {
	var elm = document.getElementById('floater');
	if (elm && !readCookie('flower-floater-cookie')) {
			var width = '100%';
			var height = '100%';
			if ($.browser.msie && $.browser.version == '6.0') {
				width = document.body.offsetWidth;
				height = document.body.offsetHeight;
				hideOverlayingObjects();
			}
			var params = {
				wmode: 'transparent'
			}
			var flashvars = {}
			swfobject.embedSWF('/_common/flash/cestitka.swf', 'floater', width, height, '9.0.0', false, flashvars, params);
	} else if (elm && readCookie('flower-floater-cookie')){
        $("#floater").remove();
    }
}

setFloatingHeight = function(height) {
	document.getElementById("floater").style.height = height + "px";
}

setFloatingWidth = function(width) {
	document.getElementById("floater").style.width = width + "px";
}

hideIntro = function() {
	var elm = document.getElementById('floater');
	if (elm) {
		if ($.browser.msie && $.browser.version == '6.0') {
			width = document.body.offsetWidth;
			height = document.body.offsetHeight;
			displayOverlayingObjects();
		}
		elm.style.width = '456px';
		elm.style.height = '428px';
	}
}

showForm = function() {
	var elm = document.getElementById('floater');
	if (elm) {
		var width = '100%';
		var height = '100%';
		if ($.browser.msie && $.browser.version == '6.0') {
			width = document.body.offsetWidth;
			height = document.body.offsetHeight;
			hideOverlayingObjects();
		}
		elm.style.width = width;
		elm.style.height = height;
	}
}

hideOverlayingObjects = function() {
	var dds = document.getElementsByTagName('select');
	if (!dds) return;
	for (var i = 0, j = dds.length; i < j; i++) {
		if (!(dds[i].style.display == 'none')) {
			dds[i].rel = 'lb-disabled';
			dds[i].title = dds[i].style.display;
			dds[i].style.display = 'none';
		}
	}
}

displayOverlayingObjects = function() {
	var dds = document.getElementsByTagName('select');
	if (!dds) return;
	for (var i = 0, j = dds.length; i < j; i++) {
		if (dds[i].rel == 'lb-disabled' && dds[i].style.display == 'none') {
			var dspl = dds[i].title;
			if (!dspl || dspl == '') dspl = 'block';
			dds[i].style.display = dspl;
			dds[i].rel = '';
		}
	}
}

var prepareFaqVideos = function() {
	var videos = $('li .faq-video');
	var params = {};
	for (var i = 0, j = videos.length; i < j; i++) {
		var id = videos[i].id;
		var uid = id.replace('video-', '');
		var flashvars = {
			source: '/bin?bin.svc=obj%26bin.id=' + uid + '%26.flv',
			preview: ''
		};
		swfobject.embedSWF('/_common/flash/video_player.swf', id, '300', '240', '8.0.0', false, flashvars, params);
	}
};

var prepareFaqLiveSearch = function() {
    if ($('form.faq #searchQuery').length > 0){
	$('form.faq #searchQuery').autocomplete('/faqLiveSearch/sl/', {
		minChars: 3,
		matchContains: true,
//		cacheLength: 1,
//		matchSubset: false,
		width: 204
	});
    }
    if ($('form.faq #searchBusinessQuery').length > 0){
	$('form.faq #searchBusinessQuery').autocomplete('/faqBusinessLiveSearch/sl/', {
		minChars: 3,
		matchContains: true,
//		cacheLength: 1,
//		matchSubset: false,
		width: 204
	});
    }
};

var prepareLightbox = function() {
    if ($('#faq-results ul.images a').length > 0){
        $('#faq-results ul.images a').lightBox();
    }
    if ($('#htc_gallery a').length > 0){
        $('#htc_gallery a').lightBox();
    }
    if ($('#accessories div.image a').length > 0){
        $('#accessories div.image a').lightBox();
    }
    if ($('#ljm_content4 a').length > 0){
	$('#ljm_content4 a').lightBox();
    }
};



var makeFaqClick = function(title) {
	$.post("/faqClick.cp2?Title=" + title);
}

var prepareFaqTogglers = function() {
    $('#faq-results dl dt').each(
        function(){
            var qid = $(this).attr("id");
		    $('#' + qid).click(function () {
			makeFaqClick(this.innerHTML);
			faqToggle(this.id);
		    });
		    $('#' + qid).addClass('toggler');
            }
        );
    var link = window.location.href;
    if (link.indexOf("searchQuery") > -1) {
        $('#faq-results dl dd dl dd').hide();
        $('#faq-results dl dd:visible').hide();
	} else {
        $('#faq-results dl dd dl dd').hide();
    }
};

var faqToggle = function(id, skip) {
	var elm = $('#' + id);
	if (elm) {
		var levelClass = $('#' + id).parent().attr('class');
		if (!skip) {
			var opens = $('#faq-results dl.' + levelClass + ' > dt.open');
			for (var i = 0, j = opens.length; i < j; i++) {
				if (id != opens[i].id) {
					faqToggle(opens[i].id, true);
				}
			}
		}
		var aid = id.replace('toggler', 'togglee');
		if ($('#' + id).hasClass('open')) {
			$('#' + aid).slideUp();
			$('#' + id).removeClass('open');
		} else { /*
			var levelNum = parseInt(levelClass.replace('level-', '')) + 1;
			var tglr = $('#' + aid + ' dl.level-' + levelNum + ' dt');
			var faqs = $('#' + aid + ' dl.level-' + levelNum + ' > dt.faq');
			var cats = $('#' + aid + ' dl.level-' + levelNum + ' > dt.category.open');
			if (tglr.length > 0 && faqs.length == 0 && cats.length == 0) {
				faqToggle(tglr[0].id);
			} */
			$('#' + aid).slideDown();
			$('#' + id).addClass('open');
		}
	}
}

manipulateFew = function(ids) {
	for (var i=0,j=ids.length;i<j;i++) {
		var elm = document.getElementById(ids[i]);
		if(elm) {
			if(elm.className.startsWith('col-')) {
				var d = parseInt(elm.className.split('-')[1]);
			} else {
				var d = 3;
			}
		}
		if (!elm) continue;
		var lis = document.getElementsByTagName('li');
		// first pass - get max height
		var h = [];
		for (var k=0,l=lis.length;k<l;k++) {
			if (lis[k].parentNode!=elm) continue;
			var th = parseFloat(getComputedStyleProperty(lis[k],'height'));
			if (isNaN(th)) th = parseFloat(lis[k].clientHeight);
			var hi = Math.ceil(parseInt(lis[k].className.substr(1))/d)-1;
			if (h[hi]==null || th>h[hi]) h[hi] = th;
		}
		// second pass - set height
		for (var k=0,l=lis.length;k<l;k++) {
			if (lis[k].parentNode!=elm) continue;
			var hi = Math.ceil(parseInt(lis[k].className.substr(1))/d)-1;
			if (h[hi]>0) lis[k].style.height = Math.ceil(h[hi])+'px';
		}
	}
}
getComputedStyleProperty = function(elm,prop) {
	var style = [];
	if (elm.currentStyle) style = elm.currentStyle;
	else if (window.getComputedStyle) style = window.getComputedStyle(elm,'');
	if (style[prop]) return style[prop];
	return 0;
}
printContent = function() {
	var p = YAHOO.util.Dom.getElementsByClassName('print-content')[0];
	if(p) {
		p.className = 'print-content';
		var a = p.getElementsByTagName('a')[0];
		a.onclick = function() {
			window.print();
			return false;
		}
	}
}
switchInputContent = function(elm, flag){
	if(!elm) return false;
	if(flag && ((!elm.temp || elm.temp == elm.value) && (elm.value == 'Elektronski naslov prijatelja/ice' || elm.value == 'Vaše ime') )) {
		elm.temp = elm.value;
		elm.value = '';
	} else if(!elm.value || elm.value == ''){
		if(!elm.temp) elm.temp = '';
		elm.value = elm.temp;
	}
}
setFrontThoughtInputFields = function(){
	var name = document.getElementById('front-thought-name');
	var email = document.getElementById('front-thought-email');
	if(!name ||!email) return;
	name.onfocus  = function(){ return switchInputContent(this, true); };
	name.onblur  = function(){ return switchInputContent(this, false); };
	email.onfocus  = function(){ return switchInputContent(this, true); };
	email.onblur  = function(){ return switchInputContent(this, false); };
}

var scrollPosition = 0;
var scrollWindowSize = 1;
var layerCount = 1;
var offsetLeft = 0;
var elementCount = null;
var scrollLength = 426;
var scrollWidth = null;
var totalScrollWidth = null;
var scrollInterval = 3000;
var interval = null;
var enableScroll = true;
var visibleItems = null;

var ScrollHeight = 237;
var SmartPhonesTop = 0;
var SmartPhonesHeight = 0;
var NewPhonesTop = 0;
var NewPhonesHeight = 0;
var ONEEURPhonesTop = 0;
var ONEEURPhonesHeight = 0;


function doScrollLeftNew() {
	if(!enableScroll) return false;

	enableScroll = false;

	if(SmartPhonesTop == -SmartPhonesHeight + ScrollHeight) {SmartPhonesTop = 0; $('#ActionSmartPhones').css('top', '0px');};
	if(NewPhonesTop == -NewPhonesHeight + ScrollHeight) {NewPhonesTop = 0; $('#ActionNewPhones').css('top', '0px');};
	if(ONEEURPhonesTop == -ONEEURPhonesHeight + ScrollHeight) {ONEEURPhonesTop = 0; $('#Action1EURPhones').css('top', '0px');};

	SmartPhonesTop -= ScrollHeight;
	NewPhonesTop -= ScrollHeight;
	ONEEURPhonesTop -= ScrollHeight;

	$('#ActionSmartPhones').animate({'top' : SmartPhonesTop + 'px'}, ScrollHeight * 3, 'linear', function () { enableScroll = true; 	if(SmartPhonesTop == -(SmartPhonesHeight - ScrollHeight)) {$('#ActionSmartPhones').css('top', '0px'); SmartPhonesTop = 0;}});
	$('#ActionNewPhones').animate({'top' : NewPhonesTop + 'px'}, ScrollHeight * 3, 'linear', function () { enableScroll = true; 	if(NewPhonesTop == -(NewPhonesHeight - ScrollHeight)) {$('#ActionNewPhones').css('top', '0px'); NewPhonesTop = 0;}});
	$('#Action1EURPhones').animate({'top' : ONEEURPhonesTop + 'px'}, ScrollHeight * 3, 'linear', function () { enableScroll = true; 	if(ONEEURPhonesTop == -(ONEEURPhonesHeight - ScrollHeight)) {$('#Action1EURPhones').css('top', '0px'); ONEEURPhonesTop = 0;}});
}

function doScrollRightNew() {
	if(!enableScroll) return false;

	enableScroll = false;

	if(SmartPhonesTop == 0) {SmartPhonesTop = -(SmartPhonesHeight - ScrollHeight); $('#ActionSmartPhones').css('top', -(SmartPhonesHeight - ScrollHeight) + 'px');};
	if(NewPhonesTop == 0) {NewPhonesTop = -(NewPhonesHeight - ScrollHeight); $('#ActionNewPhones').css('top', -(NewPhonesHeight - ScrollHeight) + 'px');};
	if(ONEEURPhonesTop == 0) {ONEEURPhonesTop = -(ONEEURPhonesHeight - ScrollHeight); $('#Action1EURPhones').css('top', -(ONEEURPhonesHeight - ScrollHeight) + 'px');};

	SmartPhonesTop += ScrollHeight;
	NewPhonesTop += ScrollHeight;
	ONEEURPhonesTop += ScrollHeight;

	$('#ActionSmartPhones').animate({'top' : SmartPhonesTop + 'px'}, ScrollHeight * 3, 'linear', function () { enableScroll = true; 	if(SmartPhonesTop == 0) {$('#ActionSmartPhones').css('top', -SmartPhonesHeight + ScrollHeight + 'px'); SmartPhonesTop = -SmartPhonesHeight + ScrollHeight;}});
	$('#ActionNewPhones').animate({'top' : NewPhonesTop + 'px'}, ScrollHeight * 3, 'linear', function () { enableScroll = true; 	if(NewPhonesTop == 0) {$('#ActionNewPhones').css('top', -NewPhonesHeight + ScrollHeight + 'px'); NewPhonesTop = -NewPhonesHeight + ScrollHeight;}});
	$('#Action1EURPhones').animate({'top' : ONEEURPhonesTop + 'px'}, ScrollHeight * 3, 'linear', function () { enableScroll = true; 	if(ONEEURPhonesTop == 0) {$('#Action1EURPhones').css('top', -ONEEURPhonesHeight + ScrollHeight + 'px'); ONEEURPhonesTop = -ONEEURPhonesHeight + ScrollHeight;}});
}


function doScrollLeft() {
	if (!enableScroll) return false;

	enableScroll = false;
	if (scrollPosition == 0 && $(visibleItems).prev().length == 0) {
		totalScrollWidth += scrollWidth;
		$('.scroll-pane').css('width', totalScrollWidth + 'px');
		$('.scroll-pane').prepend($('.scroll-items:eq(0)').clone().attr('id', 'items-' + layerCount++));
		offsetLeft -= scrollWidth;
		$('.scroll-pane').css('left', offsetLeft + 'px');
		if ($('.scroll-items').length > 2) {
			$('.scroll-items:eq(2)').remove();
			totalScrollWidth -= scrollWidth;
			$('.scroll-pane').css('width', totalScrollWidth + 'px');
		}
	}

	if (scrollPosition == 0) {
		scrollPosition = elementCount - 1;
		visibleItems = $(visibleItems).prev().get(0);
	} else {
		scrollPosition--;
    }

	offsetLeft += scrollLength;
	$('.scroll-pane').animate({'left' : '+=' + scrollLength + 'px'}, scrollLength * 3, 'linear', function () { enableScroll = true; });
	return true;
}

function doScrollRight () {
    if (!enableScroll) return false;

	enableScroll = false;
	if (scrollPosition == elementCount - scrollWindowSize && $(visibleItems).next().length == 0) {
		totalScrollWidth += scrollWidth;
		$('.scroll-pane').css('width', totalScrollWidth + 'px');
		$('.scroll-pane').append($('.scroll-items:eq(0)').clone().attr('id', 'items-' + layerCount++));
		if ($('.scroll-items').length > 2) {
			$('.scroll-items:eq(0)').remove();
			totalScrollWidth -= scrollWidth;
			$('.scroll-pane').css('width', totalScrollWidth + 'px');
			offsetLeft += scrollWidth;
			$('.scroll-pane').css('left', offsetLeft + 'px');
		}
	}

	if (scrollPosition == elementCount - 1) {
		scrollPosition = 0;
		visibleItems = $(visibleItems).next().get(0);
    } else {
		scrollPosition++;
    }

	offsetLeft -= scrollLength;
	$('.scroll-pane').animate({'left' : '-=' + scrollLength + 'px'}, scrollLength * 3, 'linear', function () { enableScroll = true; });
	return true;
}

function httpool_unveil() {
   var elm = document.getElementById('floater');
   if(elm){
      elm.className = "vis";
   }
}

function httpool_cover() {
   var elm = document.getElementById('floater');
   if(elm){
      elm.className = "inVis";
   }
}

function hideFloater() {
   var elm = document.getElementById('floater');
   if(elm){
      elm.className = "inVis";      
   }
}

function initActionsScroller() {
	$(document).bind('ready', function () {
		SmartPhonesHeight = $('#ActionSmartPhones div').length * ScrollHeight;
		NewPhonesHeight = $('#ActionNewPhones div').length * ScrollHeight;
		ONEEURPhonesHeight = $('#Action1EURPhones div').length * ScrollHeight;

		elementCount = $('.scroll-pane .item').length;
		scrollWidth = elementCount * 426;
		totalScrollWidth = scrollWidth;
		$('.scroll-pane').css('width', scrollWidth + 'px');
		$('.scroll-items').css('width', totalScrollWidth + 'px');
		visibleItems = $('.scroll-items').get(0);
		$('.bk').click(function () {
			clearInterval(interval);
			doScrollLeftNew();
		});
		$('.fw').click(function () {
			clearInterval(interval);
			doScrollRightNew();
		});
		//interval = setInterval(doScrollRight, scrollInterval);
	});
}

submitSearchStatistics = function() {
    var link = window.location.href;

    if (link.indexOf("?") > -1) {
        link = link.substr(0, link.indexOf("?"));
	}

    var fromDate = document.getElementById('fromDate').value;
    var toDate = document.getElementById('toDate').value;
    if ((fromDate) && (toDate)) {
        window.location = link + "?fromDate=" + fromDate + "&toDate=" + toDate;
    }
}

export2XLS = function() {
    var link = window.location.href;
    var params = "";
    if (link.indexOf("?") > -1) {
        params = link.substr(link.indexOf("?"), link.length);
	}
    link = params.length > 0 ? "/searchStatisticsXLS" + params : "/searchStatisticsXLS";
    window.location = link;
}

exportFAQ2XLS = function() {
	var link = window.location.href;
	var params = "";
	if (link.indexOf("?") > -1) {
		 params = link.substr(link.indexOf("?"), link.length);
  }
	link = params.length > 0 ? "/searchStatisticsFAQXLS" + params : "/searchStatisticsFAQXLS";
	window.location = link;
}

exportFAQClicks2XLS = function() {
    var link = window.location.href;
    var params = "";
    if (link.indexOf("?") > -1) {
        params = link.substr(link.indexOf("?"), link.length);
	}
    link = params.length > 0 ? "/clickStatisticsFAQXLS" + params : "/clickStatisticsFAQXLS";
    window.location = link;
}


toggleHTCArticles = function(ind) {
	var Index=0;
	for(Index=1; Index<=4; Index++) {
		var el = document.getElementById('htcarticle' + Index);
      if(el != null && el != undefined)
		   el.style.display = "none";
	}

	var el = document.getElementById('htcarticle' + ind);
   if(el != null && el != undefined)
   	el.style.display = "block";
}

toggleHTC = function() {
	var Index=0;
	for(Index=2; Index<=4; Index++) {
		var el = document.getElementById('htcarticle' + Index);
		//alert(el);
      if(el != null && el != undefined)
   		el.style.display = "none";
	}
}

prepareLJMArticles = function() {
	for(var i=1; i<=4; i++) {
		var section = document.getElementById("ljm_content" + i);
		if(section != null) {
			if(showSectionNum != i)
				section.style.display = 'none';
		}
	}
}

prepareBBArticles = function() {
	var i=2;
	for(var i=2; i<=4; i++) {
		var section = document.getElementById("bb_content" + i);
		if(section != null)
			section.style.display = 'none';
	}
}

undercoverFlash = function() {
   var elm = document.getElementById('floater-vfl');
   if(elm != null){
      elm.style.display = 'none';
   }
}

var muziq_dropdown = function() {
    if ($('#muziq-supported').length > 0){
        $('#muziq-supported select').change(function() {
            var id = $(this).val();
            $('.models').hide();
            $("#"+id+"-models").show();
});
        $('.models').hide();
        $('#nokia-models').show();
    }
};

var prepareJanArticles = function(){
    for(var i=1; i<=4; i++){
        if($("#jan_content"+i).length > 0){
            $("#jan_content"+i).hide();
        }
        if($("#jan_phone"+i).length > 0){
            $("#jan_phone"+i).hide();
        }
    }
    if($("#jan_phone1").length > 0){
        $("#jan_phone1").show();
    }
    if($("#jan_content1").length > 0){
        $("#jan_content1").show();
    }
}

var prepareAsusLightbox = function(){
    if($(".asus").length > 0){
        $(".asus a").lightBox();
    }
}


var displayLightPriceArticle = function(ind){
    for(var i=1; i<=4; i++){
        if($("#jan_content"+i).length > 0){
            $("#jan_content"+i).hide();
        }
        if($("#jan_phone"+i).length > 0){
            $("#jan_phone"+i).hide();
        }
    }
    if($("#jan_phone"+ind).length > 0){
        $("#jan_phone"+ind).show();
    }
    if($("#jan_content"+ind).length > 0){
        $("#jan_content"+ind).show();
    }
}

load_active_reception = function(){
    var domscript = document.createElement('script');
    domscript.src = "http://www.activereception.com/Chat/Client_page/Active_reception_image.php?website=http://www.simobil.si";
    var el = document.getElementById("active-reception");
    if (el){
        el.appendChild(domscript)
    }
}
prepareBBArticles = function() {
	var i=2;
	for(var i=2; i<=4; i++) {
		var section = document.getElementById("bb_content" + i);
		if(section != null)
			section.style.display = 'none';
	}
}

var populateInlineFlvs = function() {
	$('.inline-flv').each(function() {
		var id = $(this).attr('id');
		var src;
		if ($(this).find('p.source').size() > 0) {
			src = $(this).find('p.source').text();
		}
		var prv;
		if ($(this).find('p.preview').size() > 0) {
			prv = $(this).find('p.preview').text();
		}
		var size;
		if ($(this).find('p.size').size() > 0) {
			size = $(this).find('p.size').text();
		}
		if (id && src && prv) {
			var width = '660';
			var height = '375';
			if (size) {
				size = size.split('x');
				if (size.length > 0) {
					width = size[0];
					if (size.length > 1) {
						height = size[1];
					}
				}
			}
			var params = {};
			var flashvars = {
				source: src,
				preview: prv
			};
			swfobject.embedSWF('/_common/flash/video_player.swf', id, width, height, '8.0.0', false, flashvars, params);
		}
	});
};



/* onload settings */
$().ready(function () {
	//$('.pushcontent,.frontwrap,#related ul').equalHeights();
	//$('.quickaccess').tabs();
	$('#sec-nav ul li:first-child').addClass('p1');
	$('#properties .tabs li:first-child').addClass('p1');
	$('#categories li:last-child').addClass('last');
	populateInlineFlvs();
});

/* init & load */
window.oninit = function() {
	if (document.getElementById && document.getElementsByTagName) {
//		frontScroller();
		swaplines();
		externalLinks();
		enhanceLinks(['switchframes']);
//		prepareAF();
		toggleCompData();
		populateAccordionLinks();
		populateKeyvisual();
		populateNewKeyvisual();
		populateKeyvisualSimost();
        populateKeyvisualFront();
		populateCalculator();
		populateCoverageMap();
		setFrontThoughtInputFields();
		populateFlashTree();
		populateNyGreetings();
		populateNetworkMap();
		prepareFaqVideos();
		prepareFaqLiveSearch();
		//prepareFaqLightbox();
		prepareLightbox();
		injectBackToPhoneList();
		displayInBasket();
		toggleFPTabs();
		hidePNTformData();
		prepareFaqTogglers();
		toggleHTC();
		prepareLJMArticles();
		prepareBBArticles();
		/*
			- We only need this for IE6 to calculate block heights because IE can't handle CSS clearing.
			- Opera and Safari can't handle this well - block height is calculated wrong.
			- Firefox has the same issue but only on first pageload - when refreshed it's ok.
		*/
		if(navigator.appName.startsWith('Microsoft')) {manipulateFew(['categories']);}
		printContent();
        muziq_dropdown();
        prepareJanArticles();
		//displayFloater();
		//load_active_reception();
        populateBold9700();
        populateMuziqApril();
        prepareAsusLightbox();
	}
}

launchInit = function() {
	if (document.getElementsByTagName && typeof(window.oninit)=='function') {
		if (document.getElementsByTagName('body').length>0) window.oninit();
		else setTimeout('launchInit()',30);
	}
}
launchInit();

$.fn.extend({
    fire: function(evttype){
        el = this.get(0);         
        if (document.createEvent) {
            var evt = document.createEvent('HTMLEvents');
            evt.initEvent(evttype, false, false);
            el.dispatchEvent(evt);
        } else if (document.createEventObject) {
            el.fireEvent('on' + evttype);
        }
        return this;
    }
});

function shareOnFacebook(url, title, comment) {
    if (url == "" || url == null || url == undefined) {
        url = encodeURIComponent(document.location);
    } else {
        url = encodeURIComponent(url);
    }

    if (title == "" || title == null || title == undefined) {
        title = encodeURIComponent(document.title);
    } else {
        title = encodeURIComponent(title);
    }

    //    comment = encodeURIComponent(comment.replace("[URL]", document.location));

    window.open('http://www.facebook.com/sharer.php?u=' + url + '&t=' + title, 'sharer', 'toolbar=0,status=0,width=626,height=436');
}        

startString = function(a, s) {return (s==null)? false : (a.substring(0, s.length)==s);}

faqVote = function() {
    var a = $('.vote a');
    $('.vote-already').hide();
    $('.vote-tnx').hide();
    a.click(function(e) {
        if ($.cookie("vote-" + $(this).attr("rel"))){
            e.preventDefault();
            $(this).parent().parent().parent().find('.vote-already').show();
            $(this).parent().parent().parent().find('.vote-tnx').hide();
        } else {
            e.preventDefault();
            var el = $(this);
            $.get($(this).attr('href'), {});
            $.cookie("vote-" + $(this).attr("rel"), 1);
            $(this).parent().parent().parent().find('.vote-tnx').show();
        }
    });
},

$().ready(function() {
    faqVote();
   $(".muziq_popup").unbind("click");
   $(".muziq_popup").attr("onclick", "");
   $(".muziq_popup").click(function(){
        window.open(this.href, "", "height=220, width=300");
        return false;
   });
    
   $(".outbound").bind("click", function(){
        window.open(this.href);
        return false;
   });

    $("a").each(function(){
    var href = $(this).attr("href");
    if(href){
        if (startString(href,"/") || startString(href,"http://www.simobil.si") || startString(href,"javascript://") || startString(href,"#") || startString(href,"cp2")){
        } else{
            //$(this).attr("onclick", "");
            href = href.replace("http://", "");
            $(this).attr("onclick", "pageTracker._trackPageview('/outbound/"+ href+"')");
        }
        if(href.indexOf("#accTrigger") > -1){
            $(this).click(function (){                
                var accIndex = href.substring(href.indexOf(",")+1, href.length);
                $("#header-"+accIndex).click();
                $.scrollTo($("#header-"+accIndex));
            });
        }
		if($(this).hasClass("open_new_window")){
			$(this).click(function(){window.open(this.href);
        	return false;
			});
		}
    }
    });
    $(".tek_form").submit(function (){
        for(var j=0;j <= 4; j++){
            $("#tek_content"+j).hide();            
        }
        $("#tek_content3").show();
    });
    $(".tek_diploma").submit(function (){
        for(var j=0;j <= 4; j++){
            $("#tek_content"+j).hide();
        }
        $("#tek_content2").show();
    });
    if($(".tek_header").length > 0){
        for(var j=0;j <= 4; j++){
            $("#tek_content"+j).hide();
        }
        if (window.location.href.indexOf("#tekForm") > -1){
            $("#tek_content3").show();
        } else if(window.location.href.indexOf("#tekDiploma") > -1){
            $("#tek_content2").show();
        } else if(window.location.href.indexOf("#tekGallery") > -1){
            $("#tek_content4").show();
        } else if(window.location.href.indexOf("#tekOffer") > -1){
            $("#tek_content1").show();
        } else {
            $("#tek_content0").show();
        }
    }
    if ($('#re-gallery li a.image').length > 0){
	    $('#re-gallery li a.image').lightBox();
    }

    if ($('#re-gallery').length > 0) {            
        $('.re_gallery_pagination ul li a').click(function (){
            $('#re-gallery li').hide();
            $('#re-gallery li').removeClass("active");
            var pageParam = $(this).html();
            $(this).parent().addClass("active");            
            $('#re-gallery li.image'+pageParam).show();
        });
        $('.re_gallery_pagination ul li:first a').click();
    }

    $('#re-gallery li a.facebook').click(function() {
        shareOnFacebook(window.location + "&pictureParam=" +$(this).attr("rel"), 'Si.mobil', 'Si.mobil');
        return false;
    });
    $('.tek_action #re-gallery li a.facebook').click(function() {
        shareOnFacebook(window.location + "&pictureParam=" +$(this).attr("rel")+"#tekGallery", 'Si.mobil', 'Si.mobil');
        return false;
    });

    $('.tek_action .tek_form .cms a.facebook').click(function() {
        shareOnFacebook(window.location+"#tekForm", 'Si.mobil', 'Si.mobil');
        return false;
    });
    if (accordion){
        accordion.init("accordion");
        if(window.location.href.indexOf("#accTrigger") > -1){
            var accIndex = window.location.href.substring(window.location.href.indexOf(",")+1, window.location.href.length);
            $("#header-"+accIndex).click();
            $.scrollTo($("#header-"+accIndex));
        }
    }
    if($('#floater').length > 0){
        var left = parseInt(parseInt($(document).width(), 10) / 2) - 550;
        $('floater').css('left', left);
    }
	if($('.qr_large').length > 0){
		$('.qr_large').wrap('<div class="qr_large_div" />');
	}
	if($('.qr_hoover').length > 0){
		$('.qr_hoover').parent().hover(
				function(){
					$(this).find('.qr_hoover').hide();
					var div = $(this).parent().find('.qr_large_div');
					div.show();
					div.find('img').show();
				},
				function(){					
					var div = $(this).parent().find('.qr_large_div');
					div.hide();
					div.find('img').hide();
					$(this).find('.qr_hoover').show();
				});
	}

});
$().ready(function() {
	/* lightbox */
    if ($('#phone .image').length > 0){
	    $('#phone .image').lightBox();
    }
	/* phone properties */
    if($('#properties').length > 0){
        $('#properties .tab-content').hide();
        $('#properties .tabs li a').click(function() {
            $('#properties .tabs li').removeClass();
            $(this).parent().addClass('active');
            var active_tab = $(this).attr('href');
            $('#properties .tab-content').hide();
            $(active_tab).show();
            return false;
        });
        $('#properties .tabs li:first a').click();
    }
	if($("#webcalc").length > 0){
        /* web calculator @ phone */
        $('#webcalc .options').hide();
        $('#webcalc .packages .controls a').click(calculatePrices);
        $('#webcalc .options .controls a').click(function () {
            $('#webcalc .options').slideUp();
            $('#webcalc .packages').slideDown();
            $('#webcalc .progress .p2').removeClass('p2-active');
            $("#webcalc .options tr .pkg").each(function(){
                var checkbox = $(this).find("label input");
                if (checkbox.is(":checked")){
                    checkbox.change();
                    checkbox.attr("checked", false);
                }
            });
            $("#webcalc .packages tr td.pkg").each(function(){
                var radio = $(this).find("label input");
                if (radio.is(":checked")){
                    radio.change();
                    radio.attr("checked", false);
                }
            });
            calculatePrices();
            return false;
        });

        /* priceCalculator */

        $(".package_tooltip").hide();

        $("#webcalc .options tr .pkg a").tooltip({
            showURL:false
        });
        $("#webcalc .packages tr .pkg .pkg_tip").each(function(){
            if ($($(this).attr("rel")).html()){
                $(this).tooltip({
                    bodyHandler: function() {
                        return $($(this).attr("rel")).html();
                    },
                    showURL: false
                });
            }
        });        

        $("#webcalc .packages tr .pkg .reg_price").tooltip({
            showURL:false
        });

        $("#webcalc .options tr .pkg label input").click(function(){
        if($.browser.msie){           
            $(this).fire("change").blur();
            $(this).focus();
        }
        });

        calculatePrices();
        $("#webcalc .packages tr .pkg label").click(calculatePrices);
        $("#webcalc .options tr .pkg label").click(calculatePrices);
        $("#webcalc .options tr .pkg label input").change(toggleWebcalcCheckbox);
        $("#webcalc .packages tr .pkg label").attr("checked", false); 
    }
});

calculatePrices = function(){
    var sum = 0;
    var fee = 0;
    var packageName = "";
    var lowestPrice = 0;
    var discount = 0;
    var additionalFee = 0;
    var selectedOptions = {};
    var optionSelected = false;
    var muziqSelected = false;
    var ortoSelected = false;
    var numOptions = $("#webcalc .options tr td.pkg").length;    
    $("#webcalc .packages tr td.pkg").each(function(){
        var price_id = $(this).attr("rel");
        var tempSum = parseFloat($("#webcalc .packages tr #price-"+price_id).html().match(/([0-9\,]*)/)[0].replace(",","."));
        var phoneTitle = $('#phone h2').text();        
        if (lowestPrice != 0){
            if(tempSum < lowestPrice){
                lowestPrice = tempSum;
            }
        } else {
            lowestPrice = tempSum;
        }
        if ($(this).find("label input").length > 0){
            if ($(this).find("label span").html().indexOf("MUZIQ") > -1 || $(this).find("label span").html().indexOf("NULO") > -1){
                if (numOptions == 1){
                    if ($("#webcalc .options tr td.pkg label span").html().indexOf("MUZIQ")){
                        $(this).find("label input").hide();
                        $(this).find("label").unbind("click");
                        $(this).find("label").click(function(){return false;});
                    }
                }
            }
        }
/*        if ($(this).find("label input").length > 0){
            if ($(this).find("label span").html().indexOf("MUZIQ") > -1 || $(this).find("label span").html().indexOf("NULO") > -1){
                if (phoneTitle.indexOf("HTC Desire") > -1 || phoneTitle.indexOf("HTC Tatto") > -1 || phoneTitle.indexOf("HTC Legend") > -1 || phoneTitle.indexOf("Samsung i5700 Galaxy Spica") > -1 || phoneTitle.indexOf("XPERIA X10") > -1){
                    $(this).find("label input").hide();
                    $(this).find("label").unbind("click");
                    $(this).find("label").click(function(){return false;});                
                }
            }
        }*/
        if ($(this).find("label input").length > 0){
            if ($(this).find("label span").html().indexOf("MUZIQ") > -1){
                if (phoneTitle.indexOf("Nokia 5230") > -1 || phoneTitle.indexOf("HTC Magic") > -1){
                    $(this).find("label input").hide();
                    $(this).find("label").unbind("click");
                    $(this).find("label").click(function(){return false;});
                }
            }
        }
        if ($(this).find("label input").length > 0){
            if ($(this).find("label input").is(":checked")){                
                sum = parseFloat($("#webcalc .packages tr #price-"+price_id).html().match(/([0-9\,]*)/)[0].replace(",","."));
                fee = parseFloat($("#webcalc .packages tr #fee-"+price_id).html().match(/([0-9\,]*)/)[0].replace(",", "."));
                packageName = $(this).find("label span").html();
                if ($(this).find("label span").html() != null){                    
                    if ($(this).find("label span").html().indexOf("MUZIQ") > -1){
                        muziqSelected = true;
                    }
                    if ($(this).find("label span").html().indexOf("NULO") > -1){
                        ortoSelected = true;
                    }
                }
            }
        }
    });
    $("#webcalc .options tr td.pkg").each(function(){
        var checkbox = $(this).find("label input");
        if(muziqSelected || ortoSelected){
            if ($(this).find("label span").html().indexOf("MUZIQ") > -1){
                $(this).parent().hide();
            }
        } else {
            $(this).parent().show();
        }
        $(this).parent().removeClass("active");
        var price_id = $(this).attr("rel");        
        var priceCut = parseFloat($("#webcalc .options tr #price-"+price_id).attr("rel").match(/([0-9\,]*)/)[0].replace(",","."));
        if (checkbox.is(":checked")){
            optionSelected = true;
            selectedOptions[price_id] = $(this).find("label span").html();
            $(this).parent().addClass("active");
            discount = discount + priceCut;
            additionalFee = additionalFee + parseFloat($("#webcalc .options tr #fee-"+price_id).html().match(/([0-9\,]*)/)[0].replace(",","."));
        }
        var newPrice = sum - priceCut;
        if (newPrice < 1.0){
            newPrice = 1.0;
        }
        $("#webcalc .options tr #price-"+price_id).html(newPrice.toFixed(2).replace(".",",") + " &euro;");
    });
    if (optionSelected){
        $("#webcalc .options .summary #fee-selected strong").html("Skupna mesečna naročnina:");
    } else {
        $("#webcalc .options .summary #fee-selected strong").html("Mesečna naročnina:");
    }
    var outPrice = sum - discount;
    var outFee = fee + additionalFee;
    $("#webcalc .packages .controls .fee-error").hide();    
    if(fee == 0){
        $("#prelim-sum").hide();
        $('#webcalc .packages .controls a').unbind("click");
        $('#webcalc .packages .controls a').click(function (){
            $("#webcalc .packages .controls .fee-error").show();
        });        
    } else {
        $("#webcalc .packages .controls .fee-error").hide();
        $('#webcalc .packages .controls a').unbind("click");
        $('#webcalc .packages .controls a').click(function (){
            $('#webcalc .packages').slideUp();
            $('#webcalc .options').slideDown();
            $('#webcalc .progress .p2').addClass('p2-active');
            calculatePrices();
            return false;
        });
        $("#prelim-sum").show();
        if (outPrice < 1.0){
            outPrice = 1.0;
        }
        var optionList = "";
        for (var opt in selectedOptions){
            optionList = optionList + "<li>" + selectedOptions[opt] +"</li>";
        }
        $("#options-selected").html(optionList);
        $("#package-selected").html(packageName);
        $("#webcalc .progress .price strong").html(outPrice.toFixed(2).replace(".",",") + " &euro;");
        $("#webcalc .options .summary .price-sum").html(outPrice.toFixed(2).replace(".",",") + " &euro;");
        $("#webcalc .options .summary .fee-sum").html(outFee.toFixed(2).replace(".",",") + " &euro;");
    }
    if ($("#webcalc .packages tr td.pkg").length > 1){
        $("#lowest-price").html("od " + lowestPrice + " &euro;");
    } else {
        $("#lowest-price").html(lowestPrice + " &euro;");
    }

}

toggleWebcalcCheckbox = function() {
    var disabledList = $(this).attr("rel");
    if (disabledList) {
        var excludedIds = disabledList.split(",");
        for (var id in excludedIds) {
            if (excludedIds[id] != null && (excludedIds[id] != "")) {
                if ($("#option-" + excludedIds[id]).attr("disabled") == true) {
                    $("#option-" + excludedIds[id]).removeAttr("disabled");
                    $("#row-" + excludedIds[id]).removeClass("disabled");
                    $("#label-" + excludedIds[id]).click(calculatePrices);
                } else {
                    $("#option-" + excludedIds[id]).attr("disabled", true);
                    $("#row-" + excludedIds[id]).addClass("disabled");
                    $("#label-" + excludedIds[id]).unbind("click");
                }
            }
        }
    }
}