/ ----------------------------------------------------------------------------------------------------------//
// HTML5 ELEMENTS - IE //
// ----------------------------------------------------------------------------------------------------------//
document.createElement('header');
document.createElement('nav');
document.createElement('hgroup');
document.createElement('section');
document.createElement('figure');
document.createElement('figcaption');
document.createElement('footer');
document.createElement('aside');
document.createElement('article');
document.createElement('time');
//-----//

$(document).ready
(
	function()
	{
		$('a[href$=.jpg] > img, a[href$=.png] > img, a[href$=.gif] > img').each(
											function()	{$(this).closest(':not(a,img)').css({position:'relative'});$(this).parent().append('<span class="zoom">zoom</span>');});
											

		
		$('body.page-id-28 header h2, body.page-id-30 header h2').after('<ul id="currency"><li code="eur" currency="&euro;" class="selected">Euro &euro;</li><li code="gbp" currency="&pound;">Pounds &pound;</li><li code="usd" currency="&#36;">Dollars &#36;</li></ul>');
		$('body.page-id-28 ul#currency li, body.page-id-30 ul#currency li').click(changeCurrency);
		$('body.page-id-28 dl.options dt, body.page-id-30 dl.options dt').click(showDetails);
		
		tour();
//		setInterval("slideSwitch()", 6000);
		
		
		$('a.video').colorbox({iframe:true, innerWidth:640, innerHeight:390});
		$('#demo-video a.video').colorbox({iframe:true, innerWidth:720, innerHeight:405});
		
		
		$('body:not(.page-id-9) a').click
			(
				function()
				{
					if($(this).attr('href').indexOf('#')>=0)
					{
						var id=$(this).attr('href').split('#')[1];
						$('html,body').animate({scrollTop: $('#'+id).offset().top},'slow');
					}
				}
			)
			
		new steps('wpcf7-form','step','form-steps','subm');
	}
	
);




function tour()
{
	if(!$('body.page-id-9'))		{	return false;	}
	
	$(window).bind('scroll',tourScrolling);
	$('nav.secondary ul li a').click(
										function()
										{
											$('nav.secondary ul li').removeClass('current');
											$(this).parent().addClass('current');
											
											if($(this).attr('href').indexOf('#')>=0)
											{
												var id=$(this).attr('href').split('#')[1];
												$('html,body').animate({scrollTop: $('#'+id).offset().top-100},'slow');
											}
										});

}



function tourScrolling()
{			
	if($(this).scrollTop()>120)	{	$('body.page-id-9 nav.secondary').addClass('secondary-sticky');	}
	else	{	$('body.page-id-9 nav.secondary').removeClass('secondary-sticky');	}
	
	
	$('nav.secondary ul li a[href*=#]').each(
								function()
								{
									var id=$(this).attr('href').split('#')[1];
									var pozitieTopID=$('#'+id).offset().top-100;

									var pozitieMAXTopID=$('#'+id).offset().top+$('#'+id).height();
									if($(this).offset().top>=pozitieTopID && $(this).offset().top<=pozitieMAXTopID)
									{
										$('nav.secondary ul li').removeClass('current');
										$(this).parent().addClass('current');
									}
								});
}


function changeCurrency()
{
	var currency=$(this).attr('currency');
	currencyCode=$(this).attr('code');

    $('span.currency').text(currency);
	$('body.page-id-28 ul#currency li,body.page-id-30 ul#currency li').removeClass('selected');
	$(this).toggleClass('selected');
	

	$('body.page-id-28 [class*= '+currencyCode+'-], body.page-id-30 [class*= '+currencyCode+'-]').each
	(
		function()
		{
			var classes=($(this).attr('class')).split(' ');
			for(a=0;a<classes.length;a++)
			{
				if(classes[a].indexOf(currencyCode+'-')>=0)
				{
					var price=classes[a].split('-')[1];
					$(this).text(price);
				}
			}
			
		}
	);
}


function showDetails()
{
	$(this).toggleClass('deschis').next().next().slideToggle(300);	
}



function steps(idElement,idPrefix,controller,submitButton)
{
	var steps=this;
	
	this.idElement=idElement;
	this.idPrefix=idPrefix;
	this.controller=controller;
	this.submitButton=submitButton;
	
	this.currentStep=1;
	
	init();
	
	function init()
	{
		$('.'+steps.idElement+' [id|="'+steps.idPrefix+'"]:not(#'+steps.idPrefix+'-'+steps.currentStep+'),#'+steps.submitButton).hide();
		$('#'+steps.controller+' a,p.step a').click(showStep);
		
		$('#'+steps.submitButton).click(showAll);
		
	}
	
	function hideAll()
	{
		$('.'+steps.idElement+' [id|="'+steps.idPrefix+'"],#'+steps.submitButton).hide();
	}		

	function showAll()
	{
		$('.'+steps.idElement+' [id|="'+steps.idPrefix+'"]').show();
		$('html,body').animate({scrollTop: $('#'+steps.submitButton).offset().top},'slow');
	}		
	
	function showStep()
	{
		var stepNo=$(this).attr('href').split('#')[1].split('-')[1];
		$(this).addClass('curent');
		steps.currentStep=stepNo;
		hideAll();
		if(stepNo==3)	{	$('#'+steps.submitButton).show();	}
		$('.'+steps.idElement+' #'+steps.idPrefix+'-'+steps.currentStep).show();
		return false;
	}
}
