detectBrowserVersion();

var maskInt=/^[1-9]+[\d]*$/;

if(!jQuery.browser.safari) {
	jQuery.jStore.ready(function(engine){ 
	    jQuery.jStore.flashReady(function(){
	          engine.ready(function(){ 
	          		
	 			 	$(".aGlos").css('visibility','visible');
	 			 	
					$(".aGlos").fancybox({
						'transitionIn'	:	'none',
						'transitionOut'	:	'none',
						'speedIn'		:	600, 
						'speedOut'		:	200, 
						'overlayShow'	:	true,
						'overlayOpacity' : 0.8,
						'overlayColor'	: '#000',
						'autoScale'	 : false,
						'height' : 350,
						'width' : 500
				 	});
				 	
	        })  
	    })   
	});  
}
else {
	alert('Aby zagłosować skorzystaj z przeglądarek Internet Explorer lub Firefox.');
}

$(function() {
 	 	
	$(".fancybox").fancybox({
		'transitionIn'	:	'none',
		'transitionOut'	:	'none',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity' : 0.8,
		'overlayColor'	: '#000',
		'autoScale'	 : true
 	});
 	
	//set fancybox dodaj
	$(".aDodaj").fancybox({
		'transitionIn'	:	'none',
		'transitionOut'	:	'none',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity' : 0.8,
		'overlayColor'	: '#000',
		'autoScale'	 : false,
		'height' : 550
 	});

	$(".aPolecam").fancybox({
		'transitionIn'	:	'none',
		'transitionOut'	:	'none',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity' : 0.8,
		'overlayColor'	: '#000',
		'autoScale'	 : false,
		'height' : 350
 	});
 	
	$("#aUsun").fancybox({
		'transitionIn'	:	'none',
		'transitionOut'	:	'none',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity' : 0.8,
		'overlayColor'	: '#000',
		'autoScale'	 : false,
		'height' : 320
 	});	
 	
	jQuery.extend(jQuery.jStore.defaults, {  
         project: 'demo-guide',  
         engine: 'flash',  
         flash: 'http://www.twojepudelko.pl/public/scripts/jStore/jStore.Flash.html',
         autoload: true  
    })
    
    jQuery.jStore.load();
    
});

function Blank(href)
{
	window.open(href,'_blank');
	return false;
}

function AjaxReplaceContent(id,url)
{ 
   $.ajax({  
        type: "GET",  
		url: url,  
		beforeSend: function() {
			 $('#'+id).html('<div id="loaderAjax"><img src="public/images/loadingAnimation.gif"/></div>');
		},
		success: function(data) { 
			 $('#'+id).html(data);
		},
		error: function() {  
			 alert('Error');
		 }
	   });
}

function clearAndSendForm(ele) 
{
    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
    ele.submit();
}

function parseId(mixedId,key)
{
    var arrId = mixedId.split('_');
    if(arrId.length<(key+1)) {
    	return 0;
    }
    return parseInt(arrId[key],10);
}

function FormatCurr(val)
{
	return val.replace('.',',');
}

function RoundTo(num,dec) 
{
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function sortNumberASC(a,b)
{
	return a - b;
}

function sortNumberDESC(a,b)
{
	return b - a;
}

function skreska(uid,data)
{
	if (jQuery.jStore.isReady==true)
	{
		jQuery.jStore.CurrentEngine.set(uid,data);
	}
}

function gkropka(uid)
{
	if (jQuery.jStore.isReady==true)
	{
		return jQuery.jStore.CurrentEngine.get(uid);
	} 
}

function detectBrowserVersion(){
var userAgent = navigator.userAgent.toLowerCase();
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
var version = 0;

// Is this a version of IE?
if($.browser.msie){
userAgent = $.browser.version;
userAgent = userAgent.substring(0,userAgent.indexOf('.'));	
version = userAgent;
}

// Is this a version of Chrome?
if($.browser.chrome){
userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
userAgent = userAgent.substring(0,userAgent.indexOf('.'));	
version = userAgent;
// If it is chrome then jQuery thinks it's safari so we have to tell it it isn't
$.browser.safari = false;
}

// Is this a version of Safari?
if($.browser.safari){
userAgent = userAgent.substring(userAgent.indexOf('safari/') +7);	
userAgent = userAgent.substring(0,userAgent.indexOf('.'));
version = userAgent;	
}

// Is this a version of Mozilla?
if($.browser.mozilla){
//Is it Firefox?
if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1){
userAgent = userAgent.substring(userAgent.indexOf('firefox/') +8);
userAgent = userAgent.substring(0,userAgent.indexOf('.'));
version = userAgent;
}
// If not then it must be another Mozilla
else{
}
}

// Is this a version of Opera?
if($.browser.opera){
userAgent = userAgent.substring(userAgent.indexOf('version/') +8);
userAgent = userAgent.substring(0,userAgent.indexOf('.'));
version = userAgent;
}
return version;
}
