function findPos(obj) {
	var curleft = curtop = 0;

	if (obj.offsetParent) {

	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;

		} while (obj = obj.offsetParent);


	return [curleft,curtop];
}}

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}

function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

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 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 youTube(obj)
{
  if (!document.getElementById('ytform'))
  {
    return false;
  }

  var tmp=obj.value.split('='); 
  var code=tmp[1];
      
  if (code)
  {        
    document.getElementById('ytform').innerHTML='<object width="400" height="300"><param name="movie" value="http://www.youtube.com/v/'+code+'&hl=cs_CZ&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+code+'&hl=cs_CZ&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="400" height="300"></embed></object>';
  }
  
    
  return true;

}

function formHint(obj, text)
{
  var nodes=obj.parentNode.childNodes;
  for (i=0; i<nodes.length; i++)
  {
    if ('hint'==nodes[i].className)
    {
      nodes[i].style.display='block';
    }
  }
}


function formHintHide(obj)
{

  var nodes=obj.parentNode.childNodes;
  for (i=0; i<nodes.length; i++)
  {
    if ('hint'==nodes[i].className)
    {
      nodes[i].style.display='none';
    }
  }
}


function formHint2(obj, text)
{
  var nodes=obj.parentNode.parentNode.childNodes;
  for (i=0; i<nodes.length; i++)
  {
    if ('hint'==nodes[i].className)
    {
      nodes[i].style.margin='0 0 0 200px';
      nodes[i].style.display='block';
    }
  }
}



function formHintHide2(obj)
{
  var nodes=obj.parentNode.parentNode.childNodes;
  for (i=0; i<nodes.length; i++)
  {
    if ('hint'==nodes[i].className)
    {
      nodes[i].style.display='none';
      nodes[i].style.margin='0 0 0 590px';
    }
  }
}

function getList(o, list, f, v, e, d)
{
    
  field=f;
  value=v;
  obj=o;
  empty=e;
  listDef=d;

//section_id='';
xmlhttpList=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttpList=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttpList=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttpList!=null)
  {
  
    xmlhttpList.onreadystatechange=onResponseLists;
    xmlhttpList.open("GET",'/ajax/lists.php?t='+list+'&f='+field+'&v='+value,true);
    xmlhttpList.send(null);
  }
else
  {
    return false;
  }
  

}


function onResponseLists()
{

  if(xmlhttpList.readyState!=4) return;

  if(xmlhttpList.status!=200)
  {
    return false;
  }
  


  var value, text, selected, sel, industry;


  x=xmlhttpList.responseXML.documentElement.getElementsByTagName("ITEM");

/*  
  if (obj)
  { 
    obj.options.length=0;
    var optn = document.createElement("OPTION");
    optn.text='- Zvolte -';
    optn.value='';
    obj.options.length=0;
    obj.options.add(optn);
  }  
*/  
  for (i=0; i<x.length; i++)
  {
    xx=x[i].getElementsByTagName("ID");
    var id=xx[0].firstChild.nodeValue;
    xx=x[i].getElementsByTagName("TEXT");
    var text=xx[0].firstChild.nodeValue;
/*      
      if (id==defaultRegion)
      {
        selected=' selected="selected"';
      }
      else
      {
        selected='';
      }
*/      
      var optn = document.createElement("OPTION");
      optn.text=text;
      optn.value=id;
      
      if (listDef==id)
      {
        optn.selected=true;
      }

  if (obj)
  {
    obj.options.add(optn);
  }

  if (document.getElementById('region-search'))
  { 
//    document.getElementById('region-search').options.add(optn);
  }

      
    }


  if (0==i)
  {
    obj.options.length=0;
    var optn = document.createElement("OPTION");
    optn.text=empty;
    optn.value='';
    obj.options.length=0;
    obj.options.add(optn);
  }             

  if (0<icoRegion)
  {
    var tmp=icoRegion;
    icoRegion=0;
      document.getElementById('city').options.length=0;
      getList(document.getElementById('city'), 'citys', 'id_region', tmp, '- Zvolte prosím okres -');
  }


  return 'ok';

}


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.moveTo(screen.width/2-(document.images.photo.width+30)/2, screen.height/2-(document.images.photo.height+60)/2); window.resizeTo((document.getElementById(\'photo\').offsetWidth), (document.getElementById(\'photo\').offsetHeight+65)); window.moveTo(screen.width/2-(document.images.photo.width+10)/2, screen.height/2-(document.images.photo.height+60)/2);" name="photo" src="'+url+'" alt="" /></body></html>');



  

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





} 
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 showSubmenu(obj)
{
  if (obj.childNodes[2])
  {
    obj.childNodes[2].style.display='block';
  }
}

function hideSubmenu(obj)
{       
  if (obj.childNodes[2])
  {
    obj.childNodes[2].style.display='none';
  }
}










  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+'" /><input type="text" id="minute" maxlength="2" value='+min+' /></div><div class="clear_both"><!-- --></div>';

  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 today=new Date();
  
  
  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-dow)==today.getDate()) && (month==(today.getMonth()+1)) && (year==(today.getYear()+1900)) )
      {
        css_class=' class="today"';
      }
      else
      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)+'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 childern(node)
{
  var result='';
  var i;

    result+=node.style.length;
  
  if (count>10000) 
  {
    return false;
  }
  
  count++;
  


  for (i=0; i<node.childNodes.length; i++)
  {
    result+=childern(node.childNodes[i]);
  }
  
  return result;
}


