$(window).load(function() {
	setTimeout(function(){
		$('#slider').nivoSlider({
			effect:'fade',
            animSpeed:1000,
			pauseTime:6500,
			pauseOnHover:false,
			directionNav:false, //Next & Prev
			controlNav:false,
			controlNavThumbs:false
		});
	}, 2000);
});

jQuery(document).ready(function($) {
        $('a[rel*=facebox]').facebox({
        loading_image : '../img/loading.gif',
        close_image   : '../img/closelabel.gif'
    });
});

function parseXml(xml)
{
    if (jQuery.browser.msie)
    {
	    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	    xmlDoc.loadXML(xml);
	    xml = xmlDoc;
    }
    return xml;
}

function confirmInformation()
{
    name        = $('#name').val();
    country     = $('#country').val();
    phone       = $('#phone').val();
    email       = $('#email').val();
    comments    = $('#comments').val();
    
    if (!name || !email || !comments)
    {
        $('#error').fadeIn();
    }
    else
    {
        sendEmail();        
    }
}

function sendEmail()
{
    name        = $('#name').val();
    country     = $('#country').val();
    phone       = $('#phone').val();
    email       = $('#email').val();
    comments    = $('#comments').val();
    
    $.ajax({
	type: "POST",
	url: "/ajax/send-email.php",
	data:   { 
	            name:name, 
	            country:    country,
	            phone:      phone,
	            email:      email,
	            comments:   comments
	        },
	success:
      	function(xml)
      	{
      	    xml = parseXml(xml);
          	if (1 == xml)
          	{
          	     $('#contact-us-form').html('<div id="confirm">We received your message. Thank You!</h1>');
          	     claenContactForm();
//                jQuery(document).trigger('close.facebox');
          	}
      	}
    });       
}

function cleanContactForm()
{
    name        = $('#name').val('');
    country     = $('#country').val('');
    phone       = $('#phone').val('');
    email       = $('#email').val('');
    comments    = $('#comments').val('');
}

function showContactSpecialOffers()
{
    $('#contact-special-offers').fadeIn();
}

function confirmInformationOffer(){
    sendEmailOffer();
}

function sendEmailOffer(){
    name    = $('#name-special').val();
    email   = $('#email-special').val();
    notes   = $('#notes-special').val();

    $.ajax({
	type: "POST",
	url: "/ajax/send-email-offer.php",
	data:   { 
	            name:       name, 
	            email:      email,
	            notes:      notes
	        },
	success:
      	function(xml)
      	{
      	    xml = parseXml(xml);
          	if (1 == xml)
          	{
                $('#contact-special-offers').html('');
                $('#contact-special-offers').html('<div id="special-offer-message">' +
                        'Your message was sent successfully. ' +
                        '</div>');
                $('#special-offer-message').fadeIn();
//          	     claenContactForm();
//                jQuery(document).trigger('close.facebox');
          	}
      	}
    });     
}

function changePicture(id)
{
    $('#main-img').fadeOut('slow', function(){
        
    $('#main-img').attr('src', 'img-up/cover/'+id);
    });
    
    $('#main-img').fadeIn();
}

function load(site)
{
    $.ajax({
	type: "POST",
	url: site,
	data:   { 
	        },
	success:
      	function(xml)
      	{
      	    xml = parseXml(xml);
            $('#listing-box').fadeOut('slow', function(){
        
//    $('#main-img').attr('src', 'special-offers/images/alux_img_' + id + '.jpg');
                $('#listing-box').html(xml);
                $('#listing-box').fadeIn();
            });
      	   
      	}
    });
}

