function loadBlock( block_url, response_container ) {

	block_url = block_url.replace( window.ROOT_URL, '' ) ;

	$.ajax( {
		type: 'GET',
		url: block_url,
		success: function( html ) {

			$( '#' + response_container ).html( html );
		}
	});
};
function changeFont( action ) {

	if ( action == 1 ) {
		if ( size < 3 ) {
			size++;
		}
	} else {
		if ( size > 1 ) {
			size--;
		}
	}
	$( '.font img' ).attr( 'class', 'curp' );
	if ( size == 3 ) {
		$('#f1').attr( 'class', '' );
	} 
	if ( size == 1 ) {
		$( '#f2' ).attr( 'class', '' );
	}
	$('.content').attr( 'class', 'content' );
	$('.content').addClass( 'size_'+size );
	setDataToCookie( 'sessionId', sessionId );
	setDataToCookie( 'fontSize', size );
};
function openGas( id ) {
	
	var width=650;
	var height=450;
	var rnd = (Math.round((Math.random()*999)+1));
	var top=Math.round((screen.height-height)/2);
	var left=Math.round((screen.width-width)/2);
	
		this.open( window.ROOT_URL+'?act=desc&item_id='+ id, "w"+rnd, "top="+top+",left="+left+",width="+width+",height="+height+",buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no");
};
function overLithuaniaMap( id, act ) {
	
	if ( act = 1 ) {
		
		$( '#' + id ).show();
	} else {
		
		$( '#' + id ).hide();
	}
};
function submitRegForm() {
	
	var city = $( '#reg_form_city' ).attr( 'value' );
	var program = $( '#reg_form_program' ).attr( 'value' );
	var name = $( '#reg_form_name' ).attr( 'value' );
	var company = $( '#reg_form_company' ).attr( 'value' );
	var phone = $( '#reg_form_phone' ).attr( 'value' );
	var email = $( '#reg_form_email' ).attr( 'value' );
	
	var errors = false;
	
	if ( name.length == 0 ) {
		
		errors = true;
		$( '#reg_tr_name' ).addClass( 'error' );
		
	} else {
		
		$( '#reg_tr_name' ).removeClass( 'error' );
	}
	
	if ( phone.length == 0 ) {
		
		errors = true;
		$( '#reg_tr_phone' ).addClass( 'error' );
		
	} else {
		
		var reg = /^([0-9\-\s\+])+$/;
		
		if ( reg.test( phone ) === false ) {
			
			errors = true;
			$( '#reg_tr_phone' ).addClass( 'error' );
		} else {
			
			$( '#reg_tr_phone' ).removeClass( 'error' );
		}
	}
	
	if ( email.length == 0 ) {
		
		errors = true;
		$( '#reg_tr_email' ).addClass( 'error' );
		
	} else {
		
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   		
   		if ( reg.test( email ) === false ) {
			
			errors = true;
			$( '#reg_tr_email' ).addClass( 'error' );
			
   		} else {
			
			$( '#reg_tr_email' ).removeClass( 'error' );
		}
	}
	
	if ( company.length == 0 ) {
		
		errors = true;
		$( '#reg_tr_company' ).addClass( 'error' );
		
	} else {
		
		$( '#reg_tr_company' ).removeClass( 'error' );
	}
	
	if ( errors === true ) {
		
		return false;
	} else {
		
		$.getJSON(
			
			window.ROOT_URL + 'index.php?act=send_reg_form',
			{ 'city' : city, 'program' : program, 'name' : name, 'email' : email, 'company' : company, 'phone' : phone }, 
			function( data ) {
			
			if ( data.success === false ) {
				
				return false;
			} else {
				
				$( '#reg_form' ).slideUp( 500, function a() {
					
					$( '#reg_form_success' ).slideDown( 800 );
				});
			}
		});
		
		return true;
	}
};

function toggleContainer( id ) {
	
	$( id ).slideToggle();
	$( id ).parent().toggleClass('opened_branch');
}
