/**
 * @author admin
 */

/* HOMEPAGE NAVIGATION */
function home(argObj)
{
	document.location.href = argObj.href;	
}
function extLink(argObj) {
	window.open(argObj.href,'',''); 
}

/* CLOSE BUTTON */

function closeParent() {

		
		$('#mask',parent.document).hide();
		$('.window',parent.document).hide();
		
		$('#modalWin',parent.document).hide();
		$('#mask', parent.document).hide();
		$('#logo',parent.document).fadeIn(1000);
		//$('iframe',parent.document).attr('src','about:blank');

}
/*
function closeParentCat() {
		$('.navigaton',top.document).css({'z-index':'9999'});
		$('#modalCat1',parent.document).hide();
		$('#mask1', parent.document).hide();
		//$('.windowScroller',parent.document).css({'margin-top':'215'});
	 
		}
*/




/* MODAL BUILDER */
$(function(){
	
	/* level 2 
	 * Close level 2 
	 * */
	$('a[name=modalTop]').click(function(e) {
		// close level 2
		$('#modalCat1',parent.document).hide();
		$('#jqmContentTop').attr('src','');
		$('#mask1', parent.document).hide();		
		// level 1
		$('#modalCat',parent.parent.document).css({'z-index':'9997'});
		// level 0
		$('#navigaton',top.document).css({'z-index':'9999'});
		});
	
	/* horizontal scroll CATEGORIES
	 * level 1
	 */
	$('a[name="modalScroll"]').click(function(e) {
	  
	  // fade out level 0 twitter
      $('#twitter').fadeOut(3000);
		// level 0
		$('#navigaton',top.document).css({'z-index':'9999'});
		// level 1
		$('#modalCat',parent.parent.document).css({'z-index':'9997'});
	
      	  parent.document.getElementById('modalCat').style.height='100%';
	  parent.document.getElementById('modalCat').style.background='none';

		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		// set vars
		var id = 'jqmContentCat';
		var myLink = $(this).attr('href');
		// display level 0 modal container
		$('#modalCat').css({'display':'block'});
		// display level 1 iframe
		$('iframe#jqmContentCat').css({'display':'block'});
		// load level 1 iframe src
		$('iframe#jqmContentCat').attr({'src':myLink});

		//Get the screen height and width
		var maskHeight = $(window).height();
		var maskWidth = $(window).width();
		var catHeight = (maskHeight*0.70)+15;
		//alert(maskHeight +' : '+ catHeight);
		
		$('#mask').css({'background':'transparent','height':maskHeight});
		$('#modalCat').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
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);	
	});


/******************************/
	//main navigation level 0 PAGES
	$('a[name=modal]').click(function(e) {
		// set navigation z-index
		// $('.navigation',top.document).css({'z-index':'9997'});
		// hide level 0 twitter	
      		$('#twitter').fadeOut(3000);
		// make sure to close any open CATEGORY level
		$('#modalCat').hide();
		$('iframe#jqmContent').css({'display':'none'});
		//style level 0 for pages	
		parent.document.getElementById('modalWin').style.height='100%';
		parent.document.getElementById('modalWin').style.background='none';

		//Cancel the link behavior
		e.preventDefault();
		
		//set variables
		var id = 'jqmContent';
		var myLink = $(this).attr('href');
		//show PAGE container
		$('#modalWin').css({'display':'block'});
		// move level 0 container to top of screen so
		$('#windowModal').css({'margin':'0'})
		//show iframe and load src PAGE
		$('iframe#jqmContent').css({'display':'block'});
		$('iframe#jqmContent').attr({'src':myLink});
		//mask settings
		var maskHeight = $(window).height();
		var maskWidth  = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		$('#modalWin').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
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2); 
	
	});
	// LEVEL 1 DETAIL PAGES
	$('a[name=modalSub]').click(function(e) {
		//handle z-index settings
		$('.navigation',top.document).css({'z-index':'9998'});
		$('#modalCat',parent.document).css({'z-index':'9998'});
		
		parent.document.getElementById('modalCat').style.height='100%';
		parent.document.getElementById('modalCat').style.background='none';

		//Cancel the link behavior
		e.preventDefault();
		//set vars
		var id = 'jqmContentTop';
		var myLink = $(this).attr('href');
		//display level 1 container
		$('#modalCat1').css({'display':'block'});
		$('iframe#jqmContentTop').css({'display':'block'});
		$('iframe#jqmContentTop').attr({'src':myLink});
		//Get the screen height and width
		var maskHeight = $(window).height();
		var maskWidth = $(window).width();
		//Set heigth and width to mask to fill up the whole screen
		$('#mask1').css({'width':maskWidth,'height':maskHeight});
		$('#modalCat1').css({'width':maskWidth,'height':maskHeight});
		//transition effect		
		$('#mask1').fadeIn(1000);	
		$('#mask1').fadeTo("slow",0.8);	
		//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);
	});
});

/* PROMO MODALITY */
function promo() {


		// var myClass = argObj.clss;
		  // fade out level 0 twitter
	      $('#twitter').fadeOut(3000);
			// level 0
			$('#navigaton',top.document).css({'z-index':'9999'});
			// level 1
			$('#modalCat',parent.parent.document).css({'z-index':'9997'});
		
	      	  parent.document.getElementById('modalCat').style.height='100%';
		  parent.document.getElementById('modalCat').style.background='none';

			//Cancel the link behavior
			// e.preventDefault();
			
			//Get the A tag
			// set vars
			var id = 'jqmContentCat';
//			var myLink = $(this).attr('href');
			var myLink = "http://www.hellskitchen.nl/?cat=10";
			// display level 0 modal container
			$('#modalCat').css({'display':'block'});
			// display level 1 iframe
			$('iframe#jqmContentCat').css({'display':'block'});
			// load level 1 iframe src
			$('iframe#jqmContentCat').attr({'src':myLink});

			//Get the screen height and width
			var maskHeight = $(window).height();
			var maskWidth = $(window).width();
			var catHeight = (maskHeight*0.70)+15;
			//alert(maskHeight +' : '+ catHeight);
			
			$('#mask').css({'background':'transparent','height':maskHeight});
			$('#modalCat').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
			$(id).css('top',  winH/2-$(id).height()/2);
			$(id).css('left', winW/2-$(id).width()/2);	

		
		
		
		
		
		
		
		
		
		
		/**********************************/
		/* var id = 'modalWin';
		
		$('#modalWin').css({'display':'block'});
		$('iframe').css({'display':'block'});
		$('iframe').attr({'src':myLink});

		//Get the screen height and width
		var maskHeight = $(window).height();
		var maskWidth = $(window).width();

		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		$('#modalWin').css({'width':maskWidth,'height':maskHeight});		

		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("fast",0.9);	


		//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());
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 

		//if close button is clicked
	$('.window .jqmClose').click(function (e) 
	{
		//Cancel the link behavior
		e.preventDefault();
		
		// $('iframe').attr('src','blank.html');
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () 
	{
		$(this).hide();
		$('.window').hide();
	});	

		//if close button is clicked
	function jqmCloseMe()
	{
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	}	
	*/
}
