var popupStatus=0;
var iframeCount=0;
var iframeCount2=0;
var popupLanguage='';
var defaultTab='';

function loosePx(value){
str = String(value);
return str.replace(/px/gi,'');
}

function getPageSize(){

var xScroll,yScroll,arrayPageSize=[];

if(window.innerHeight&&window.scrollMaxY){

xScroll=document.body.scrollWidth;

yScroll=window.innerHeight+window.scrollMaxY;

}else if(document.body.scrollHeight>document.body.offsetHeight){

xScroll=document.body.scrollWidth;

yScroll=document.body.scrollHeight;

}else{

xScroll=document.body.offsetWidth;

yScroll=document.body.offsetHeight;

}

var windowWidth,windowHeight;

if(self.innerHeight){

windowWidth=self.innerWidth;

windowHeight=self.innerHeight;

}else if(document.documentElement&&document.documentElement.clientHeight){

windowWidth=document.documentElement.clientWidth;

windowHeight=document.documentElement.clientHeight;

}else if(document.body){

windowWidth=document.body.clientWidth;

windowHeight=document.body.clientHeight;

}

if(yScroll<windowHeight){

pageHeight=windowHeight;

}else{

pageHeight=yScroll;

}

if(xScroll<windowWidth){

pageWidth=windowWidth;

}else{

pageWidth=xScroll;

}

arrayPageSize.push(pageWidth,pageHeight,windowWidth,windowHeight);

return arrayPageSize;

}// getPageSize

function getPageSize2(){

var xScroll,yScroll;

if(window.innerHeight&&window.scrollMaxY) {

xScroll=window.innerWidth+window.scrollMaxX;

yScroll=window.innerHeight+window.scrollMaxY;

} else if(document.body.scrollHeight>document.body.offsetHeight) {

xScroll=document.body.scrollWidth;

yScroll=document.body.scrollHeight;

} else {

xScroll=document.body.offsetWidth;

yScroll=document.body.offsetHeight;

}

var windowWidth,windowHeight;

if(self.innerHeight) {

if(document.documentElement.clientWidth) {

windowWidth=document.documentElement.clientWidth;

} else {

windowWidth=self.innerWidth;

}

windowHeight=self.innerHeight;

} else if(document.documentElement&&document.documentElement.clientHeight) {

windowWidth=document.documentElement.clientWidth;

windowHeight=document.documentElement.clientHeight;

}else if(document.body) {

windowWidth=document.body.clientWidth;

windowHeight=document.body.clientHeight;

}

if(yScroll<windowHeight) {

pageHeight=windowHeight;

} else {

pageHeight=yScroll;

}

if(xScroll<windowWidth) {

pageWidth=xScroll;

} else {

pageWidth=windowWidth;

}

return[pageWidth,pageHeight];

}// getPageSize2

/**
* Get the body scroll
**/
function getScroll() {
var scrOfX=0,scrOfY=0;
if(document.body&&(document.body.scrollLeft||document.body.scrollTop)) {
scrOfY=document.body.scrollTop;
scrOfX=document.body.scrollLeft;
} else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)) {
scrOfY=document.documentElement.scrollTop;
scrOfX=document.documentElement.scrollLeft;
}
return[scrOfY,scrOfX];
}// getScroll

/**
* Set scroll to a element
**/
function setScroll(id, x) {
document.getElementById(id).scrollTop=x;
}// setScroll


/**
*	upload popup (with a simple gif), checks are performed at input change
**/
function uploadPOPUP(){
var scroll=getScroll();
var size=getPageSize();
var height=size[1];
var width=size[0];

var popup=document.getElementById('uploadpopup');

popup.style.display='block';

height=size[3];

width=size[0];

var top=((loosePx(height)-480)/2)+scroll[0];

var left=(loosePx(width)-610)/2;

$('#uploadpopup').animate({
width: '610px',
height: '480px',
top: top + 'px',
left: left + 'px',
padding: 23 + 'px'
}, 300, function() {

});
$('#map_canvas').animate({
width: '610px',
height: '480px',
top: 0 + 'px',
left: 0 + 'px'
}, 300, function() {

});
}// uploadPOPUP


function hidePOPUP() {
popupStatus=0;
var scroll=getScroll();
var size=getPageSize();
var height=size[3]+scroll[0];
var width=size[0];
var top=loosePx(height)/2;
var left=loosePx(width)/2;


$('#uploadpopup').animate({
width: '0px',
height: '0px',
top: top + 'px',
left: left + 'px',
padding: 0 + 'px'
}, 200, function() {
// Animation complete.
});

}// hidePOPUP
