function getWindowWidth() {
  var myWidth = 0, myHeight = 0;
  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.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myWidth;
}
function getLeftMargin(imageWidth){
	var winWidth = getWindowWidth()
	if(winWidth<=imageWidth){
		marginLeft = 0
	} else {//parluka vidus
		marginLeft = ((winWidth-imageWidth)/2)
	}
}
function getLeftMargin2(){
	return marginLeft
}
function setLeftMargin(imageWidth){
	getLeftMargin(imageWidth)
	document.getElementById('ibox_overlay').style.left = marginLeft + 'px'
}

function openImgPopup(imgName){
	setLeftMargin(1040)
	document.getElementById('ibox_overlay').style.display = "block"
	document.getElementById('ibox_overlay').style.visibility = "visible"
	$.ajax({
		url: '/lv/imagemap/index/id/0?imgUrl='+imgName,
		type: 'GET',
		dataType: 'html',
		timeout: 0,
		error: function(){
			alert('Error loading document');
		},
		success: function(html){

		   // alert(html)
			document.getElementById('ibox_content').innerHTML = html
		}
	});
}

function openVeikaliPopup(imgName){
	setLeftMargin(740)
	document.getElementById('ibox_overlay').style.display = "block"
	document.getElementById('ibox_overlay').style.visibility = "visible"
	$.ajax({
		url: '/lv/imagemap/index/id/0?imgUrl='+imgName,
		type: 'GET',
		dataType: 'html',
		timeout: 0,
		error: function(){
			alert('Error loading document');
		},
		success: function(html){

		   // alert(html)
			document.getElementById('ibox_content').innerHTML = html
		}
	});
}

function openGalleryPopup(galleryId, imgId){
	setLeftMargin(950)
	document.getElementById('ibox_overlay').style.display = "block"
	document.getElementById('ibox_overlay').style.visibility = "visible"
	$.ajax({
		url: '/lv/gallery/index/id/'+galleryId+'/img/'+imgId,
		type: 'GET',
		dataType: 'html',
		timeout: 0,
		error: function(){
			alert('Error loading document');
		},
		success: function(html){

		   // alert(html)
			document.getElementById('ibox_content').innerHTML = html

		}
	});

}



function closeGalleryPopup(){
	//document.getElementById('ibox_overlay').style.display = "none"
	document.getElementById('ibox_overlay').style.display = "none"
	document.getElementById('ibox_overlay').style.visibility = "hidden"
	document.getElementById('ibox_content').innerHTML = ''
}

function openImagemapPopup(imagemapId){
	setLeftMargin(1250)
	document.getElementById('ibox_overlay').style.display = "block"
	document.getElementById('ibox_overlay').style.visibility = "visible"
	$.ajax({
		url: '/lv/imagemap/index/id/'+imagemapId,
		type: 'GET',
		dataType: 'html',
		timeout: 0,
		error: function(){
			alert('Error loading document');
		},
		success: function(html){

		   // alert(html)
			document.getElementById('ibox_content').innerHTML = html

		}
	});
}

function openImagemapPopup2(imagemapId, c_t,c_l,txt){
	setLeftMargin(1250)
	document.getElementById('ibox_overlay').style.display = "block"
	document.getElementById('ibox_overlay').style.visibility = "visible"
	$.ajax({
		url: '/lv/imagemap/index/id/'+imagemapId,
		type: 'GET',
		dataType: 'html',
		timeout: 0,
		error: function(){
			alert('Error loading document');
		},
		success: function(html){

		   // alert(html)
			document.getElementById('ibox_content').innerHTML = html
			sh_cmp_s(c_t,c_l,txt)
		}
	});
}

function closeImagemapPopup(){
	document.getElementById('ibox_overlay').style.display = "none"
	document.getElementById('ibox_overlay').style.visibility = "hidden"
	//document.getElementById('ibox_overlay').style.position = "absolute"

	document.getElementById('ibox_content').innerHTML = ''
}
