function ClearDefaultInputValue()
{
  $(".clearinput").each(function(){
                             this.onfocus = function(){inputText = this.value;this.value = "";};
                             this.onblur = function(){if(!this.value) this.value=inputText}
                            }
                        );
}

$(document).ready(ClearDefaultInputValue);

function ShowImg(obj, src)
{
 document.getElementById("ShowPic").src = src;
 document.getElementById("ShowPic").parentNode.href = obj.href;
}


function ShowLiteBox(Obj)
{  
  var imgPreload = new Image();
  imgPreload.id = "ShowPicBox";
  imgPreload.title = "Нажмите, чтобы закрыть окно";
  imgPreload.src = Obj.href;


	imgPreload.onload = function()
	{
	  if(imgPreload.width>=document.body.offsetWidth)
      imgPreload.style.width = parseInt(document.body.offsetWidth-10)+'px';
      
  	var theShadow = document.createElement('div');
		theShadow.id = "LiteBox";
	  theShadow.style.height = document.body.offsetHeight+100+'px';
		imgPreload.onclick = function() {$(theShadow).remove(); }
		
  	var theBox = document.createElement('div');
  	var theDivImg = document.createElement('div');
  	theBox.className = "photoes";
  	
    
    $("body").append(theShadow);
    
    $(theDivImg).append(imgPreload);
  	
  	if(Obj.parentNode.getElementsByTagName("ul")[0])
  	{
      var miniPics = Obj.parentNode.getElementsByTagName("ul")[0].cloneNode(true);
      $(miniPics).find("a").each(function(){this.onclick=function(){ShowImgBox(this.href); return false;}});
    	$(theBox).append(theDivImg).append(miniPics);

  	}
  	else
      $(theBox).append(theDivImg);
     
  	$(theShadow).html(theBox).animate({opacity:"toggle"}, 300);
	}
}

function ShowImgBox(src)
{
  var PicBox = document.getElementById("ShowPicBox");
  if(PicBox)
  {
    $(PicBox.parentNode).css({display:"none"});
    var imgPreload = new Image();
    imgPreload.id = "ShowPicBox";
    imgPreload.title = "Нажмите, чтобы закрыть окно";
    imgPreload.src = src;
		imgPreload.onclick = function() {$("#LiteBox").remove(); }
    
    imgPreload.onload = function()
    {
      if(imgPreload.width>=document.body.offsetWidth)
        imgPreload.style.width = parseInt(document.body.offsetWidth-10)+'px';
      else
        imgPreload.style.width = "";
    }
    
    $(PicBox.parentNode).html(imgPreload).animate({opacity:"show"}, 800);

  }
}
