var tour = 1;

function getNavbarValue()
{
	var urlquery = location.href.split("navbar=");
	var navbar = 1;
	if(urlquery[1] && !isNaN(urlquery[1])){
		navbar = urlquery[1];
	}
	return navbar;
}

function tourNext(){
	
	var navbar = parseInt(getNavbarValue());
	if(navbar > 1)
	{
		$('tour-prev').href = '?tour='+(navbar-1);
	}
	if (navbar < 18){
		$('tour-next').href = '?tour='+(navbar++);
	}
    
	$('nextButton').show();

	$('tour'+tour+'-section').removeClassName('selected');
	
    if (tour > 1){
        $('tour' + tour).style.display = 'none';
        $('tour' + tour + '-bg').style.display = 'none';
        tour = tour - 1;
        $('tour' + tour).style.display = '';
        $('tour' + tour + '-bg').style.display = '';
    }
	
	if (tour >= 1){
		$('tour'+tour+'-section').addClassName('selected');
	}
    
    if (tour > 1){
        $('tour-prev').addClassName('active');
    }
    else{
        $('tour-prev').removeClassName('active');
    }

    if ($('tour' + (1 + tour))){
        $('tour-next').addClassName('active');
    }
    else{
        $('tour-next').removeClassName('active');
    }

    $('head-section-1').removeClassName("selected");
    $('head-section-2').removeClassName("selected");
    $('head-section-3').removeClassName("selected");
    $('head-section-4').removeClassName("selected");
    
    switch (tour) {
    	case 1:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Easy FTP");
    			break;
    	case 2:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Single/Bulk Image Upload");
    			break;
    	case 3:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Automatic Image Resizing");
    			break;
    	case 4:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Drag-and-Drop Portfolio Editing");
    			break;
    	case 5:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("High-Quality Images");
    			break;
    	case 6:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Site Design");
    			break;
    	case 7:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Intuitive Navigation");
    			break;
    	case 8:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Website Styling");
    			break;
    	case 9:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Multimedia Presentation");
    			break;
    	case 10:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Music");
    			break;
    	case 11:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Mirror HTML Site");
    			break;
    	case 12:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Automatic Metadata Search");
    			break;
    	case 13:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Search Landing Page");
    			break;
    	case 14:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Google Analytics");
    			break;
    	case 15:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Downloadable PDFs");
    			break;
    	case 16:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("Client Access");
    			break;
    	case 17:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("Shopping Cart");
    			break;
    	case 18:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("");
			    $('nextButton').hide();
    			break;
    			
    }

    return false;

}



function tourPrev(){

	var navbar = parseInt(getNavbarValue());
	if(navbar > 1)
	{
		$('tour-prev').href = '?tour='+(navbar-1);
	}
	if (navbar < 18){
		$('tour-next').href = '?tour='+(navbar+1);
	}
	
	$('nextButton').show();

	$('tour'+tour+'-section').removeClassName('selected');

	
	if ($('tour' + (1 + tour))){
        $('tour' + tour).style.display = 'none';
        $('tour' + tour + '-bg').style.display = 'none';
        tour = tour + 1;
        $('tour' + tour).style.display = '';
        $('tour' + tour + '-bg').style.display = '';
    }

	if (tour <= 18){
		$('tour'+tour+'-section').addClassName('selected');
	}


    if (tour > 1){
        $('tour-prev').addClassName('active');
    }
    else{
        $('tour-prev').removeClassName('active');
    }

    if ($('tour' + (1 + tour))){
        $('tour-next').addClassName('active');
    }

    else{
        $('tour-next').removeClassName('active');
    }
    
    $('head-section-1').removeClassName("selected");
    $('head-section-2').removeClassName("selected");
    $('head-section-3').removeClassName("selected");
    $('head-section-4').removeClassName("selected");
    
    switch (tour) {
    	case 1:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Easy FTP");
    			break;
    	case 2:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Single/Bulk Image Upload");
    			break;
    	case 3:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Automatic Image Resizing");
    			break;
    	case 4:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Drag-and-Drop Portfolio Editing");
    			break;
    	case 5:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("High-Quality Images");
    			break;
    	case 6:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Site Design");
    			break;
    	case 7:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Intuitive Navigation");
    			break;
    	case 8:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Website Styling");
    			break;
    	case 9:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Multimedia Presentation");
    			break;
    	case 10:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Music");
    			break;
    	case 11:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Mirror HTML Site");
    			break;
    	case 12:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Automatic Metadata Search");
    			break;
    	case 13:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Search Landing Page");
    			break;
    	case 14:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Google Analytics");
    			break;
    	case 15:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Downloadable PDFs");
    			break;
    	case 16:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("Client Access");
    			break;
    	case 17:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("Shopping Cart");
    			break;
    	case 18:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("");
			    $('nextButton').hide();
    			break;
    			
    }

    return false;

}

