function doLogin()
{
  
   	
   var password = $('.main_pass').val();
   var username = $('.main_user').val();	
   var error = 0;
   if( password=='')
   {
	  error =1
   }
   
   if( username=='')
   {
	  error =1
   }
   
    if( username=='Enter username...')
   {
	  error =1
   }
   
   if( password=='Enter password...')
   {
	  error =1
   }
   
   if(error==1){ alert('Please fill in both fields with the corresponding login data.'); }else{ $('form#login').submit(); }
   
}

function doLoginMain()
{
  
   	
   var password_main = $('.pass').val();
   var username_main = $('.user').val();	
   var error = 0;
   if( password_main=='')
   {
	  error =1
   }
   
   if( username_main=='')
   {
	  error =1
   }
 
   if(error==1){ alert('Please fill in both fields with the corresponding login data.'); }else{ $('form.mainLogin').submit(); }
   
}

function doBorder(field)
{
   	$(field).css('border','3px solid #FF0000')
}

function undoBorder(field)
{
   	$(field).css('border','1px solid #333')
}

function doRegister()
{
    var new_username = $('#new_username').val();
	var new_password = $('#new_password').val();
	var new_password_repeat = $('#new_password_repeat').val();
	var new_email = $('#new_email').val();
	var correct_code = $('#correct_code').val();
	var new_code = $('#new_code').val();
	var pass_len = 4;
    var error =0;
	var message = '<div class="error_message">All fields are required.</div>';
	
	if(new_username ==''){
	  doBorder('#new_username');	
	}else{
	  undoBorder('#new_username');
	  error = 0;	
	}
	
	if(new_password ==''){
	  doBorder('#new_password');	
	}else{
	  undoBorder('#new_password');
	  error = 0;	
	}
	
	if(new_password_repeat ==''){
	  doBorder('#new_password_repeat');	
	}else{
	  undoBorder('#new_password_repeat');
	  error = 0;	
	}
	
}


	     
		 function check_this(game_id){
			 //alert(game_id);
			 $('div.overlayG').fadeIn(700);
			 $('div#checkGame').fadeIn(700);
		     
			 $('input.checkBtn').click(function(){
			     //proverka dali se odbrani parametrite
				 
				 var grafix = $('select.grafix').val();
				 var memory = $('select.memory').val();
				 var cpu =    $('select.cpu').val();
				 var postto = 'http://gameinfocenter.com/check_game/';
				 //alert(grafix+'-'+memory+'-'+cpu+'-'+game_id);
				 if(grafix==0 || memory==0){
					alert('Please select graphic card and ram.'); 
				 }else{
					$('div.showLoader').html('<img src="http://gameinfocenter.com/site_images/green_loader.gif" style="margin-left:45%; margin-top:40px"/>');
					$('form.formToHide').hide(); 
					///imame i graficka i ram i imame id od igrata praj proverka so ajax
					$.ajax({
						type:"POST",
						  async: true,
						  data:'grafix='+grafix+'&cpu='+cpu+'&memory='+memory+'&game_id='+game_id,
						  url: postto,
							  success: function(check){
								//alert(check);
								if(check==1)
								{
								   $('div.showLoader').html('');
								   $('div.yesYouCan').fadeIn(200); 
								   $('div.yesYouCan').html('You can play this game with this configuration.<br/><a href="#" style="padding-top:20px; display:block; font-size:13px;" onClick="check_again(); return false">Check again using different configuration.</a>');
								}
								else if(check==2)
								{
								  $('div.showLoader').html('');	
								  $('div.noYouCant').fadeIn(1000); 
								  $('div.noYouCant').html('Internal error. Please try again later.');	
								}
								else
								{
								  $('div.showLoader').html('');	
								  $('div.noYouCant').fadeIn(1000); 
								  $('div.noYouCant').html('No, you can\'t play this game with this configuration.<br/><a href="#" style="padding-top:20px; display:block; font-size:13px;" onClick="check_again(); return false">Check again using different configuration.</a>');	
							
								}
							  } 
					});
				 }
				 return false;
			 })
		 }
		 
		 
		 
		 function close_over() {
			 $('div.overlayG').fadeOut(700);
			 $('div#checkGame').fadeOut(700); 
			 $('select#grafix').val('0');
			 $('select#memory').val('0');
			 $('select#cpu').val('0');
			 $('div.yesYouCan').hide(); 
			 $('div.noYouCant').hide();
			 $('form#mainFilterForm').show();
			  $('div.showLoader').html('');	 
			  
			 
		 }
		 $(document).ready(function(){
		 $('div.overlayG').click(function(){
			 $('div.overlayG').fadeOut(700);
			 $('div#checkGame').fadeOut(700);
			 $('select#grafix').val('0');
			 $('select#memory').val('0');
			  $('select#cpu').val('0');
			 $('div.yesYouCan').hide(); 
			 $('div.noYouCant').hide();
			 $('form.formToHide').show(); 
			  $('div.showLoader').html('');	
		  })
		 })
		 function check_again (){
			 
			 $('select#grafix').val('0');
			 $('select#memory').val('0');
			 $('div.yesYouCan').hide(); 
			  $('select#cpu').val('0');
			 $('div.noYouCant').hide();
			 $('form.formToHide').show(); 
			  $('div.showLoader').html('');	
		 }
		 
