jQuery.noConflict();

var stretchers;
var toggles;
var myAccordion;

jQuery(document).ready(function(){
	// external links hack
	jQuery('a.external').click( function(){	window.open(this.href,'_blank'); return false;});
	
	// links outline hack 
	jQuery('a, label').bind('focus',function(){if(this.blur)this.blur();});

	stretchers = document.getElementsByClassName('stretcher');
	toggles = document.getElementsByClassName('display');
	myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, height: true, width: true, duration: 400, transition: fx.sineInOut});
		
	Element.cleanWhitespace('content');
	init('#');
	
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("pojGoogleMap"));
		map.setCenter(new GLatLng(49.56860408728187, 22.16792106628418), 14);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		var text = '<div class="pojGoogleInfo"><h4>WOJTECH - Wojciech Paradiuk</h4><p>ul. Krakowska 2,<br />38-500 SANOK</p></div>';
		var localisation = new GLatLng(49.56860408728187, 22.16792106628418);
		map.openInfoWindowHtml(localisation,text);
      }
      
    if(jQuery.browser.opera) {
    	jQuery('#oPojPomiary div.pojContent').css('overflow-y', 'scroll');
    }

});

function init(sId){
	//hash functions
	var found = false;
	toggles.each(function(h3, i){
		var div = Element.find(h3, 'nextSibling');
			var sPoj = (sId ? sId : window.location.href);
			if (sPoj.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
	if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}