

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


var stanje=0;

var total_width=screen.width;
var total_height=screen.height;

function ShowHideOby(){
		
	var innerContainerWidth = 0;
	var innerContainerHeight = 0;//if 0. then it usess auto strech
	
	var numSel = 0;//number of select elements before popup div !!! ONLY IN IE6
		
	if(stanje==0){
		stanje=1;
		
		//alert(stanje);
						
		opacity_cont('popUpBg', 0, 80, 300);	
		
		//second id(element) is for seperate opacity from BG
		//last two...div width, height
		//opacity('popUpObyInner', 'popUpObyContainer', 0, 100, 500, innerContainerWidth, innerContainerHeight);
		
		setTimeout("ShowHideOby_img()", 300)
				
		setTimeout("selectVisibility('"+numSel+"')", 0)
		
	}
	else{
		stanje=0;
		
		//alert(stanje);
		
		
		opacity_cont('popUpBg', 80, 0, 500);
		
		//second id(element) is for seperate opacity from BG
		//last two...div width, height
		//opacity('popUpObyInner', 'popUpObyContainer', 100, 0, 300, innerContainerWidth, innerContainerHeight);
		setTimeout("ShowHideOby_img()", 300)
		
		setTimeout("selectVisibility('"+numSel+"')", 500)
		
	}
	
	

}

function ShowHideOby_img(){
		
	var object_k = document.getElementById('popUpObyContainer').style;
	
	var object = document.getElementById('popUpObyInner').style;
	
	if(stanje==1){
		object_k.left=0+'px';
		object_k.top=0+'px';
		
		object_k.width=100+'%';
	}
	else{
		
		object_k.left=-10000+'px';
		object_k.top=-10000+'px';
	}
	
		
}


function preveri_stanje(){
		
	var innerContainerWidth = 300;
	var innerContainerHeight = 0;//if 0. then it usess auto strech
	
	var numSel = 0;//number of select elements before popup div !!! ONLY IN IE6
		
	if(stanje==0){
		stanje=1;
		
		//alert(stanje);
						
		opacity_cont('popUpBg', 0, 80, 300);	
		
		//second id(element) is for seperate opacity from BG
		//last two...div width, height
		opacity('popUpBlogInner', 'popUpBlogContainer', 0, 100, 500, innerContainerWidth, innerContainerHeight);
		
		setTimeout("selectVisibility('"+numSel+"')", 0)
		
	}
	else{
		stanje=0;
		
		//alert(stanje);
		
		
		opacity_cont('popUpBg', 80, 0, 500);
		
		//second id(element) is for seperate opacity from BG
		//last two...div width, height
		opacity('popUpBlogInner', 'popUpBlogContainer', 100, 0, 300, innerContainerWidth, innerContainerHeight);
		
		setTimeout("selectVisibility('"+numSel+"')", 500)
		
	}
	
	

}

function selectVisibility(numSel){

	var arSelect = document.getElementsByTagName("select");
	//var len=arSelect.length;
	
	//alert(BrowserDetect.browser+' '+BrowserDetect.version+' '+BrowserDetect.OS);
	
	if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '6'){
		if(stanje==1){
			for(var i=0;i<numSel;i++){
				arSelect[i].style.visibility = 'hidden';			
			}
		}
		else{
			for(var i=0;i<numSel;i++){
				arSelect[i].style.visibility = 'visible';			
			}	
		}
	}
		
}
		

//for inner container
function opacity(id, idSec, opacStart, opacEnd, millisec, width, height) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
	
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd)
	{
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "','" + idSec + "'," + 0 +",'" + width + "','" + height + "')",(timer * speed));
            timer++;			
        }	
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++){
            setTimeout("changeOpac(" + i + ",'" + id + "','" + idSec + "'," + 1 +",'" + width + "','" + height + "')",(timer * speed));
            timer++;	
        }		
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id, idSec, stat, width, height) {
	
	var object_k = document.getElementById(idSec).style;
	
	var object = document.getElementById(id).style;
	
    /*object_k.opacity = (opacity / 100);
    object_k.MozOpacity = (opacity / 100);
    object_k.KhtmlOpacity = (opacity / 100);
    object_k.filter = "alpha(opacity=" + opacity + ")";*/
		
	if(stat==1){
		if(opacity>5 && opacity<7){
			object_k.left=0+'px';
			object_k.top=0+'px';
			
			object_k.width=100+'%';
			
			if(height!=0){
				object_k.height=height+'px';
				object.height=height+'px';
			}
			
			if(width!=0){
				object.width=width+'px';
			}			
		}
	}
	else{
		if(opacity<=1){
			object_k.left=-10000+'px';
			object_k.top=-10000+'px';
			
			/*object_k.width=0+'px';
			object_k.height=0+'px';
			
			object.width=0+'px';
			object.height=0+'px';*/
		}
	}
} 

//for container
function opacity_cont(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
	
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd)
	{
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac_cont(" + i + ",'" + id + "'," + 0 +")",(timer * speed));
            timer++;			
        }	
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++){
            setTimeout("changeOpac_cont(" + i + ",'" + id + "'," + 1 +")",(timer * speed));
            timer++;	
        }		
    }
}

//change the opacity for different browsers
function changeOpac_cont(opacity, id, stat) {
	var object = document.getElementById(id).style;
		    
	object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	
	
	if(stat==1){
		if(opacity>5 && opacity<7){
			object.left=0+'px';
			object.top=0+'px';
			
			object.width=100+'%';
						
			var _docHeight = (document.height || document.body.offsetHeight);
						
			object.height= _docHeight + 'px';	
			//object.height=100+'%';
		}
	}
	else{
		if(opacity<=1){
			object.left=-10000+'px';
			object.top=-10000+'px';
			
			object.width=0+'px';
			object.height=0+'px';
		}
	}
} 