<!--

// otevreni noveho okna
function OpenWindow(strURL,width,height,sroll){
	var objWnd = window.open(strURL,"Detail","scrollbars=" + sroll + ",resizable=yes,height=" + height + ",width=" + width + ",left=0,top=0");
	objWnd.focus();
}


// otevreni noveho okna
function NewWindow(strURL){
	var objWnd = window.open(strURL);
	objWnd.focus();
}

function OpenPhoto(theElement){
	var objWnd = window.open(theElement.href,"Photo","scrollbars=1,resizable=yes,height=680,width=590,left=0,top=0");
	objWnd.focus();
}

// vrati hodnotu vybraneho tlacitka
function GetRadioValue(radioArray){
	var iLength = radioArray.length;
	if(iLength){	// vice hodnot
		var i;
		for(i = 0; i < iLength; i++){
			if(radioArray[i].checked == true) return radioArray[i].value;
		}
	}
	else{	// // pouze jedna hodnota
		if(radioArray.checked == true) return radioArray.value;
	}
	return null;
}


// oriznuti mezer
function Trim(s){
	while(s.substring(0,1) == ' '){
		s = s.substring(1,s.length);
	}
	while(s.substring(s.length-1,s.length) == ' '){
		s = s.substring(0,s.length-1);
	}
	return s;
}


//testovani regularnich vyrazu
function RegExpTest(test,reg){
	return test.search(reg) == 0;
}


// kontrola prazdne hodnoty pole
function CheckEmptyField(sField){

	var sMsg = '';
	var oLabel = document.getElementById('lb' + sField);

	if(Trim(document.getElementById(sField).value) == ""){
		document.getElementById(sField).focus();

		if(oLabel){
			sMsg = oLabel.firstChild.data;
			if(sMsg.substring(sMsg.length - 1, sMsg.length) == ':') sMsg = sMsg.substring(0, sMsg.length-1)
			oLabel.style.color = 'red';
		}
		else sMsg = '';

		alert(sCheckEmptyField + sMsg + "!");
		return false;
	}
	else{
		if(oLabel) oLabel.style.color = '';
		return true;
	}
}


// kontrola podle regularniho vyrazu
function CheckFormat(sField, sRegStr){

	var sMsg = '';
	var oLabel = document.getElementById('lb' + sField);
	var sValue = Trim(document.getElementById(sField).value);
	var sRe  = sRegStr;

	if(sValue != ''){
		if(!RegExpTest(sValue,sRe)){
			document.getElementById(sField).focus();
			if(oLabel){
				sMsg = oLabel.firstChild.data;
				if(sMsg.substring(sMsg.length - 1, sMsg.length) == ':') sMsg = sMsg.substring(0, sMsg.length-1)
				oLabel.style.color = 'red';
			}
			else sMsg = '';
			alert(sCheckFormat + sMsg + '.');
			return false;	
		}
		else{
			if(oLabel) oLabel.style.color = '';
			return true;			
		}
	}
	else return true;
}


function GetLabelDesc(sField){
	var oLabel = document.getElementById('lb' + sField);
	if(oLabel){	// pokud existuje label
		sLabel = oLabel.firstChild.data;
		if(sLabel.substring(sLabel.length - 1, sLabel.length) == ':') sLabel = sLabel.substring(0, sLabel.length-1);
		oLabel.style.color = 'red';
		return sLabel;
	}
}

function SetBookmark(dsbBookmark){
	var oBookmark = document.getElementById('bm');
	var aItem = new Array;
	var j = 0;
	for(i = 0; i < oBookmark.childNodes.length; i++){
		if(oBookmark.childNodes[i].id != '' && oBookmark.childNodes[i].id != undefined){
			strlen = oBookmark.childNodes[i].id.length;
			aItem[j] =  oBookmark.childNodes[i].id.substring(7, strlen);
			j++;
		}
	}
	for(i = 0; i < aItem.length; i++){
	    bl = document.getElementById('tab-'+aItem[i]);
	    itm = document.getElementById('bm-itm-'+aItem[i]);
	    if(aItem[i] == dsbBookmark){
			if(bl) bl.style.display = (bl.style.display == 'block') ? 'none' : 'block';
			itm.className = (itm.className == 'active') ? '' : 'active';
		}
		else{
			if(bl) bl.style.display = 'none';
			itm.className = '';
		}
	}
}

function Setpayment(doprava,dopravae,soucet,soucete,orcena) {
  $('#price1').html(doprava);
  $('#price2').html(dopravae);
  
  $('#price3').html('<strong class="basket-price">'+soucet+'</strong>');
  $('#price4').html(soucete);

  $('#price5').html(doprava);
  $('#price6').html(dopravae);
}

function SetTransport(cis,doprava,dopravae,soucet,soucete,orcena) {
  $('div#hs-platba').hide('fast');
  $('table#hs-platba-table').html('');
  $('table#hs-platba-table').load("./hs-payment.php?transport="+cis);

  $('#price1').html(doprava);
  $('#price2').html(dopravae);
  
  $('#price3').html('<strong class="basket-price">'+soucet+'</strong>');
  $('#price4').html(soucete);

  $('#price5').html(doprava);
  $('#price6').html(dopravae);

  $('div#hs-platba').show('fast');
}

