function setNull(){}

$(document).ready(function() { 
	
	$(document).pngFix();
	
	var replaceh2 = function(){
        var gotinside = false
        $('.xyzSlideShowSub').each(function(i){
            gotinside = true;
            if (i < 1){	
            	Cufon.replace('h2');
            }
        });
        if (!gotinside)
            setTimeout(replaceh3, 1000);
    }
    replaceh2();

	
    $("#explain_1").tooltip({
    	tip: '#tooltip_1',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_2").tooltip({
    	tip: '#tooltip_2',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_3").tooltip({
    	tip: '#tooltip_3',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_4").tooltip({
    	tip: '#tooltip_4',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_5").tooltip({
    	tip: '#tooltip_5',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_6").tooltip({
    	tip: '#tooltip_6',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_7").tooltip({
    	tip: '#tooltip_7',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_8").tooltip({
    	tip: '#tooltip_8',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_9").tooltip({
    	tip: '#tooltip_9',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    $("#explain_10").tooltip({
    	tip: '#tooltip_10',
    	effect: 'fade' 
    }).dynamic( { 
        bottom: { 
            direction: 'down', 
            bounce: true 
        } 
    });
    


    $("a[rel]").overlay({ 
        
        effect: 'apple',
         
        onBeforeLoad: function() { 
            // grab wrapper element inside content 
            var wrap = this.getContent().find(".contentWrap"); 
            // load the page specified in the trigger 
            wrap.load(this.getTrigger().attr("href")); 
        } 
    }); 
});


function sendForm(target,page){
	if(page=='contact'){
		
	}
	
}
/*
function analysePerform(){

	// grab wrapper element inside content 
	var wrap = this.getContent().find(".contentWrap"); 
	 
    // load the page specified in the trigger 
    wrap.load(this.getTrigger().attr("href")); 
	$('#PalletAnalyse').html('blah, blah!');
}
*/





function sendContact(from, loader){
$.ajax({
	url: "sendForm.php",
	dataType: "html",
	type: "POST",
	data: $('#contactData').serialize(),
	async: false,
	error: function(){
		$('#' + from).html('Error loading XML document');
	},
	success: function(data){
		$('#' + from).html(data);
	},
	beforeSend: function(){
	     $('#' + loader).show();
	     $('#' + from).hide();
	     
		},
	complete: function(){
	     $('#' + loader).hide();
	     $('#' + from).show();
   }
});
}

function sendCalculation(target, loader){
$.ajax({
	url: "savingsCalculator.php",
	dataType: "html",
	type: "POST",
	data: $('#swapCalculator').serialize(),
	async: false,
	error: function(){
		$('#' + target).html('Error loading XML document');
	},
	success: function(data){
		$('#' + target).html(data);
	},
	beforeSend: function(){
	     $('#' + loader).show();
	     $('#' + target).hide();
	     
		},
	complete: function(){
	     $('#' + loader).hide();
	     $('#' + target).show();
   }
});
}

function closeMessage(target,loader){
	$.ajax({
		url: "contactForm.php",
		dataType: "html",
		type: "POST",
		async: false,
		error: function(){
			$('#' + target).html('Error loading XML document');
		},
		success: function(data){
			$('#' + target).html(data);
		},
		beforeSend: function(){
		     $('#' + loader).show();
		     $('#' + target).hide();
		     
			},
		complete: function(){
		     $('#' + loader).hide();
		     $('#' + target).show();
	   }
	});
}

function validateContact(){
	var required = new Array('fCompany', 'fName', 'fLastName', 'fAddress', 'fCity', 'fCountry', 'fMail', 'fPhone');
	var err = 0;
	for(i=0;i<required.length;i++){
		if($('#' + required[i]).val()=='') err++;
	}
	if(err>0) 
		showError('contact');
	else 
		sendContact('contactForm','contactFormLoader');
};

function showError(where){
	if(where=='contact') {
		$('#contactTip').hide();
		$('#contactError').show();
	}
}

