var count=0;

function inactive()
{
/*
  var tmp;
  var i;
//  document.bgColor='#dddddd';
  
  //alert(document.styleSheets[0].cssRules.length);
  
 // alert(document.childNodes.length);

//  for (i=0; i<document.childNodes.length; i++)
//  {
//    tmp+=childern(document.childNodes[i]);
//  }


  for (i=0; i<document.styleSheets[0].cssRules.length; i++)
  {
    tmp=document.styleSheets[0].cssRules[i].style.cssText;
    if ('color'==tmp.substring(0, 5))
    {
//      alert(tmp);
      document.styleSheets[0].cssRules[].cssText='color: rgb(10, 10, 10);';
    }    
  //  alert("Style sheet " + i + " is titled " + document.styleSheets[i].title);
  }
  

//  alert(tmp);

  //document.getElementById('page').style.background='#ddd';
  //document.getElementById('page').style.background='#ddd';
*/  
  
}


function openTree()
{

}


function getexpirydate(nodays){
 var UTCstring;
 Today = new Date();
 nomilli=Date.parse(Today);
 Today.setTime(nomilli+nodays*24*60*60*1000);
 UTCstring = Today.toUTCString();
 return UTCstring;
}
function setcookie(name,value,duration){
 document.cookie = 
  name+"="+escape(value)+
  ";expires="+getexpirydate(duration)+
  ";path=/";
}
function getcookie(name) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(name);
 if (index1==-1) return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(
  cookiestring.substring(
   index1+name.length+1,index2 ));
}

function popInit(obj)
{
  if ('false'==getcookie(obj+'show'))
  {
    document.getElementById(obj).style.height='20px';
    document.getElementById(obj).style.overflow='hidden';
  }
}


function pop(obj)
{
  if (!document.getElementById(obj))
  {
    return false;
  }
  

  
  if ('hidden'==document.getElementById(obj).style.overflow)
  {
    setcookie(obj+'show', 'true', 365);
    document.getElementById(obj).style.height='200px';
    document.getElementById(obj).style.overflow='visible';
    document.getElementById(obj).style.height='';
  }
  else
  {
    setcookie(obj+'show', 'false', 365);
//    original[obj]['height']=document.getElementById(obj).offsetHeight;
    document.getElementById(obj).style.height='20px';
    document.getElementById(obj).style.overflow='hidden';
  }
}

function showTasks(where)
{
  if (oldid)
  {
    document.getElementById(oldid).innerHTML=oldhtml;
//    alert(oldhtml);
  }
  
  
  oldid=where.id;
  oldhtml=where.innerHTML;
  where.innerHTML+='</tr>'+document.getElementById('tasks'+where.id).innerHTML;
  
  alert(where.innerHTML);

}


function admin_help_show(objName, e)
{
//  document.getElementById(objName).style.left=e.clientX;
//  document.getElementById(objName).style.top=(e.clientY+40);
  document.getElementById(objName).style.visibility='visible';
}

function admin_help_hide(objName)
{
  document.getElementById(objName).style.visibility='hidden';
}

function customPreview(text, font)
{
  if (text)
  {
    document.getElementById('custom-preview').innerHTML='<img src="/font-preview.php?f='+font+'&t='+text+'" alt="'+text+'" />';
  }
  else
  {
    document.getElementById('custom-preview').innerHTML='';
  }
}