function SetPayments(cis) {
  $('div#hs-platba').hide('fast');
  $('table#hs-platba-table').html('');
  $('table#hs-platba-table').load("./hs-payment.php?transport="+cis);
  $('div#hs-platba').show('fast');
}

function hsReklamaceValidate(){
	if(!CheckEmptyField('id_order')) return false;
	if(!CheckEmptyField('id_product')) return false;
	if(!CheckEmptyField('name')) return false;
	if(!CheckEmptyField('street')) return false;
	if(!CheckEmptyField('house_number')) return false;
	if(!CheckEmptyField('town')) return false;
	if(!CheckEmptyField('postcode')) return false;
	if(!CheckFormat('postcode', '^([0-9]{3} [0-9]{2})$')) return false;
	if(!CheckEmptyField('country')) return false;
	if(!CheckEmptyField('description1')) return false;
	return true;
}

function hsReklamaceSet(){ 
	document.getElementById('nosend').value = '1';
	document.getElementById('reclamation-f').submit();
}


$(document).ready(function() {

  $('div.hs-platba-off').hide();

  // Shovame / zobrazime si dodaci adresu dle checkboxu 
  if ($('input#fill-address').attr('checked')) { $('#transport-address').hide(); }
  if ($('input#fill-addressn').attr('checked')) { $('#transport-addressn').hide(); }
  
  $('#basket-register').hide();
  $('#basket-no-register').hide();
  $('#basket-login').hide();

  if ($('input#basket-login-type').attr('checked')) {
    $('#basket-login').show();
  }

  if ($('input#basket-register-type').attr('checked')) {
    $('#basket-register').show();
  }

  if ($('input#basket-no-register-type').attr('checked')) {
    $('#basket-no-register').show();
  }

// FUNKCE PRO KLIKANI

  // Kliknuti na checkbox - dodaci adresa je totozna / rozdilna jak fakturacni - registrace
  $('input#fill-address').click(function() {
    if ($('input#fill-address').attr('checked')) {
      $('#transport-address').hide();
    } else {
      $('#transport-address').show();
    }
  });

  // Kliknuti na checkbox - dodaci adresa je totozna / rozdilna jak fakturacni - rychly nakup
  $('input#fill-addressn').click(function() {
    if ($('input#fill-addressn').attr('checked')) {
      $('#transport-addressn').hide();
    } else {
      $('#transport-addressn').show();
    }
  });

  function RegClick() {
    if ($('input#basket-login-type').attr('checked')) {
      $('#basket-login').show();
      $('#basket-register').hide();
      $('#basket-no-register').hide();
    }
    if ($('input#basket-register-type').attr('checked')) {
      $('#basket-login').hide();
      $('#basket-register').show();
      $('#basket-no-register').hide();
    }
    if ($('input#basket-no-register-type').attr('checked')) {
      $('#basket-login').hide();
      $('#basket-register').hide();
      $('#basket-no-register').show();
    }
  }  
  
  // Kliknuti na typ zakaznika - prihlasit nebo registrovat v kosiku
  $('input#basket-login-type').click(function() { RegClick() });
  $('input#basket-register-type').click(function() { RegClick() });
  $('input#basket-no-register-type').click(function() { RegClick() });
  
  // Aktivace LIGTHBOXU
	$("a[rel='lightbox']").colorbox();
//	$("a.lightbox").colorbox();

  $("a.regenerate").click(function() {
    tmp = new Date();
    tmp.getDate();
    imn="./class/antispam/image.php?i="+tmp;
    $("img.imgcapt").attr("src", imn);
    return false;
  });
  
  $('.eshop-f-inp[title]').qtip({
    position: { },
    show: { when: { event: 'focus' }, effect: { type: 'fade', length: 200 }, delay: 10 },
    hide: { when: { event: 'blur' }, effect: { type: 'fade', length: 200 }, delay: 10 },
    position: { corner: { tooltip: 'leftMiddle' }, adjust: { x: 15, y: -8 } },
    style: { 
      padding: 5,
      background: '#EF0E0E',
      color: 'black',
      textAlign: 'center',
      border: {
        width: 3,
        radius: 5,
        color: '#8F2323'
      },
      tip: false,
    }
  });
  
  $('.eshop-f-err[title]').qtip({
    show: { when: { event: 'mouseover' } },
    hide: { when: { event: 'mouseout' } },
    position: { corner: { tooltip: 'leftMiddle' }, adjust: { x: 5, y: -8 } },
    style: { 
      padding: 5,
      background: '#EF0E0E',
      color: 'black',
      textAlign: 'center',
      border: {
        width: 7,
        radius: 5,
        color: '#8F2323'
      },
      tip: true,
      name: 'dark' // Inherit the rest of the attributes from the preset dark style
    }
  });
  
  $("#loginfrm input").keypress(function(e) {
    if(e.which == 13) {
      $("form#loginfrm #snd").click();
    }
  });
  
});

//-->