/*
	Autor: Grzegorz Jaworek
	E-mail: grzegorz.jaworek@gmail.com
	www: http://gjaworek.pl 
	Tel.: +48 519 133 159
*/

jQuery(document).ready(function(){
	jQuery('.totop').click(function () {
		scroll(0,0);
		return false;
	});
	jQuery('label.hide').each(function () {
		jQuery(this).next().val(jQuery(this).html());
		jQuery(this).next().attr('rel',jQuery(this).html());
		jQuery(this).next().attr('title',jQuery(this).html());
		jQuery(this).hide();
	});
	jQuery('input[type="text"], textarea').focus(function () {
		if (jQuery(this).val()==jQuery(this).attr('rel')) jQuery(this).val('');
		jQuery(this).removeClass('invalid');
		jQuery(this).addClass('active');
	});
	jQuery('input[type="text"], textarea').blur(function () {
		if (jQuery(this).val()=='') jQuery(this).val(jQuery(this).attr('rel'));
		jQuery(this).removeClass('active');
	});
	jQuery('.sidebar-right, .video, .video object').css({'position':'relative','z-index':'1'});
	jQuery('.video object, .video object embed').height(220).width(272);
	jQuery('.video embed').attr('wmode','transparent');
	try {
		jQuery('.video').html(jQuery('.video').html().replace('</param><embed','</param><param name="wmode" value="transparent"></param><embed'));	
	} catch(err) {}
	jQuery('.stbuttontext').parents('p').css({'clear':'both','padding-top':'15px'});
	jQuery('.ngg-galleryoverview a').lightBox();
});


jQuery(window).load(function(){
	jQuery('#featured').cycle({ 
		fx:      'fade', 
		speed:   1100, 
		timeout: 4231
	});
});


function validateForm(current)
{	
	current = jQuery('#'+current+' label');
	validate = true;
	jQuery(current).each(function () {
		if ( (jQuery(this).next().val().indexOf(jQuery(this).html())!=-1) || (jQuery(this).next().val().length<1 ) ) {
			jQuery(this).next().addClass('invalid');
			validate = false;
		} else  if ((jQuery(this).next().attr('name') == 'ne') && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(jQuery(this).next().val())) ) {
			jQuery(this).next().addClass('invalid');
			validate = false;
		} else {
			jQuery(this).next().removeClass('invalid');
		}
	});
    return validate;
}

function resetForm(current)
{	
	current = jQuery('#'+current+' label');
	jQuery(current+' label').each(function () {
		jQuery(this).next().val(jQuery(this).html());
		jQuery(this).next().attr('rel',jQuery(this).html());
		jQuery(this).hide();
	});
    return true;
}