sections = new Array(['faq.php','kontakt.php','sitemap.php','soutez.php','specialni-akce.php'],['index.php'],['produkty.php','clin-na-okna.php','clin-na-okna-a-ramy.php','clin-universal.php','clin-cistici-ubrousky-na-bryle.php','clin-apple.php','clin-citrus.php','clin-floral.php','nahradni-baleni.php','squeezer.php','clin-apple-ramy.php','clin-universal-ramy.php'],['proc-specialni-prostredky.php'],['historie-henkel.php','vypis-produktu-henkel.php'])

sectionID = 0;

//

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    } else {
        return document[movieName]
    }
}

function loadPage(link, target, isflash){

	sections.each(function(s, i){

		if(s.length>0){
			s.each(function(ss){
				if(link.indexOf(ss) != -1){
					sectionID = i;
				}
			});			
		}
	});

	found = 'clin.cz/';
	if (link.indexOf(found) != -1) {
		link = link.substr(link.indexOf(found) + found.length);
	}
	
	pageTracker._trackPageview("/" + link);
//	console.log(link);
	
	if (link.substr(0, 4) != 'http') {
		link = 'http://www.clin.cz/' + link;
	}

	new Ajax.Updater(target, 'pages.php?url='+link, { method: 'get', evalScripts: true ,  onSuccess: function(transport){doMenu(link);}});
//	alert(thisMovie('headerswf').updateFlashNavi);

	if(isflash == 0){
		thisMovie('headerswf').updateFlashNavi(sectionID);
	}
}

function doMenu(link) {
	new Ajax.Updater('subMenu', 'pages_menu.php?url='+link, { method: 'get', evalScripts: true , onSuccess: 
	function(transport){setTimeout(doLinks, 10)}});
}

function doLinks(){
	$$('#subMenu a, #content a, #rightside a, #menu a').each(function(node){
		if(node.target!='_blank'){
			node.onclick = function(){
				loadPage(node.href, 'content', 0);
				return false;
			}
		}
	});
	if (typeof hover!= "undefined") hover();
}

function highlightFlashNavi(id){

}


cAPI = function() {

	this.init = function(){
		API.browser = new API.getBrowserInfo();
		API.page = new API.getPageInfo();
	}

};

var API = new cAPI();

cAPI.prototype.getPageInfo = function() {
		this.x1 = 0;this.y1 = 0;
		this.x2 = (API.browser.ie7)?document.documentElement.clientWidth:(API.browser.ns6) ? innerWidth : document.body.clientWidth;
		this.y2 = (API.browser.ie7)?document.documentElement.clientHeight:(API.browser.ns6) ? innerHeight : document.body.clientHeight;
		this.x50 = Math.round(this.x2 / 2);
		this.y50 = Math.round(this.y2 / 2);		
};


cAPI.prototype.getBrowserInfo = function() {
		this.ver = navigator.appVersion;
		this.agent = navigator.userAgent;
		this.dom = document.getElementById ? 1 : 0;
		this.opera5 = this.agent.indexOf("Opera 5") > -1;
		this.opera = this.agent.indexOf("Opera") > -1;
		this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom && !this.opera5) ? 1 : 0;
		this.ie6 = (this.ver.indexOf("MSIE 6") > -1 && this.dom && !this.opera5) ? 1 : 0;
		this.ie7 = (this.ver.indexOf("MSIE 7") > -1 && this.dom && !this.opera5) ? 1 : 0;
		this.ie4 = (document.all && !this.dom && !this.opera5) ? 1 : 0;
		this.ie = this.ie5 || this.ie6 || this.ie7;
		this.mac = this.agent.indexOf("Mac") > -1;
		this.ns6 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
		this.ns4 = (document.layers && !this.dom) ? 1 : 0;
		this.bw = (this.ie7 || this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
		return this;
};
	
	
	function findPageHeight(){
var winWidth, winHeight, d=document;
if (typeof window.innerWidth!='undefined') {
winWidth = window.innerWidth;
winHeight = window.innerHeight;
} else if ( d.documentElement
&& typeof d.documentElement.clientWidth!='undefined'
&& d.documentElement.clientWidth!=0 ) {
winWidth = d.documentElement.clientWidth;
winHeight = d.documentElement.clientHeight;
} else if ( d.body
&& typeof d.body.clientWidth!='undefined') {
winWidth = d.body.clientWidth;
winHeight = d.body.clientHeight;
}
return winHeight;
}

Event.observe(window, 'load', function() {
  doLinks();
	API.init();
});
