// prislusenstvo v kosiku
function show_accessories(idcko) {
	sect = document.getElementById('odp_mob_' + idcko);
	
	if(sect.style.display == "none")
		sect.style.display = "block";
	else
		sect.style.display = "none";
}

//kalendar v historie objednavok

$(function() {	
	// zadefinujeme si slovensku lokalizaciu pre datepicker
		$.datepicker.regional['sk'] = {
			closeText: 'Zavrieť',
			prevText: '&#x3c; Predchádzajúci',
			nextText: 'Nasledujúci &#x3e;',
			currentText: 'Dnes',
			monthNames: ['Január','Február','Marec','Apríl','Máj','Jún',
			'Júl','August','September','Október','November','December'],
			monthNamesShort: ['Jan','Feb','Mar','Apr','Máj','Jún',
			'Júl','Aug','Sep','Okt','Nov','Dec'],
			dayNames: ['Nedel\'a','Pondelok','Utorok','Streda','Štvrtok','Piatok','Sobota'],
			dayNamesShort: ['Ned','Pon','Uto','Str','Štv','Pia','Sob'],
			dayNamesMin: ['Ne','Po','Ut','St','Št','Pia','So'],
			weekHeader: 'Ty',
			dateFormat: 'dd.mm.yy',
			firstDay: 0,
			isRTL: false,
			showMonthAfterYear: false,
//			showButtonPanel: true,
			yearSuffix: ''};
			//setneme sk nastavenia ako defaultne
		$.datepicker.setDefaults($.datepicker.regional['sk']);
		
		$(".datepicker").datepicker();
	 
});


// odpocitavac pre 24 hodinove akcie
function zacni_odpocitavat(yr,m,d) {
	var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

	hodiny = document.getElementById('supspec_hodiny');
	minuty = document.getElementById('supspec_minuty');
	sekundy = document.getElementById('supspecsekundy');
	
	theyear=yr;themonth=m;theday=d
	var today=new Date()
	var todayy=today.getYear()
	if (todayy < 1000)
	todayy+=1900
	var todaym=today.getMonth()
	var todayd=today.getDate()
	var todayh=today.getHours()
	var todaymin=today.getMinutes()
	var todaysec=today.getSeconds()
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
	futurestring=montharray[m-1]+" "+d+", "+yr
	dd=Date.parse(futurestring)-Date.parse(todaystring)
	dday=Math.floor(dd/(60*60*1000*24)*1)
	dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
	dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
	dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
	
	hodiny.innerHTML = (dhour.toString().length == 2 ? dhour.toString() : '0' + dhour.toString());
	minuty.innerHTML = (dmin.toString().length == 2 ? dmin.toString() : '0' + dmin.toString());
	sekundy.innerHTML = (dsec.toString().length == 2 ? dsec.toString() : '0' + dsec.toString());
		
	setTimeout("zacni_odpocitavat(theyear,themonth,theday)", 1000)
}

function starover(k){							
	for(i = 1; i <= k; i++)
		document.getElementById('star'+i).src = document.getElementById('star'+i).src.replace('emptystar.jpg', 'fullstar.jpg');
}
function starout(){							
	for(i = 1; i <= 5; i++)
		document.getElementById('star'+i).src = document.getElementById('star'+i).src.replace('fullstar.jpg', 'emptystar.jpg');
}

function hlasuj(k) {
	document.location.href = '?hlasovanie=' + k;
}

function popupWindowFitImage(url) {
  window.open(url,'popupWindow',"resizable=yes, location=no");
}

// otvorenie nahladu na tlac
function print_preview(id) {
  window.open('nahlad-na-tlac-' + id, 'preview', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=no,status=no,height=600,width=625');
}

// otvorenie obrazku v novom okne - picture_show.php
function show_picture(source, path, comment) {
  path = (path ? path : "");
  window.open(path + "picture_show.php?source=" + source + "&comment=" + ((comment == null) ? "" : comment), 'picture', "toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,resizable=no,status=no");
}

// otvorenie okna na porovnanie produktov
function compare_product(prod_id) {
  window.open('compare.php?prod0=' + prod_id, 'compare', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=no,status=no,height=650,width=880');
}

// otvorenie okna na odoslanie emailu
function open_email_form(typ, param) {
    window.open('mail-' + typ + '-' + param, 'email', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,resizable=no,status=no,height=470,width=530');
}

// funkcia na submitnutie enterom
function submitenter(myfield, e) {
  var keycode;
  if(window.event) 
    keycode = window.event.keyCode;
  else {
    if(e) 
      keycode = e.which;
  }

  if(keycode == 13)
    myfield.form.submit();
}

// bookmark page
function bookmark_page(title, linka) {
  // Mozilla Firefox Bookmark
  if(window.sidebar)
    window.sidebar.addPanel(title, linka,"");
  
  // IE Favorite
  else if(window.external)
    window.external.AddFavorite(linka, title);
  
  // Opera Bookmark
  else if(window.opera && window.print) {
    var obm = document.createElement('a');
    obm.setAttribute("title", title);
	obm.setAttribute("href", linka);
	obm.setAttribute("rel", "sidebar");    
    obm.click();
  }
}

// ONMOUSEOVER PRE BUTTONY

function over(obj) {
  //var thisimg = document.getElementById(imgID);
  if(obj.src.substring(obj.src.length-9, obj.src.length) == "blank.gif") obj.style.filter = obj.style.filter.replace('.png','-hover.png');
  else obj.src = obj.src.replace(/(\.[a-z0-9]+)$/i,'-hover$1');
  obj.style.cursor= "pointer";
}
function out(obj) {
  //var thisimg = document.getElementById(imgID);
  //thisimg.src = thisimg.src.replace(/-hover(\.[a-z0-9]+)$/i,'$1');
 if(obj.src.substring(obj.src.length-9, obj.src.length) == "blank.gif")
  	obj.style.filter = obj.style.filter.replace('-hover.png','.png');
  else
  	obj.src = obj.src.replace(/-hover(\.[a-z0-9]+)$/i,'$1');
}

function ieover(obj){
	if (obj.className!="tab-active")
		obj.className="tab-active hov";
	else 
		obj.className="tab-active";
}
function ieout(obj){
	if(obj.className=="tab-active hov")
		obj.className="tab";
}

// bookmark page
function bookmark_page() {
  // Mozilla Firefox Bookmark
  if(window.sidebar)
    window.sidebar.addPanel("Pricemania.sk - porovnanie cien tovarov", "http://www.pricemania.sk","");
  
  // IE Favorite
  else if(window.external)
    window.external.AddFavorite("http://www.pricemania.sk", "Pricemania.sk - porovnanie cien tovarov");
  
  // Opera Bookmark
  else if(window.opera && window.print) {
    var obm = document.createElement('a');
    obm.setAttribute("title", "Pricemania.sk - porovnanie cien tovarov");
	obm.setAttribute("href", "http://www.pricemania.sk");
	obm.setAttribute("rel", "sidebar");    
    obm.click();
  }
}
