$(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');
		//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});
		
		//transition effect		
		$('#mask').fadeIn(1000);
		
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();

		//Set the popup window to center
//		$('#mask').scroll();
		window.scrollBy(0,-600);

		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		//$(this).hide();
		//$('.window').hide();
	});	
	
	
	$('.acc_trigger').click(function(){
	if( $(this).next().is(':hidden') ) { 
		$('.acc_trigger').removeClass('active').next().slideUp();
		$(this).toggleClass('active').next().slideDown(); 
	}
	else if( $(this).next().is(':visible') ) { 
		$(this).toggleClass('active').next().slideUp();
	}
	
	return false; 
});

$('.acc_box').hide(); 
$('.acc_menu:first').addClass('active').next().show();
$('.acc_menu').click(function(){
	if( $(this).next().is(':hidden') ) { 
		$('.acc_menu').removeClass('active').next().slideUp();
		$(this).toggleClass('active').next().slideDown(); 
	}
	
	else if( $(this).next().is(':visible') ) { 
		$(this).toggleClass('active').next().slideUp();

	}
	
	
	return false; 
});

$('.acc_box1').hide(); 
$('.acc_menu1:first').addClass('active').next().show();
$('.acc_menu1').click(function(){
	if( $(this).next().is(':hidden') ) { 
		$('.acc_menu1').removeClass('active').next().slideUp();
		$(this).toggleClass('active').next().slideDown(); 
	}
	
	else if( $(this).next().is(':visible') ) { 
		$(this).toggleClass('active').next().slideUp();
	}
	
	return false; 
});
	

$('#view_all_countries').click(function(){
									
	if( $('#second_panel').is(':hidden') ) { 
		$(this).hide();
		$('#second_panel').slideDown(); 
		$('html, body').animate({
		    scrollTop: 220,
		    scrollLeft: 0
		}, 1000);
	}
	
	return false; 
});

$('#browse').click(function(){
							if($('#portfolio').is(':visible')){
								$('html, body').animate({
							    scrollTop: 450,
							    scrollLeft: 0
								}, 1000);								
								}
							}
				   );
$('#why').click(function(){
							if($('#portfolio').is(':visible')){
								$('html, body').animate({
							    scrollTop: 450,
							    scrollLeft: 0
								}, 1000);								
								}
							}
				   );
$('#bvisa').click(function(){
							if($('#portfolio').is(':visible')){
								$('html, body').animate({
							    scrollTop: 450,
							    scrollLeft: 0
								}, 1000);								
								}
							}
				   );



	
});

