//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();
	 
});

function image_title() {
	// hmm... asi bude treba urlencoding natvrdo :(
	
	//document.getElementById('green2').innerHTML = '<img src="includes/imageheader.php?text=' + document.getElementById('green2').innerHTML + '" />'
}

function show_accessories(idcko) {
	sect = document.getElementById('odp_mob_' + idcko);
	
	if(sect.style.display == "none")
		sect.style.display = "block";
	else
		sect.style.display = "none";
}

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=600,width=750');
}

// 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');
}

