
$(document).ready(function() {
	setCurrent($('#home'));
	$('#nav > div').bind('click', function(){
          setCurrent(	$(this));
		 })

     $('#quote').fadeIn('slow');

	setTimeout('swapQuoteTimer()', 400000);
	setTimeout('swapMessage()',5000);
 
});

var msgId=2;
var qId=1;

 

function swapQuoteTimer(){
  
	setTimeout('swapQuoteTimer()', 40000);
}


function swapQuote(){
    	qId++;
	if (qId >5) qId=1;

  	$('#quote').hide();
    	var newPage = "quote"+qId+".html";
  	$('#quote').load(newPage, function(){
		$(this).fadeIn();
							}	);

}

function swapMessage(){
	msgId++;
	if (msgId>5)msgId=1;
   	 if($('#pictext')){
            	$('#pictext').fadeOut("slow",function(){      
                 		if(msgId==1){	
					$('#pictext').html("pennineWays.com <br/> Web Design and Hosting <br/>  - just that little bit different");
                 		 }
				if(msgId==2){	
					$('#pictext').text("Value for money");
                  	}
				if(msgId==3){	
					$('#pictext').text("A Professional Service");
                 		 }
				if(msgId==4){	
					$('#pictext').text("Skilled, friendly staff");
                  	}
  				if(msgId==5){	
					$('#pictext').html("Contact us today, <br> we can help your business<br> to succeed!");
                  	}

			});
			$('#pictext').fadeIn("slow");
    		}
  		setTimeout('swapMessage()',5000);
}







function setCurrent(el){
	$('#nav > div').removeClass('currentsel');

	$('#nav > div').bind('mouseover', function(){
		$(this).removeClass('mousout');
		$(this).addClass('mousov');
	 })

	$('#nav > div').bind('mouseout', function(){
		$(this).removeClass('mousov');
		$(this).addClass('mousout');
	 })

  	el.removeClass('mousov');
  	el.removeClass('mousout');
 	 el.addClass('currentsel');
	  loadPage(el);
 }

function loadPage(el){
  swapQuote();
//$('#col2').html("<div id='loady'>&nbsp;</div>");
 $('#col2').hide();

    var newPage = el.attr('id') +".html";
  	$('#col2').load(newPage, function(){
		$(this).fadeIn();

			if(el.attr("id")=="clients"){
	     			setClientTips();
           			}
	



	}	);

}


function setClientTips(){

/*	$('img[title]').qtip({ style: { tip:'topLeft',  width: 200, padding: 5, background: '#4E0D51', color: 'white', textAlign: 'center', border: { width: 7, radius: 5, color: '#616161' } 
, name: 'dark' } 
                     });
*/

$('#ollie').qtip({ position: { corner: { target: 'rightMiddle', tooltip: 'topLeft' }} ,
style: { tip:'leftTop',   width: 200, padding: 5, background: '#4E0D51', color: 'white', textAlign: 'center', border: { width: 7, radius: 5, color: '#4E0D51' } 
, name: 'dark' } 
                     });

$('#rinn').qtip({ position: { corner: { target: 'rightBottom', tooltip: 'leftMiddle' }} ,
style: { tip:'leftTop',   width: 200, padding: 5, background: '#4E0D51', color: 'white', textAlign: 'center', border: { width: 7, radius: 5, color: '#4E0D51' } 
, name: 'dark' } 
                     });

 

$('#pande').qtip({ position: { corner: { target: 'leftMiddle', tooltip: 'topRight' }} ,
style: { tip:'rightTop',   width: 200, padding: 5, background: '#4E0D51', color: 'white', textAlign: 'center', border: { width: 7, radius: 5, color: '#4E0D51' } 
, name: 'dark' } 
                     });

$('#princess').qtip({ position: { corner: { target: 'leftBottom', tooltip: 'rightMiddle' }} ,
style: { tip:'rightTop',   width: 200, padding: 5, background: '#4E0D51', color: 'white', textAlign: 'center', border: { width: 7, radius: 5, color: '#4E0D51' } 
, name: 'dark' } 
                     });



}



function loadPageById(el){
     $('#col2').hide();

     var newPage = el.id+".html";
  	$('#col2').load(newPage);
    	$('#col2').load(newPage, function(){
		$(this).fadeIn();
							}	);
	
}



function sendMessage(){


  $.get('http://www.pennineways.net/cgi-bin/cgiemail/enquiryform.txt', $('#msgForm').serialize(), function(data) {
           
				$('#messageArea').html('<i>	 Thank you for your enquiry. We will get back to you shortly.</i>'); });
}
