	function redirect() {	
		if (get_cookie("lang")) {
			if (get_cookie("lang") == 'bg') {
				document.location.href = 'bg/index.html';
			} else {
				document.location.href = 'en/index.html';
			}
		} else {
			var lang = "en";
			
			if (window.navigator.userLanguage) {
				lang = window.navigator.userLanguage;
			} else if (window.navigator.language) {
				lang = window.navigator.language;
			}
		
			if (lang.toLowerCase() == "bg" || lang.toLowerCase() == "bg-bg") {
				write_cookie("bg");
				document.location.href = 'bg/index.html';
			} else {
				write_cookie("en");
				document.location.href = 'en/index.html';
			}				
		}
	}
	
	function change_language(language) {
		var parentURL = parent.location.href.toString();
		
		if (language == 'bg') {
			parentURL = parentURL.replace(/\/en\//, '/bg/');
			
			// IE crashes when redirection occurs if the URL ends with '#' 
			var parentURLLen = parentURL.length;
			if (parentURL.charAt(parentURLLen - 1) == '#') {
				parentURL = parentURL.slice(0, parentURLLen - 1);
			}
			
			write_cookie(language);
			parent.location.href = parentURL;
		}
		
		if (language == 'en') {
			parentURL = parentURL.replace(/\/bg\//, '/en/');
			
			// IE crashes when redirection occurs if the URL ends with '#'
			var parentURLLen = parentURL.length;
			if (parentURL.charAt(parentURLLen - 1) == '#') {
				parentURL = parentURL.slice(0, parentURLLen - 1);
			}
								
			write_cookie(language);
			parent.location.href = parentURL;
		}		
	}
		
	function write_cookie(language) {
		var cookie_date = new Date (2050, 00, 01);
		document.cookie = "lang=" + language + "; expires=" + cookie_date.toGMTString() + "; path=/;";
	}
	
	function get_cookie(cookie_name)
	{
		var results = document.cookie.match( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
		if ( results )
	    	return ( unescape ( results[2] ) );
	  	else
	    	return null;
	}
	
	function pressBarChooser() {
		
		var lngBar = document.getElementById('pressLangBar');
		
		if (lngBar == null) {
			return;
		}
		
		var lngBarSrc = lngBar.src.toString();	
		
		if (get_cookie("lang")) {
			if (get_cookie("lang") == 'bg') {		
				lngBarSrc = lngBarSrc.replace(/\/en\//, '/bg/');
			} else {
				lngBarSrc = lngBarSrc.replace(/\/bg\//, '/en/');
			}
		}
		
		lngBar.src = lngBarSrc; 		
	}
	
	function pressMenuChooser() {

		var menuIFrame = document.getElementById('menuIFrame');
		
		if (menuIFrame == null) {
			return;
		}
			
		var menuIFrameSrc = "../../../en/menu.html?selSubMenu=pressSubMenu"; //	menuIFrame.src.toString();
		
		if (get_cookie("lang")) {
			if (get_cookie("lang") == 'bg') {		
				menuIFrameSrc = menuIFrameSrc.replace(/\/en\//, '/bg/');
			} else {
				menuIFrameSrc = menuIFrameSrc.replace(/\/bg\//, '/en/');
			}
		}
		
		menuIFrame.src = menuIFrameSrc;
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
