// JavaScript Document
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){ return "error_email" }
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return "error_email" }
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return "error_email" }
	if (str.indexOf(at,(lat+1))!=-1){ return "error_email" }
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return "error_email" }
	if (str.indexOf(dot,(lat+2))==-1){ return "error_email" }
	if (str.indexOf(" ")!=-1){ return "error_email" }
	return ""					
}

function getCookie ( cookie_name ) {
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

$(document).ready( function () {
	var idBox = "#boxconcursuri";
	var afis = 0;
	
	// Verificare numar afisari sau deja inregistrare in newsletter
	var cnt = getCookie('noDropBoxCon');
	
	/*
	 * MANAGEMENTUL COOKIURILOR SE FACE SERVER SIDE
	if ( cnt == null ) {
		var cookie_date = new Date ( 2016, 01, 15 );
		document.cookie = "noDropBoxCon=1; expires="+ cookie_date.toGMTString()+"; domain=hit.lh;";
		afis = 1;
	} else {
		afis = 0;
	}
	*/

	if ($(idBox)) {
		var winH = $(window).height();
		var winW = $(window).width();
		var boxH = $(idBox).height();
		var boxW = $(idBox).width();
		var newY = boxH + ( winH/2 - boxH/2) ;

		// Pregatire box
		$(idBox).show();
		$(idBox).css('left', winW/2 - boxW/2);
		
		// onClose
		$(".close_conc").click( function () {
			$(idBox).animate({"top": "-="+newY+"px"}, 300);
		});

		// onOpen
		var options = {};
		$(idBox).animate({"top": "+="+newY+"px"}, 400);
		$(idBox).effect('bounce',options,300);
	}
});
