function IEVersion(){
	var _n=navigator,_w=window,_d=document;
	var version="NA";
	var na=_n.userAgent;
	var ieDocMode="NA";
	var ie8BrowserMode="NA";
	// Look for msie and make sure its not opera in disguise
	if(/msie/i.test(na) && (!_w.opera)){
		// also check for spoofers by checking known IE objects
		if(_w.attachEvent && _w.ActiveXObject){		
			// Get version displayed in UA although if its IE 8 running in 7 or compat mode it will appear as 7
			version = (na.match( /.+ie\s([\d.]+)/i ) || [])[1];
			// Its IE 8 pretending to be IE 7 or in compat mode		
			if(parseInt(version)==7){				
				// documentMode is only supported in IE 8 so we know if its here its really IE 8
				if(_d.documentMode){
					version = 8; //reset? change if you need to
					// IE in Compat mode will mention Trident in the useragent
					if(/trident\/\d/i.test(na)){
						ie8BrowserMode = "Compat Mode";
					// if it doesn't then its running in IE 7 mode
					}else{
						ie8BrowserMode = "IE 7 Mode";
					}
				}
			}else if(parseInt(version)==8){
				// IE 8 will always have documentMode available
				if(_d.documentMode){ ie8BrowserMode = "IE 8 Mode";}
			}
			// If we are in IE 8 (any mode) or previous versions of IE we check for the documentMode or compatMode for pre 8 versions			
			ieDocMode = (_d.documentMode) ? _d.documentMode : (_d.compatMode && _d.compatMode=="CSS1Compat") ? 7 : 5;//default to quirks mode IE5				   			
		}
	}
				 
	return {
		"UserAgent" : na,
		"Version" : version,
		"BrowserMode" : ie8BrowserMode,
		"DocMode": ieDocMode
	}
}

jQuery(document).ready ( init );

function init() {
	
	$("a[rel='new_window']").click ( function () { window.open (this.href); return false; });
	
	if( jQuery.support.boxModel )
	{
		$( ".news_box" ).accordion({
			header: '.news_item_head'
		});
	}
	/*
	if( $( "#newest_product_img img" ).length > 0 ) {
		if( IEVersion().Version != 8 )
		{
			$( "#newest_product_img img" ).rotate( -7 );
		}
	}*/
	
	$(".news_box").css({
		height: $(".news_box").height(),
		overflow: "hidden"
	});
	
	$("#content_left img").parent().css({
		borderBottom: 'none'
	});
	
	ajaxContact();
}

function ajaxContact()
{
	$("#contactform form").submit(function () {	
		$.post(
			baseUri + "/js/contact-form-ajax.php?send=Odeslat",
			$("#contactform form").serialize(),
			function(html){
				$("#contactform").fadeTo( "fast", 0.3, function(){
					$(this).html(html).fadeTo("fast",1);
				});
				
    			ajaxContact();
  			});

		return false;
    });
}
