Cufon.replace('h1', { 
	fontFamily : 'Helvetica Neue LT Pro'
});

Cufon.replace('h2, h3, #menu-left a.c-top', { });

Cufon.replace('#menu-top ul li a, #menu-bottom ul li a', {
	hover		: true
	
});

/************************************************************* */

//_initAjaxRequest();

$(document).ready(_initPage);

function _initPage()
{
	// centrowanie obrazow w pionie wewnatrze kontenera
	$('.vAlign').vAlign();
	// opisu pol w formularzach
	$('.clearField').clearField();
	// obrazy uruchamiane w lightboxie
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	// linki obslugiwane za pomoca XMLHTTPRequest
	//$("a[rel^='ajaxRequest']").sevEnAjaxRequest({
	//	reInitCallback	: _reinitPage
	//});

	$('.toolTip').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " -=- ",
		fade: 250
	});

	$('form.clearForm').submit(function(){
		$(this).clearFormArtSeven();
	});
	
	// ******************************
	
	_initMenuLeft();
	_initFbWidget();
	_initTopFlash();
	
	_initFancyCheckRadio();
}

function _reinitPage()
{
	$('.vAlign').vAlign();
	$('.clearField').clearField();
	$("a[rel^='prettyPhoto']").prettyPhoto();

	$("a[rel^='ajaxRequest']").sevEnAjaxRequest({
		reInitCallback	: _reinitPage
	});

	$('.toolTip').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " -=- ",
		fade: 250
	});

	//curvyCorners(settings, obj);
}

/************************************************************* */

function _initFancyCheckRadio()
{
	$('body').addClass('has-js');
	
	$('.fancy-label-check, .fancy-label-radio').click(function()
	{
		setupLabel();
	});
	
	setupLabel(); 
}

function setupLabel() 
{
	if ($('.fancy-label-check input').length) {
		$('.fancy-label-check').each(function(){ 
			$(this).removeClass('c_on');
		});
		$('.fancy-label-check input:checked').each(function(){ 
			$(this).parent('label').addClass('c_on');
		});                
	};
	if ($('.fancy-label-radio input').length) {
		$('.fancy-label-radio').each(function(){ 
			$(this).removeClass('r_on');
		});
		$('.fancy-label-radio input:checked').each(function(){ 
			$(this).parent('label').addClass('r_on');
		});
	};
};

/************************************************************* */

var mins
var secs;

function cd(minut) 
{
 	mins = 1 * m(minut); // change minutes here
 	secs = 0 + s(":01"); // change seconds here (always add an additional second to your total)
 	redo();
}

function m(obj) 
{
	for(var i = 0; i < obj.length; i++) 
	{
	  	if(obj.substring(i, i + 1) == ":")
	  	break;
	 }
	 return(obj.substring(0, i));
}

function s(obj) 
{
	for(var i = 0; i < obj.length; i++) 
	{
		if(obj.substring(i, i + 1) == ":") break;
	}
	
	return(obj.substring(i + 1, obj.length));
}

function dis(mins,secs)
{
	var disp;
	if(mins <= 9) disp = " 0";
	 else disp = " ";
	 	
	 disp += mins + ":";
	 if(secs <= 9) disp += "0" + secs;
	 else disp += secs;
	 
	 return(disp);
}

function redo() 
{
	secs--;
	if(secs == -1)
	{
		secs = 59;
		mins--;
	}
	
	document.formcd.disp.value = dis(mins,secs); // setup additional displays here.
	
	if((mins == 0) && (secs == 0)) 
	{
		window.alert("Czas się skończył. Wciśnij OK aby przesłać test."); // change timeout message as required
	  	document.test.submit();
	 }
	 
	 else 
	 {
		cd = setTimeout("redo()",1000);
	 }
}

function initTimer(minut) 
{
	cd(minut);
}


/************************************************************* */

function _initMenuLeft()
{
	$('#menu-left .cat-sub').click(function(e) {
		e.preventDefault();
		
		$('#cat-' + $(this).attr('rel')).toggle();
	});
}

function _initFbWidget()
{
	$(".w2bslikebox").hover(function() {$(this).stop().animate({right: "0"}, "medium");}, function() {$(this).stop().animate({right: "-250"}, "medium");}, 500);
}

function _initTopFlash()
{
	var flashvars = {};
	var params = {};
	var attributes = {};

	params.quality = "high";
	params.wmode = "transparent";
	params.swliveconnect = "true";
	params.allowscriptaccess = "sameDomain";

	swfobject.embedSWF(BASE_URL + "_images/site/flash-columbus.swf", "swf-holder", "720", "250", "7.0.0", false, flashvars, params, attributes);
}

function _gmap_init(__container, __lat, __lng)
{
	// http://maps.google.pl/maps/ms?msid=208607300289757192064.0004b66a48e86cf7c8a4a&msa=0&ll=50.666318,17.906047&spn=0.002615,0.006217

	var myLatlng = new google.maps.LatLng(__lat, __lng);

	var myOptions = {
	  zoom: 16,
	  center: myLatlng,
	  noClear: true,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	}

	var map = new google.maps.Map(document.getElementById(__container), myOptions);

	var image = new google.maps.MarkerImage('/_images/site/gmaps/logo.png',
		new google.maps.Size(128, 89),
		new google.maps.Point(0,0),
		new google.maps.Point(36, 41));

	var shadow = new google.maps.MarkerImage('/_images/site/gmaps/logo_cien.png',
      // The shadow image is larger in the horizontal dimension
       //while the position and offset are the same as for the main image.
      new google.maps.Size(128, 89),
      new google.maps.Point(0,0),
      new google.maps.Point(34, 10));

	var shape = {
		  coord: [1, 1, 1, 31, 71, 31, 71 , 1],
		  type: 'poly'
	  };

	var marker = new google.maps.Marker({
		position: myLatlng,
		map: map,
		shadow: shadow,
        icon: image,
        shape: shape,
		title: 'Carlos'
	});
}

function _verifyDate(dd, mm, yyyy) 
{
	//  amerykański format zapisu mm/dd/yyyy
	var data_am  = mm + '/' + dd + '/' + yyyy;
	var date_obj = new Date(data_am);
	
    with( date_obj )
      return (getDate() == dd && getMonth() == (mm-1) && getFullYear() == yyyy);
}

/************************************************************* */

function pokazPozycje(obiektId)		{$("#" + obiektId).slideToggle("fast");}

/************************************************************* */

function _initAjaxRequest()
{
	// zastapienie funkcji w rsh
	window.dhtmlHistory.create( {
		debugMode : false,
		toJSON:		function(o) {return $.toJSON(o);},
		fromJSON:	function(s) {return $.parseJSON(s);}
	});

	window.onload = function() {
		dhtmlHistory.initialize();
		dhtmlHistory.addListener($().sevEnAjaxRequest.handleAjaxRequestHistory);
	};
}
