/* HORIZONTAL SCROLLER */
/*
$(document).ready(function() {
	//Get our elements for faster access and set overlay width
	var div = $('div.sc_menu'),
		ul = $('ul.sc_menu'),
		ulPadding = 100;
	
	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars	
	div.css({overflow: 'hidden'});
	
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
});
*/

/* CHECK NEWSLETTER */
/*
$(function() {
 if(the_cookie === undefined)
 {
 	var the_cookie = 'active';
	$('#newsletter').css('dislay','none');
}
 if($.cookie('the_cookie') == 'newsletter') {$('#newsletter').css('dislay','none');}
});
*/
/* 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();
		$('iframe',parent.document).attr('src','about:blank');
    $('#twitter',parent.document).css({'display':'block'}).fadeIn(3000);
    $('#newsletter',parent.document).css({'display':'block'}).fadeIn(5000);
}


/* 1ST LEVEL MODAL WINDOWS */


function loadPage(argObj) {
$('#twitter').fadeOut(3000);
$('#newsletter').fadeOut(3000);
 	for (var i in argObj) {
		// alert(argObj[i]);
		// navigation click value to var
		var myLink = argObj.href;
		// var myClass = argObj.clss;
		// filter: category
		if(argObj.clss == 'category')
		{
		// div to var
		var id2 = 'modalCat';
		// if div modalWin is present, remove display
		if($('#modalWin').css({'display':'block'}))
		{
		$('#modalWin').css({'display':'none'});
		$('iframe#jqmContent').css({'display':'none'});
		}

		$('iframe#jqmContentCat').attr('src','blank.html'); // set iframe content to blank page
		$('#modalCat').css({'display':'block'}); // show modal div
		$("iframe#jqmContentCat").load(function (){ // load archive page
		
		});
		$('iframe#jqmContentCat').attr({'src':myLink});
		$('iframe#jqmContentCat').css({'display':'block'});	

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		var catHeight = (maskHeight*0.70)+15;
		//alert(maskHeight +' : '+ catHeight);
		
		$('#mask').css({'background':'transparent','height':catHeight});
		$('#modalCat').css({'width':maskWidth,'height':catHeight});
		}

		else if(argObj.clss == 'page')
		{
		var id = 'modalWin';
		if($('#modalCat').css({'display':'block'}))
		{
		$('#modalCat').css({'display':'none'});
		$('iframe#jqmContentCat').css({'display':'none'});
		// $('#mask').fadeOut(500);
		}
		// $('iframe').attr('src','blank.html');
		$('iframe').attr({'src':myLink});
		$('#modalWin').css({'display':'block'});
		$("iframe#jqmContent").load(function (){
		$('iframe').css({'display':'block'});
		});

		//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({'background':'#010101','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(1000); 

		//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();
	}		
	

	}

}

/* 2ND LEVEL MODAL WINDOWS */
$(function(){

	$('a[name="modal"]').click(function(e) {

			// parent.jqmC.document.mask.style.height = '100%';
			parent.document.getElementById('modalCat').style.height='100%';
			parent.document.getElementById('modalCat').style.background='none';
			// parent.document.getElementById('jqmContent').style.height='100%';

		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		// var id = $(this).attr('href');
		var id = 'jqmContent';
		var myLink = $(this).attr('href');
		$('#modalCat1').css({'display':'block'});
		$('iframe').css({'display':'block'});
		$('iframe').attr({'src':myLink});
	
		var maskHeight = $(document).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);
	
		//transition effect
		$(id).fadeIn(2000); 

	//if close button is clicked
	$('.window1 .jqmClose1').click(function (e) {
		parent.document.getElementById('modalCat').style.height='500px';
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask1').hide();
		$('.window1').hide();
	});		
	
	//if mask is clicked
	$('#mask1').click(function () {
		$(this).hide();
		$('.window1').hide();
	});
	
	});


$('a[name="singlePage"]').click(function(e) {
	$('#mask1',parent.document).hide();
	// $('#mask1',parent.document).css('display','none');
	$('.window',parent.document).hide();
	$('.modalCat1',parent.document).hide();
	$('iframe',parent.document).attr('src','blank.html');
	$('#modalCat',parent.parent.document).css('height','500px');
});


$('a[name="themePage"]').click(function(e) {
	$('#mask',parent.document).hide();
	$('.window',parent.document).hide();
	$('iframe',parent.document).attr('src','about:blank');
	$('#twitter',parent.document).css({'display':'block'}).fadeIn(3000);
	$('#newsletter',parent.document).css({'display':'block'}).fadeIn(5000);
});



});




/* PROMO MODALITY */

function promo() {
	$('#twitter').fadeOut(3000);
	$('#newsletter').fadeOut(3000);
		var myLink = "?cat=9";

		var id2 = 'modalCat';
		// if div modalWin is present, remove display
		/* if($('#modalWin').css({'display':'block'}))
		{
		$('#modalWin').css({'display':'none'});
		$('iframe#jqmContent').css({'display':'none'});
		}*/

		$('iframe#jqmContentCat').attr('src','blank.html'); // set iframe content to blank page
		$('#modalCat').css({'display':'block'}); // show modal div
		$("iframe#jqmContentCat").load(function (){ // load archive page
		
		});
		$('iframe#jqmContentCat').attr({'src':myLink});
		$('iframe#jqmContentCat').css({'display':'block'});	

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		var catHeight = (maskHeight*0.70)+15;
		//alert(maskHeight +' : '+ catHeight);
		
		$('#mask').css({'background':'transparent','height':catHeight});
		$('#modalCat').css({'width':maskWidth,'height':catHeight});
		//}

		
		
		
		
	/*	
		// var myClass = argObj.clss;
		var id = 'modalWin';
		
		$('#modalWin').css({'display':'block'});
		$('iframe').css({'display':'block'});
		$('iframe').attr({'src':myLink});

		//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});
		$('#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
		$(id2).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();
	}		



}

/* MAILINGS */
$(function(){

	$('#mailInvitation').bind('click', function() {
	this.style.display = 'none';
	$('#mailForm').css('display','block').fadeIn(1000);
	});
	$("input").focus(function () {
		 $(this).select();
    });
    
});

        // wait for the DOM to be loaded 
$(document).ready(function() { 
// bind 'myForm' and provide a simple callback function 
  $('#ajaxsubmit').ajaxForm(function() { 
	$("#messages").html("<p style='color: #ffffff; font-size: 9px; padding: 45px 0 0 0; text-align: center;'>Thanks for joining the Duivel family!</p>");
	$("#ajaxsubmit").remove();
	$("#newsletter").fadeOut(5000);
  }); 
  $('#ajaxsubmitHome').ajaxForm(function() {
	$("#messages").html("<p style='color: #ffffff; font-size: 9px; padding: 45px 0 0 0; text-align: center;'>Thanks for joining the Duivel family!</p>");
	$("#ajaxsubmit").remove();
	$("#newsletter").fadeOut(5000);
  	$.cookie('the_cookie', 'newsletter');
  	//return false;
//  	alert($.cookie('the_cookie'));
  });
}); 