function goTour(step){

	var navbar = parseInt(getNavbarValue());
	if(navbar > 1)
	{
		$('tour-prev').href = '?tour='+(navbar-1);
	}
	if (navbar < 18){
		$('tour-next').href = '?tour='+(navbar+1);
	}
	if(navbar == 1)
	{
		$('tour-prev').href = '?tour=1';
	}
	if (navbar == 18){
		$('tour-next').href = '?tour=18';
	}
	
	$('nextButton').show();

	$('tour'+tour+'-section').removeClassName('selected');

    if ($('tour' + step)){
        $('tour' + tour).style.display = 'none';
        $('tour' + tour + '-bg').style.display = 'none';
        tour = parseFloat(step);
        $('tour' + tour).style.display = '';
        $('tour' + tour + '-bg').style.display = '';
    }

	if (tour <= 18){
		$('tour'+tour+'-section').addClassName('selected');
	}

    if (tour > 1){
        $('tour-prev').addClassName('active');
    }
    else{
        $('tour-prev').removeClassName('active');
    }

    if ($('tour' + (1 + tour))){
        $('tour-next').addClassName('active');
    }

    else{
        $('tour-next').removeClassName('active');
    }
    
    $('head-section-1').removeClassName("selected");
    $('head-section-2').removeClassName("selected");
    $('head-section-3').removeClassName("selected");
    $('head-section-4').removeClassName("selected");
    
    switch (tour) {
    	case 1:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Easy FTP");
    			break;
    	case 2:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Single/Bulk Image Upload");
    			break;
    	case 3:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Automatic Image Resizing");
    			break;
    	case 4:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("Drag-and-Drop Portfolio Editing");
    			break;
    	case 5:
			    $('head-section-1').addClassName("selected");
			    $('hintNext').update("High-Quality Images");
    			break;
    	case 6:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Site Design");
    			break;
    	case 7:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Intuitive Navigation");
    			break;
    	case 8:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Website Styling");
    			break;
    	case 9:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Multimedia Presentation");
    			break;
    	case 10:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Music");
    			break;
    	case 11:
			    $('head-section-2').addClassName("selected");
			    $('hintNext').update("Mirror HTML Site");
    			break;
    	case 12:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Automatic Metadata Search");
    			break;
    	case 13:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Search Landing Page");
    			break;
    	case 14:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Google Analytics");
    			break;
    	case 15:
			    $('head-section-3').addClassName("selected");
			    $('hintNext').update("Downloadable PDFs");
    			break;
    	case 16:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("Client Access");
    			break;
    	case 17:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("Shopping Cart");
    			break;
    	case 18:
			    $('head-section-4').addClassName("selected");
			    $('hintNext').update("");
			    $('nextButton').hide();
    			break;
    			
    }

    return false;

}

/* Pricing list */
function pricing_all(el)
{
    el = Element.extend(el);
    if (el.hasClassName('open'))
    {
        el.removeClassName('open');
        el.update('<span>Expand all</span>');
        
        $$(".pricing-content .left li").each(
            function(s){
                s.removeClassName('open');
            }
        );
    }
    else
    {
        el.addClassName('open');
        el.update('<span>Contract all</span>');
        
        $$(".pricing-content .left li").each(
            function(s)
            {
                s.addClassName('open');
            }
        );
    }
    
    return false;
}

function pricing_switch(el)
{
	if (!el)
	{
		el = this;
	}
	else 
	{
		if (el.element)
		{
			el = el.element();
		}
	}
    
    el = Element.extend(el.parentNode);
    
    if (el.hasClassName('open'))
    {
        el.removeClassName('open');
    }
    else
    {
        el.addClassName('open');
    }
    
    return false;
}

function pricing_init()
{
    $$(".pricing-content .left li>a").each(
        function(s)
        {
            s.onclick = pricing_switch;
        }
    );
}

