﻿$(document).ready(function() {	

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		


		
		
		//Get the A tag
		var id = $(this).attr('href');

		
	    var vacancy_id = $(this).attr('vacancy_id');
		$("#vacancy_id").val(vacancy_id);
        
		var description = $(this).attr('description');
		$(".login-content-news").html(description);
		
		var jobdescription = $(this).attr('jobdescription');
		$(".content-job").html(jobdescription);
		
		
		var address = $(this).attr('address');
		$(".content-showroom").html(address);

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		$('#mask').css({'opacity':0.9});

		//transition effect		
		$('#mask').fadeIn("slow");
		//$('#mask').fadeTo("slow");	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn("slow"); 
	
	});
	
	//if close button is clicked
	$('#popupApplyClose').click(function (e) {
		//Cancel the link behavior
		
		e.preventDefault();
		
		$('#mask').hide();
		$('#popupApply').hide();
	});
	
	
	$('.popupClose').click(function (e) {
		//Cancel the link behavior
		
		e.preventDefault();
		
		
		$('#mask').hide();

		var popupid=$(this).parent().attr("id");

		 $('#'+popupid).hide();
		
      // $('#popuplogin').hide();
	});	
	
	
	$('#popupNewsClose').click(function (e) {
		//Cancel the link behavior
		
		e.preventDefault();
		
		$('#mask').hide();
		$('#popupNews').hide();
	});

	//Closing the login and
	$('#popupsignup').click(function (e) {
		//Cancel the link behavior
		$('#popuplogin').hide();
		//e.preventDefault();
		
		//$('#mask').hide();
		//$('#popupNews').hide();
	});	
	
	$('#popupShowroomClose').click(function (e) {
		//Cancel the link behavior
		
		e.preventDefault();
		
		$('#mask').hide();
		$('#popupShowroom').hide();
	});	
	
	
	$('#popupVacancyClose').click(function (e) {
		//Cancel the link behavior
		
		e.preventDefault();
		
		$('#mask').hide();
		$('#popupVacancy').hide();
	});	
	
	
	
	
	$('#popuploginClose').click(function (e) {
		//Cancel the link behavior
		
		e.preventDefault();
		
		$('#mask').hide();
		
		$('#popuplogin').hide();
	});
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('#popuplogin').hide();
		$('#popupsignup').hide();
		$('#popupApply').hide();
		$('#popupNews').hide();
		$('#popupShowroom').hide();
		$('#popupVacancy').hide();
	});			
	
});
