function validEmail(email) {
			
	zleZnaki = "/:,;"
	
	if (email == "") return false
	
	for (i=0; i<zleZnaki.length; i++) {
		zlyZnak = zleZnaki.charAt(i)
		if (email.indexOf(zlyZnak,0) != -1) return false
	}
	
	malpaPoz = email.indexOf("@",0)
	if (malpaPoz == -1 || malpaPoz == 0) return false
	
	if (email.indexOf("@",malpaPoz+1) != -1) return false
	
	kropkaPoz = email.indexOf(".",malpaPoz)
	if (kropkaPoz == -1 || kropkaPoz == malpaPoz+1) return false
	
	if (kropkaPoz+3 > email.length) return false
	
	return true
	
}



/**
 *	source: http://techpatterns.com/downloads/javascript_cookies.php
 *
 *	EXAMPLE:
 *	setCookie( 'mycookie', 'visited 9 times', 30, '/', '', '' )
 *	Don't forget to put in empty quotes for the unused parameters or you'll get an error when you run the code. This makes the cookie named 'mycookie', with the value of 'visited 9 times', and with a life of 30 days, and the cookie is set to your root folder. 
 *
 */

function setCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	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" : "" );
}


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;
	}
}


function topPlayer(preview_url, video_url, total_time, width, height)
{
	document.getElementById('topPlayer').style.display = 'block'
	
	if (!width) width = 625
	if (!height) height = 351	
	
	var so = new SWFObject('/swf/nFilm_player.swf', 'topFilmPlayer', width, height, '9.0.115', '#121212')
	so.useExpressInstall('/js/swfobject/expressinstall.swf')
	so.addParam('menu', 'false')
	so.addParam('allowScriptAccess', 'always')
	so.addParam('allowFullScreen', 'true')
	
	so.addVariable('preview_url', preview_url)
	so.addVariable('video_url', video_url)
	so.addVariable('total_time', total_time)
	
	so.addParam('wmode', '')
	
	so.write('topfplayer')
}

function closeTopPlayer()
{
	document.getElementById('topPlayer').style.display = 'none';
}

function getScrollPosition() {
	  var scrOfX = 0, scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
	    scrOfY = window.pageYOffset;
	    scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	    scrOfY = document.body.scrollTop;
	    scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	    scrOfY = document.documentElement.scrollTop;
	    scrOfX = document.documentElement.scrollLeft;
	  }
	  return [ scrOfX, scrOfY ];
	}

function storeScrollPosition(e) {
	var id = $(this).attr('id');
	var pos = getScrollPosition();
	var cookieOptions = {path: '/'};
	$.cookie(id, pos[0]+'x'+pos[1], cookieOptions);
	return true;
}

function popitup(link, name) {
	newwindow=window.open(link.attr('href'),name,'height=300,width=600');
	if (window.focus) {newwindow.focus();}
	return false;
}

function sharePopup(e) {
	e.preventDefault();
	e.stopPropagation();
	popitup($(this), 'FacebookShare');
	return false;
}

function trackEvent(category, action, label, value) {
	if (typeof pageTracker != 'undefined') {
		if (value) {
			pageTracker._trackEvent(category, action, label, value);
		} else {
			pageTracker._trackEvent(category, action, label);
		}
	}
	
	return true;	
}

$(document).ready(function() {
	$('#topPlayer .back').click(closeTopPlayer);
	
	$('*[id^=rec]').click(storeScrollPosition);
	$('.share a').click(sharePopup);
});