function checkICO(object)
{


document.getElementById('company-name').disabled=true;
document.getElementById('company-name').value='Vyhledávám';


obj=object;
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=onResponseICO;
  xmlhttp.open("GET",'/msi/ajax/companys.php?ico='+object.value,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }

}

function onResponseICO()
{

var ok=true;
var x;
var xx;

//alert('Font s tímto názvem již existuje.');
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  return false;
  }


x=xmlhttp.responseText;

document.getElementById('company-name').value=x;
document.getElementById('company-name').disabled=false;

if (x)
{
  document.getElementById('dic').value='CZ'+obj.value;
  document.getElementById('street').focus();
}  


}



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







function checkLogin(login)
{


xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=onResponseLogin;
  xmlhttp.open("GET",'/ajax/logins.php?login='+login,true);
  xmlhttp.send(null);
  }
else
  {
    return false;
  }

}

function onResponseLogin()
{

var x;


if(xmlhttp.readyState!=4) return;

if(xmlhttp.status!=200)
  {
  return false;
  }



x=xmlhttp.responseText;


if (x)
{
  alert('Zadané uživatelské jméno je už obsazené, zvol prosím jiné.');
  document.getElementById('login').focus();
  document.getElementById('login').select();
}  


}



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



function setGalleryImage(obj)
{
  var tmp;
//  document.getElementById('gallery-image-name').innerHTML='<h2>'+images[id].name+'</h2>';
  document.getElementById('main-gallery-image').style.background=obj.style.background.replace('/thumb-s', '/thumb-m');
  //document.getElementById('main-gallery-image').style.background='#f00';

}


function showGalleryImage(path)
{
 // showImage(document.getElementById('main-gallery-image').src.replace('/thumb-m', ''), 1, 1);
}


function treePaging(ul, index, dir, pag)
{               
  if (!document.getElementById('secondMenu'))
  {
    return false;
  }
  
  if (!ul)
  {
    
    var uls=getElementsByClassName('second-menu-2', document.getElementById('secondMenu'));
    var lis;
    
  
    for (i=0; i<uls.length; i++)
    {
  //    alert(uls[i].tagName);
      if ('UL'==uls[i].tagName)
      {
        lis=getElementsByClassName('second-menu-li', uls[i]);
      
        if (lis.length>10)
        {
          ulp[i]=document.createElement('li');
//          ulp[i].innerHTML='<span onclick="treePaging(this.parentNode.parentNode, '+i+', 1, this.parentNode);">&gt;</span>';
          uls[i].appendChild(ulp[i]);
          ulo[i]=0;
          treePaging(uls[i], i, 0, ulp[i]);
          
        }
      }
    }

  }
  
  
  else
  {
  
    if (1==dir)
    {
      ulo[index]+=10;
    }
    else if (2==dir)
    {
      ulo[index]-=10;
    }
    
    if (0>ulo[index])
    {
      ulo[index]=0;
    }
    
    
  
    var lis=getElementsByClassName('second-menu-li', ul, index);
    var end=ulo[index]+10;
    var len=lis.length;
    
    
    
    if (end>len)
    {
      end=len;
    }
    
  
    for (j=0; j<len; j++)
    {
      if ( (j>=ulo[index]) && (j<end) )
      {
        lis[j].style.display='block';        
      }
      else
      {
        lis[j].style.display='none';
      }        
      
    } 
    
    if (pag)
    {
    
      pag.innerHTML='';
      
      if (ulo[index]>0)
      {
        pag.innerHTML+='<span class="js-paging" style="float: left;" onclick="treePaging(this.parentNode.parentNode, '+index+', 2, this.parentNode);">&lt;</span>';
      }   
  
  
      if (end<len)
      {
      
        pag.innerHTML+='<span class="js-paging" style="float: right;" onclick="treePaging(this.parentNode.parentNode, '+index+', 1, this.parentNode);">&gt;</span>';
      }  
      
      pag.innerHTML+='<div class="clear_both">&nbsp;</div>'; 
    }
  
  }
  
}




function getElementsByClassName(className,parentElement) {
    var elements = [];
    var parentElement = parentElement || document.getElementsByTagName("html")[0];
    var nodes = parentElement.getElementsByTagName('*');

    for (var i = 0, child; child = nodes[i]; i++) {
      if (child.className && hasClassName(child,className)) {
        elements.push(child);
      }
    }
  return elements;
}

function hasClassName(element,className) {
    return element.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"));
}







var obj;
var oldid;
var oldhtml;
var images=new Array();
var ulo=new Array();
var ulp=new Array();

