$(document).ready(function(){
/*-----------------------------------------------------------------------------
resume stuff - andrewpougher.co.uk (c) watermarked code DO NOT REMOVE / COPY
--------------------------------------------------------------------------*/
var mystuff = "resume.htm"
$.ajax({ 
	
	url: mystuff, 
	dataType: "html", 
	type: "GET", 
	error: function(){ 
	$('#resume').html('Content is being updated right now, please try later.'); 
	}, 
	success: function(data){
	$('#resume').html(data);
	} 
	}); 

/*-----------------
Brand Fun
------------------*/	

	$("#brand").hover(function() {

   $(this).css("background-image","url(../img/brand_over.png)");
			}, function() {
    		$(this).css("background-image","url(../img/brand-new-andrew-pougher.png)");
	});




$(".barContent").each(function(i){

$(this).find("p:first").css({'padding-top': '18px','text-align':'justify'})

});
/*-----------------
bio res switch
------------------*/


	$("a.switch_thumb").toggle(function(){
	  $(this).addClass("swap"); 
	  $('#resume').fadeOut("fast", function() {
	  	$(this).fadeIn("fast").load("bio.htm"); 
		 });
	  }, function () {
      $(this).removeClass("swap");
	  $('#resume').fadeOut("fast", function() {
	  	$(this).fadeIn("fast").load("resume.htm");
		});
return false;
	}); 


/*-----------------
example stuff
------------------*/

$('div.clickBar:eq(1)').click(function() {

clearTimeout($.innerfade.startTimeout);
clearTimeout($.innerfade.continueTimeout);

$('#apfolio').innerfade({
 	  animationtype: 'slide', 
	speed: 1000,
	timeout: 5000,
	type: 'sequence',
	containerheight: '315px'
	});
});
$('div.clickBar:eq(0)').click(function() {

clearTimeout($.innerfade.startTimeout);
clearTimeout($.innerfade.continueTimeout);

$('#homeadvert').innerfade({
	speed: 1000,
	timeout: 5000,
	type: 'sequence',
	containerheight: '180px'
	});
});



/*-----------------
hire stuff
------------------*/

	$('.hire .left, .hire input, .hire textarea, .hire select').focus(function(){
	$(this).parents('.row').addClass("over");
	}).blur(function(){
	$(this).parents('.row').removeClass("over");
	});
/*-----------------
checboxes disabled

$(".content input:checkbox,.content input:radio,.content input[type*=che],.content input[type=checkbox]").each(function() {
	$(this).next("label").addClass("chbxs");
	});
$(".content input:checkbox, .content input:radio,.content input[type*=che],.content input[type=checkbox]").change(function(){
		if($(this).is(":checked")){
			$(this).next("label").addClass("LabelSelected");
		}else{
			$(this).next("label").removeClass("LabelSelected");
		}
	});
------------------*/
	$('.content input[type=checkbox],.content input:checkbox').prettyCheckboxes();
/*-----------------
Tweeeeet             username: ["apougher","e3msi"],
------------------*/

$(".tweet").tweet({
            username: ["apougher"],
            join_text: "auto",
            avatar_size: 32,
            count: 30,
            auto_join_text_default: " - ", 
            auto_join_text_ed: " - ", //"we"
            auto_join_text_ing: " - ", // "we were"
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
            loading_text: "loading tweets..."
        });

/*-----------------
Menu
------------------*/


	$('div.clickBar').click(function() {
	$('div.barContent').slideUp('normal');	
	$(this).next("div").slideDown('normal', 'swing');
	});
	$("div.barContent").hide();
	$("div.barContent:eq(1)").slideDown(200).slideUp(2200);
	


/*-----------------
core subject Fade
------------------*/

$('#foot img').each(function() {
            $(this).hover(function() {
                $(this).animate({ opacity: 0.3 }, 500);
            },
           function() {
               $(this).stop().animate({ opacity: 1.0 }, 500);
           });
        });




/*-----------------
colour cores by page no
------------------*/
var qlevel  = (window.location.search.substr(8).toLowerCase());
//alert(qlevel)


$("div.clickBar").click(function(event) {
	$(this).css({opacity: 1.0});
	$(".clickBar").not(this).css({opacity: 0.4});
	$(this).animate({ backgroundColor: "#7c123d" }, 300)
	.animate({ backgroundColor: "#cd4079" }, 300);


		var hue = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
				$('#foot').animate( { backgroundColor: hue }, 2300);


});

/*-----------------
forms
------------------*/
$(".hirebtn").click(function(event) {
//form values
	var getin = {}
	$('.hireform input[type="text"],.hireform textarea,.hireform input[type=checkbox]:checked, .hireform input[type="password"], .hireform select').each( function(n,element){  getin += (  "&" + element.name + "=" + element.value ); } );
	
var rgdata = ("reg=1&" + getin)
	//alert(rgdata)

var fail = 1
$(".hireform input[type=text],.hireform textarea").each(function(){
	var text = $(this).attr("value");
	if (text == ""){
	fail = 1
	$(this).css("border", "2px solid #cc1100");
	}else{
	$(this).css("border", "1px solid #b08aa8");
	fail = 0
	} 
});

if (fail == 0){
		$.ajax({ 
		url: "aj_hireus.aspx", 
		data: rgdata + "&rd=" + Math.random() * 3,
		dataType: "html", 
		type: "GET", 
		error: function(){ 
		alert('Posting Failed, Please try later.'); 
		}, 
		success: function(data){
			if (data == ":)" || "Thanks for your inquiry " + $(".fnom").val()){
			alert("Thanks, we will be in touch.")			
			}else{
			alert("Its all gone horribly wrong. Try Later.")
			}
			}
	
			});
			}
return false;
});

$("#btnSubmit").click(function(event) {
//form values
	var getin = {}
	$('.contact input[type="text"],.contact textarea,.hireform input[type=checkbox]:checked, .contact input[type="password"], .contact select').each( function(n,element){  
	getin += (  "&" + element.name + "=" + element.value ); 
	});
	var rgdata = ("reg=1&" + getin)
	//alert(rgdata)

	var fail = 1
	$(".contact input[type=text],.contact textarea").each(function(){
	var text = $(this).attr("value");
	if (text == ""){
	fail = 1
	$(this).css("border", "2px solid #cc1100");
	}else{
	$(this).css("border", "1px solid #b08aa8");
	fail = 0
	} 
	});

	if (fail == 0){
	$.ajax({ 
		url: "aj_contact.aspx", 
		data: rgdata + "&rd=" + Math.random() * 3,
		dataType: "html", 
		type: "GET", 
		error: function(){ 
		alert('Posting Failed, Please try later.'); 
		}, 
		success: function(data){
		if (data == ":)" || "Thanks for your inquiry " + $(".fname").val()){
		alert("Thanks, we will get in touch with you very soon.")			
		}else{
		alert("Its all gone horribly wrong. Try Later.")
		}
		}
	
		});
		}

	


	return false;
	});


/* =============================
read more
================================*/

 var slicePoint = 100;
  var widow = 4;
   $("#cell_8 .more").each(function() {
    var allText = $(this).html();
	$(allText).css({"text-align": "justify"});
    var startText = allText.slice(0,slicePoint).replace(/\w+$/,'');
    var endText = allText.slice(startText.length);
    if ( endText.replace(/\s+$/,'').split(' ').length> widow ) {
      $(this).html([
        startText,
        "<a href='#' class='read-more'> ~ read more...</a>",
        "<span class='details'>",
          endText,
        "</span>"
        ].join('')
      );
    }
  });
 
  // *** hide details until read-more link is clicked;
  // then hide link and show details.
  $('span.details').hide();
  $('a.read-more').click(function() {
    $(this).hide()
    .next('span.details').fadeIn()
    return false;
  });





/*-----------------
Folio
------------------*/

  $("div.folio1").carousel({
		loop: true,
		autoSlide: true,
		slideEasing: "easeInOutElastic", // swing, 	effect: "fade",
		animSpeed: 2000,
                direction: "vertical",
		autoSlideInterval: 3000,
		 pagination: true
            });

$("div.folio2").carousel( { 
	//dispItems: 2,
        autoSlide: true, 
	slideEasing: "easeInOutElastic",
	loop: true,
	direction: "vertical",
	animSpeed: 2000,
        autoSlideInterval: 3000,
	pagination: true,
complete: function() { // the callback
            alert('done');
        }
});

 $("div.folio3").carousel( {
        direction: "vertical",
	slideEasing: "easeInOutElastic",
        loop: true,
		animSpeed: 2000,
        pagination: true, // setting this to true adds the pagination 1, 2, 3 etc.
        autoSlide: true, // automatic rotation between the banners
        autoSlideInterval: 3000, // how long in miliseconds till next rotation
        delayAutoSlide: 3000 // how long to pause on each banner
     } );


/*-----------------
Footer stuff
------------------*/
	$('#foot a').attr("target","_blank");
	$('#foot img').attr("align","absmiddle");

});

