function getSub(year,kat){
 // window.console.log('year:'+ year + ' kat: ' + kat);
  dojo.xhrPost(new postData("/galerie/sub",year,kat,'','','subCat'));
  getImgNav(year,'','');
  //getImg('','','','');
}

function getImgNav(year,kat,sub){
  //alert(year + ' ' +  kat + ' ' + sub);
  
  dojo.xhrPost(new postData("/galerie/img",year,kat,sub,'','imgNavDiv'));
  getImg('','','','');
}

function getImg(year,kat,sub,image){
	dojo.xhrPost(new postData("/galerie/item",year,kat,sub,image,'imgDiv'));
}

function postData(url,year,kat,sub,img,id) {
	this.url      = url;
	this.postData = ''+year+':'+kat+":"+sub+":"+img;
	//window.console.log("Post is " + this.postData);
	this.handleAs = "text";
    this.load     = function(data){
                     // alert(data);  
    	              dojo.byId(id).scrollTop= 0;// = '&nbsp;';
                      dojo.byId(id).innerHTML = data;
                   };
    this.error = function(error){
      alert(error);
    };
}

function changePic(elem){
	  var obj = dojo.byId(elem);
	  if(obj){
		 var src = obj.src.split("/");
		 var img = src[src.length-1];
		// alert(img);
		 var split = img.split('-')
		 if(split.length != 1)
		   img = split[0]+'.png';
		 else
		   img = split[0].split('.')[0]+'-light.png';
		// alert(img);
		 src[src.length-1] = img;
		 obj.src = src.join('/');
	  } 
	}


function posItToSize(width,height,elemName) {
     window.console.log('resizing... ');
	  var myWidth = 0, myHeight = 0;
	  obj = dojo.byId(elemName);
	  if(obj && width == null && height== null) {
	    width = (obj.style.width);
	    height = (obj.style.height);
	  }
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }
	  window.console.log('Window size is height: ' +  myHeight + ' width: ' + myWidth);
	  window.console.log('Element size is height: ' +  height + ' width: ' + width);
	  toppos = 20;
	  leftpos = 20;
	  if(myWidth > width)
	    leftpos = (myWidth - width) / 2;
	  if(myHeight > height)
	    toppos = (myHeight-height) / 2;
	  if(document.getElementById(elemName))
	  with(document.getElementById(elemName)){
	    style.top = toppos.toString() + "px";
	    style.left = leftpos.toString() + "px";
	  }
	  window.console.log('moved to top:' + toppos + 'px; left:' + leftpos + 'px' );
	}

