/**
 * @author Administrator
 */

function validateInt(id)
{
	value = parseInt($(id).value);
	
	if(value >= 0)
	{
		$(id).value = value;
	}
	else
	{
		$(id).value = 0;
	}
}
/*
function displayLang(lang_id, link_id)
{
	$$('.lang').each(function(elmt) { elmt.hide() });
	
	$('lang_' + lang_id).show();
	
	$$('.a_lang').each(function(elmt) { elmt.className = 'a_lang' });

	$(link_id).className = 'a_lang active';
	

}
*/

$(document).ready(function(){
	


if($(window).height() > $('html').height())
{
  var height = $(window).height();
}
else
{
  var height = $('html').height();
}


$("#modal").css({'height':height + 'px'})
$("#modal").css({'width':$(window).width() -20 + 'px'});

$("#alwahy_modal_loading").css({'top':'350px'});
$("#alwahy_modal_loading").css({'left': ($(window).width() - 100) / 2 + 'px'});
  
$("#alwahy_modal_loading").hide();


  

$("#modal_close").click(function(){
  $("#alwahy_modal_loading").hide();
  
  $("#modal_inner").hide();
  $("#modal_inner div").html('');     
  $("#modal").fadeOut();
  $('html').css({'overflow':'auto'});
    
});


$(".open_modal").click(function(){

  $("#alwahy_modal_loading").show();
  
 // $('html').css({'overflow':'hidden'});
  

  $("#modal_inner").css({'left':$(window).width()/2 - 350  + 'px', 'top': '300px'});

  
  $("#modal").show();
  
  
  
  var rel  = $(this).attr('rel');
  var href = $(this).attr('href');
  if (href && href != '#' && !rel) {  

      
  $.ajax({
  url : href,
  dataType : 'html',
  type: 'get',

  success: function (html) {
    $("#alwahy_modal_loading").hide();
    $("#modal_inner div").html(html);
    $("#modal_inner").fadeIn();
  },
  error: function (err) {
    //$("#alwahy_modal_loading").hide();
    $("#modal_inner div").html("Sorry, Error!<p>Please contact us to report this error!</p>");
    $("#modal_inner").fadeIn();
  }
  
  });
  
  } else {
  
	
	  $("#alwahy_modal_loading").hide();
    $("#modal_inner div").html($("#"+rel).html());
    $("#modal_inner").fadeIn();
  
	    $(window).scrollTop(200);
  }
  return false;

});


	
	$(".a_thumbs").click(function(){
		
  $.each($('.a_thumbs'), function(i, item)
  {
    $('#' + item.id).removeClass('selected');
  });
		
	$('#' + this.id).addClass('selected');
			
	$('#big_photo').attr('src', $('#' + this.id + ' > img').attr('src').replace('/thumbs','')  );
	
    
		
		
		
		return false;
	})
	
})



function closeModal()
{
  $("#alwahy_modal_loading").hide();
  $("#modal_inner").hide();
  $("#modal_inner div").html('');     
  $("#modal").fadeOut();  
  
   $('html').css({'overflow':'auto'});
}


function openModal(rel)
{
	
    $("#modal_inner").css({'left':$(window).width()/2 - 350  + 'px', 'top': '300px'});

    $("#modal").show();
		
    $("#modal_inner div").html($("#"+rel).html());
    $("#modal_inner").fadeIn();
		
    $(window).scrollTop(200);

		 

}


