function showDetail(url,w,h){

	wasOpen  = false;
  if ( (0<w) && (0<h) )
  {
	 win = window.open(url,'detail','left='+(screen.width/2-w/2)+', top='+(screen.height/2-h/2)+', width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	}
	else
	{
    win = window.open(url);
  }
	win.focus();
  return (typeof(win)=='object')?true:false;

}       



function showImage(url,w,h){


	wasOpen  = false;
  if ( (0<w) && (0<h) )
  {
	  win = window.open('', '', 'left='+(screen.width/2-100)+', top='+(screen.height/2-80)+', width=190, height=180, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	}
	else
	{
    win = window.open(url);
  }

  win.focus();

  win.document.write('<html style="padding: 0; maring: 0;"><body style="padding: 0; maring: 0;"><div style="text-align: center;" id="loading"><img src="images/loading.gif" width="168" height="147" alt="" /></div><img id="photo" style="position: absolute; left: 0; top: 0; visibility: hidden;" onclick="window.close();" onload="this.style.visibility=\'visible\'; window.resizeTo((document.getElementById(\'photo\').offsetWidth+30), (document.getElementById(\'photo\').offsetHeight+80)); window.moveTo(screen.width/2-(document.images.photo.width+30)/2, screen.height/2-(document.images.photo.height+80)/2); window.resizeTo((document.getElementById(\'photo\').offsetWidth), (document.getElementById(\'photo\').offsetHeight)); window.moveTo(screen.width/2-(document.images.photo.width+10)/2, screen.height/2-(document.images.photo.height+80)/2);" name="photo" src="'+url+'" alt="" /></body></html>');

  
  return (typeof(win)=='object')?true:false;

}


function showSubmenu(no)
{
  if (document.getElementById('submenu'+no))
  {
    document.getElementById('menu'+no).style.background='url(../images/menu-active.png) right bottom no-repeat'; 
    document.getElementById('submenu'+no).style.visibility='visible';  
    document.getElementById('submenu'+no).style.top=(document.getElementById('menu'+no).offsetTop+2)+'px';  
  }
}

function hideSubmenu(no)
{       
  if (document.getElementById('submenu'+no))
  {
    document.getElementById('menu'+no).style.background='url(../images/menu-separator.jpg) right bottom no-repeat'; 
    document.getElementById('submenu'+no).style.visibility='hidden';  
  }
}










  function monthName(month){

   
    var mn=new Array(13); 
    
    mn[1]='Leden';
    mn[2]='Únor';
    mn[3]='Březen';
    mn[4]='Duben';
    mn[5]='Květen';
    mn[6]='Červen';
    mn[7]='Červenec';
    mn[8]='Srpen';
    mn[9]='Září';
    mn[10]='Říjen';
    mn[11]='Listopad'; 
    mn[12]='Prosinec';
    
    return mn[month];
  }


// nastavi datum a cas vybrany v kalendari do inputboxu "date"

function setDateTime(day, month, year, hour, min, obj)
{
  document.getElementById('time_select').style.visibility='hidden';
  document.getElementById(obj).value=day+'. '+month+'. '+year+', '+document.getElementById('hour').value+':'+document.getElementById('minute').value;
}            




// zobrazi kalendar

function calendar(month, year, hour, min, obj)
{
  var content;
  
  
  if ('visible'!=document.getElementById('time_select').style.visibility)   
  {  
    var string=new String(document.getElementById(obj).value);
    var tmp=string.split(', ');
    var tmp_date=new String(tmp[0]);
    var tmp_time=new String(tmp[1]);
    
    var date=tmp_date.split('. ');
    var time=tmp_time.split(':');
    

    n_month=date[1];
    n_year=date[2];
    
    n_hour=time[0];
    n_min=time[1]; 
    
    
    if ( 
      (parseInt(n_month)<13) && (parseInt(n_month)>0)
      &&
      (parseInt(n_year)<3000) && (parseInt(n_year)>1970)
      &&
      (parseInt(n_hour)<25) && (parseInt(n_hour)>=0)
      &&
      (parseInt(n_min)<60) && (parseInt(n_min)>=0) 
    )
    {
      month=parseInt(n_month);   
      year=parseInt(n_year);
      hour=parseInt(n_hour);
      min=parseInt(n_min);
    }
    
  }
  
  date=new Date(year, month-1, 1);
  var dow=date.getDay()-1;
  
  
  var daysinmonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) daysinmonth[2] = 29;
  
  var nod=daysinmonth[month-1];
  
  
  content='<div class="float_right" onmouseover="this.style.cursor=\'pointer\';" onclick="document.getElementById(\'time_select\').style.visibility=\'hidden\';">X</div><b>Zvolte čas a poté datum</b> ';

  content+='<div class="margin-top"><input type="text" id="hour" maxlength="2" value="'+hour+'" /> h : <input type="text" id="minute" maxlength="2" value='+min+' /> m</div><br />';

  content+='<div id="cal_tab"><table id="calendar_table" cellpadding="0" cellspacing="0" border="0">';

  content+='<tr><th>Po</th><th>Út</th><th>St</th><th>Čt</th><th>Pá</th><th>So</th><th>Ne</th></tr>';

  
  if (dow<0)
  {
    dow=dow+7;
  }
  
  for (i=1; i<=dow%7; i++)
  {
    if (1==i%7)
    {
      content+='</tr><tr>';
    }
    content+='<td>&nbsp;</td>'; 
  
  }
  
  
  for (i=dow+1; i<=nod+dow; i++)
  {
    if (1==i%7)
    {
      content+='</tr><tr>';
    }   
    
    content+='<td><span onmouseover="this.style.cursor=\'pointer\';" onclick="setDateTime('+(i-dow)+', '+month+', '+year+', '+hour+', '+min+', \''+obj+'\')">'+(i-dow)+'</a></td>';           
  }

  if (0!=(nod+dow)%7)
  {
    for (i=(nod+dow)%7; i<7; i++)
    {
      content+='<td>&nbsp;</td>'; 
    }
  }

  content+='</tr>';   
  
  content+='</table></div>';   
   
  if (month>1)
  {
    content+='<span onmouseover="this.style.cursor=\'pointer\';" onclick="calendar('+(month-1)+', '+year+', '+hour+', '+min+', \''+obj+'\')"> &lt; </span>';
  }
   
  content+=monthName(month);
  
  if (month<12)
  {
    content+='<span onmouseover="this.style.cursor=\'pointer\';" onclick="calendar('+(month+1)+', '+year+', '+hour+', '+min+', \''+obj+'\')"> &gt; </span>';
  }
 
  content+='<br />';
 
  if (year>1970)
  {
    content+='<span onmouseover="this.style.cursor=\'pointer\';" onclick="calendar('+month+', '+(year-1)+', '+hour+', '+min+', \''+obj+'\')"> &lt; </span>';
  }
    
  content+=year;
  
  if (year<3000) 
  {
    content+='<span onmouseover="this.style.cursor=\'pointer\';" onclick="calendar('+month+', '+(year+1)+', '+hour+', '+min+', \''+obj+'\')"> &gt; </span><br />';
  }

  
  

//  document.getElementById('time_select').style.left=(screen.width/2-document.getElementById('time_select').offsetWidth/2)+'px';
//  document.getElementById('time_select').style.top=(screen.height/2-document.getElementById('time_select').offsetHeight/2)+'px';
  document.getElementById('time_select').style.visibility='visible';
  document.getElementById('time_select').innerHTML=content;
}   














function setDate(day, month, year, obj)
{
  document.getElementById('time_select').style.visibility='hidden';
  document.getElementById(obj).value=day+'. '+month+'. '+year;
}            





function calendarDate(month, year, obj)
{

  var content;
  var css_class;

  if (month<1)
  {
    month=12;
    year--;
  }
  
  if (month>12)
  {
    month=1;
    year++;
  }
  
  if ('visible'!=document.getElementById('time_select').style.visibility)   
  {  
    var string=new String(document.getElementById(obj).value);
    var tmp=string.split(', ');
    var tmp_date=new String(tmp[0]);
    var tmp_time=new String(tmp[1]);
    
    var date=tmp_date.split('. ');
    var time=tmp_time.split(':');
    

    n_month=date[1];
    n_year=date[2];
    
    
    
    if ( 
      (parseInt(n_month)<13) && (parseInt(n_month)>0)
      &&
      (parseInt(n_year)<3000) && (parseInt(n_year)>1970)
    )
    {
      month=parseInt(n_month);   
      year=parseInt(n_year);
    }
    
  }
  
  date=new Date(year, month-1, 1);
  var dow=date.getDay()-1;
  
  
  var daysinmonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) daysinmonth[2] = 29;
  
  var nod=daysinmonth[month-1];
  
  
  content='<div class="float_right" onmouseover="this.style.cursor=\'pointer\';" onclick="document.getElementById(\'time_select\').style.visibility=\'hidden\';">X</div><b>Zvolte datum</b> ';

  content+='<div id="cal_tab"><table id="calendar_table" cellpadding="0" cellspacing="0" border="0">';

  content+='<tr><th>Po</th><th>Út</th><th>St</th><th>Čt</th><th>Pá</th><th class="weekend">So</th><th class="weekend">Ne</th></tr>';

  
  if (dow<0)
  {
    dow=dow+7;
  }
  
  for (i=1; i<=dow%7; i++)
  {
    if (1==i%7)
    {
      content+='</tr><tr>';
    }
    content+='<td>&nbsp;</td>'; 
  
  }
  
  
  for (i=dow+1; i<=nod+dow; i++)
  {
    if (1==i%7)
    {
      content+='</tr><tr>';
    }   
      if ( (i%7>5) ||  (0==i%7) )
      {
        css_class=' class="weekend"';
      }
      else
      {
        css_class='';
      }
    
    content+='<td'+css_class+'><span onmouseover="this.style.cursor=\'pointer\';" onclick="setDate('+(i-dow)+', '+month+', '+year+', \''+obj+'\')">'+(i-dow)+'</a></td>';           
  }

  if (0!=(nod+dow)%7)
  {
    for (i=(nod+dow)%7; i<7; i++)
    {
      content+='<td'+css_class+'>&nbsp;</td>'; 
    }
  }

  content+='</tr>';   
  
  content+='</table></div>';   
  
  content+='<div id="month_year_select">';
  
  content+='<span class="left_arrow" style="padding-left: 15px;" onmouseover="this.style.cursor=\'pointer\';" onclick="calendarDate('+(month-1)+', '+year+', \''+obj+'\')"><!-- --></span>';
   
  content+='<span class="month_select">'+monthName(month)+'</span>';
  
  content+='<span class="right_arrow" onmouseover="this.style.cursor=\'pointer\';" onclick="calendarDate('+(month+1)+', '+year+', \''+obj+'\')"><!-- --></span>';
 
  content+='<div class="clear_both"><!-- --></div>';
 
  if (year>10)
  { 
    content+='<span class="left_long_arrow" onmouseover="this.style.cursor=\'pointer\';" onclick="calendarDate('+month+', '+(year-10)+', \''+obj+'\')"><!-- --></span>';
  }

  if (year>1)
  {
    content+='<span class="left_arrow" onmouseover="this.style.cursor=\'pointer\';" onclick="calendarDate('+month+', '+(year-1)+', \''+obj+'\')"><!-- --></span>';
  }
    

  content+='<span class="year_select">'+year+'</span>';
  
  if (year<4091) 
  {
    content+='<span class="right_arrow" onmouseover="this.style.cursor=\'pointer\';" onclick="calendarDate('+month+', '+(year+1)+', \''+obj+'\')"><!-- --></span>';
  }

  if (year<5000) 
  {
    content+='<span class="right_long_arrow" onmouseover="this.style.cursor=\'pointer\';" onclick="calendarDate('+month+', '+(year+10)+', \''+obj+'\')"><!-- --></span>';
  }
  content+='<div class="clear_both"><!-- --></div>';
  
  content+='</div>';
   
  document.getElementById('time_select').style.left=(screen.width/2-document.getElementById('time_select').offsetWidth/2)+100+'px';
  document.getElementById('time_select').style.top=(screen.height/2-document.getElementById('time_select').offsetHeight/2)+'px';
  document.getElementById('time_select').style.visibility='visible';
  document.getElementById('time_select').innerHTML=content;
}   



function countPrice()
{
  document.getElementById('price_total').value=
    document.getElementById('price_km').value*document.getElementById('km').value
    +
    document.getElementById('price_hours').value*document.getElementById('hours').value;
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function notice(obj, text, operation, box)
{
  if ('show'==operation)
  {
    document.getElementById(box).innerHTML=text;
    document.getElementById(box).style.left=(findPosX(obj)+obj.offsetWidth/2-document.getElementById(box).offsetWidth/2)+'px';
    document.getElementById(box).style.top=(findPosY(obj)-document.getElementById(box).offsetHeight-2)+'px';
    document.getElementById(box).style.visibility='visible';
  }
  else
  {
    document.getElementById(box).style.visibility='hidden';
    document.getElementById(box).innerHTML='';
  }

}



function galleryListRight()
{
  if (gx<=(450-galleryLength-last))
  {
    return false;
  }
  gx-=5;
  document.getElementById('gallery-list-in').style.margin='0 0 0 '+gx+'px';  
}

function galleryListLeft()
{
  if (gx>=0)
  {
    return false;
  }
  gx+=5;
  document.getElementById('gallery-list-in').style.margin='0 0 0 '+gx+'px';  
}


function preloadImage(path, id)
{
  images[id]=new Image();
  images[id].src=path; 
}



/*
function setGalleryImage(id)
{
//  document.getElementById('gallery-image-name').innerHTML='<h2>'+images[id].name+'</h2>';
  document.getElementById('main-gallery-image').src=images[id].src;
  document.getElementById('main-image-a').href=images[id].src.replace('/thumb-m', '');
}
*/

function setGalleryImage(path)
{
//  showImage(document.getElementById('main-gallery-image').src.replace('/thumb-m', ''), 1, 1);
  document.getElementById('detail-main-image').style.background='url('+path+') center center no-repeat';
//  aler


}


// prepocitava objednavku darkovych poukazu
function zmenaCelkem() {
	var a = parseInt(document.form.hodnota.options[document.form.hodnota.selectedIndex].text);
	var b = parseInt(document.form.pocet.value);
	if (!b) {
		b = 1;
		document.form.pocet.value = 1;
	}
	document.form.celkem.value = (a && b) ? a*b : 0;
}


function asp()
{
  if (document.getElementById('asp'))
  {
    document.getElementById('aspdiv').style.display='none';
    document.getElementById('asp').value='projektstudio';
  }
}


function scrollDown(offset)
{
	document.getElementById('content').scrollTop=offset;
//  document.getElementById('page').scrollTop=50;
//  document.getElementById('page').scrollTop=500;
}




var gx=0;
var images=new Array();
var galleryLength=0;
var last;
