// JavaScript callbacks
// jFlow Call
$jq(document).ready(function () {
    $("#myController").jFlow({
        slides: "#mySlides",
        controller: ".jFlowControl",
        // must be class, use . sign
        slideWrapper: "#jFlowSlide",
        // must be id, use # sign
        selectedWrapper: "jFlowSelected",
        // just pure text, no sign
        width: "1000px",
        height: "210px",
        duration: 500,
        prev: ".jFlowPrev",
        // must be class, use . sign
        next: ".jFlowNext", // must be class, use . sign
		auto: true	
    });
});





$(document).ready(function () {
    //Caption Sliding 
    $('.subBlockHolder.caption').hover(function () {
        $(".cover", this).stop().animate({
            top: '10px'
        }, {
            queue: false,
            duration: 160
        });
    }, function () {
        $(".cover", this).stop().animate({
            top: '286px'
        }, {
            queue: false,
            duration: 160
        });
    });
});

// form inputs
$(document).ready(function () {
    $('#cname').autofill({
        value: 'Name:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#cemail').autofill({
        value: 'Email:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#ctname').autofill({
        value: 'Name:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#ctemail').autofill({
        value: 'Email:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#cttel').autofill({
        value: 'Telephone:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#comments').autofill({
        value: 'Comments:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });

    $('#yourname').autofill({
        value: 'Name:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#youremail').autofill({
        value: 'Email:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#yourtelephone').autofill({
        value: 'Telephone:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#size').autofill({
        value: 'Size:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
    $('#yourcomments').autofill({
        value: 'Comments:',
        defaultTextColor: '#666666',
        activeTextColor: '#453123'
    });
});

<!--

function HT_swapImgRestore() { 
    var i, x, a = document.HT_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function HT_preloadImages() {
    var d = document;
    if (d.images) {
        if (!d.HT_p) d.HT_p = new Array();
        var i, j = d.HT_p.length,
            a = HT_preloadImages.arguments;
        for (i = 0; i < a.length; i++)
        if (a[i].indexOf("#") != 0) {
            d.HT_p[j] = new Image;
            d.HT_p[j++].src = a[i];
        }
    }
}

function HT_findObj(n, d) { 
    var p, i, x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = HT_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n);
    return x;
}

function HT_swapImage() { 
    var i, j = 0,
        x, a = HT_swapImage.arguments;
    document.HT_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3)
    if ((x = HT_findObj(a[i])) != null) {
        document.HT_sr[j++] = x;
        if (!x.oSrc) x.oSrc = x.src;
        x.src = a[i + 2];
    }
}
//-->
//checkbox show or hide
$(document).ready(function () {

    //Hide div w/id extra
    $("#gates").css("display", "none");
    $("#railings").css("display", "none");
    $("#sidegates").css("display", "none");
    // Add onclick handler to checkbox w/id checkme
    $("#gatecheck").click(function () {
        // If checked
        if ($("#gatecheck").is(":checked")) {
            //show the hidden div
            $("#gates").show("fast");
            //$("#gates").css("background-color","#e3f5df");
        }
        else {
            //otherwise, hide it 
            $("#gates").hide("fast");
        }
    });



    // Add onclick handler to checkbox w/id checkme
    $("#railcheck").click(function () {
        // If checked
        if ($("#railcheck").is(":checked")) {
            //show the hidden div
            $("#railings").show("fast");
            //$("#railings").css("background-color","#f3f1db");
        }
        else {
            //otherwise, hide it 
            $("#railings").hide("fast");
        }
    });


    // Add onclick handler to checkbox w/id checkme
    $("#sidecheck").click(function () {
        // If checked
        if ($("#sidecheck").is(":checked")) {
            //show the hidden div
            $("#sidegates").show("fast");
            //$("#sidegates").css("background-color","#f3e4db");
        }
        else {
            //otherwise, hide it 
            $("#sidegates").hide("fast");
        }
    });

});

$(document).ready(function () {
    $("#quoteForm").validationEngine()
})
$(document).ready(function () {
    $("#contactForm").validationEngine()
})

$(document).ready(function () {
$("#submit").validationEngine()
})

// size convertor

function checnum(as) {
    var dd = as.value;

    if (isNaN(dd)) {
        dd = dd.substring(0, (dd.length - 1));
        as.value = dd;
    }
}

function inchconv(val) {
    with(document.conv) {
        cm.value = (Math.round(inch.value * 2.54)).toFixed(2);
        feet.value = (Math.round(inch.value / 12)).toFixed(2);
        var tmp = (inch.value * 2.54) * Math.pow(10, -5);
        kilo.value = ((inch.value * 2.54) * Math.pow(10, -5)).toFixed(2);
        miles.value = ((inch.value * 1.58) * Math.pow(10, -5)).toFixed(2);
    }
}

function feetconv(val) {
    with(document.conv) {
        cm.value = (Math.round(feet.value * 30.48)).toFixed(2);
        inch.value = (Math.round(feet.value * 12)).toFixed(2);
        kilo.value = ((feet.value * 3.05) * Math.pow(10, -4)).toFixed(2);
        miles.value == ((feet.value * 1.8900000000000001) * Math.pow(10, -4)).toFixed(2);
    }
}

function cmconv(val) {
    with(document.conv) {
        feet.value = (Math.round(cm.value / 30.84)).toFixed(2);
        inch.value = (Math.round(cm.value / 2.54)).toFixed(2);
        kilo.value = ((cm.value * 1) * Math.pow(10, -5)).toFixed(2);
        miles.value == ((cm.value * 6.21) * Math.pow(10, -6)).toFixed(2);
    }
}

function kiloconv(val) {
    with(document.conv) {
        feet.value = ((kilo.value * 3.28) * Math.pow(10, 3)).toFixed(2);
        inch.value = ((kilo.value * 3.94) * Math.pow(10, 4)).toFixed(2);
        cm.value = ((kilo.value * 1) * Math.pow(10, 5)).toFixed(2);
        miles.value = ((kilo.value * 0.621)).toFixed(2);
    }
}

function milesconv(val) {
    with(document.conv) {
        feet.value = ((miles.value * 5.28) * Math.pow(10, 3)).toFixed(2);
        inch.value = ((miles.value * 6.34) * Math.pow(10, 4)).toFixed(2);
        cm.value = ((miles.value * 1.61) * Math.pow(10, 5)).toFixed(2);
        kilo.value = ((miles.value * 1.61)).toFixed(2);
    }
} 

$(document).ready(function() {
			$("a.light").fancybox({
				'titleShow'		: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
		});
/*
$(document).ready(function(){
	$("#submit").validationEngine()
	
	$("form#submit").submit(function() {
	// we want to store the values from the form input box, then send via ajax below
	var cemail    = $('#cemail').attr('value');
	var cname     = $('#cname').attr('value');
		$.ajax({
			type: "POST",
			url: "capture.php",
			data: "cname="+ cname + "&cemail=" + cemail,
			success: 
			    function(){
				$('form#submit').hide(
				function(){
				$('div.success').fadeIn();
				});
			}
			
		});
	return false;
	
  });
});
*/


function initialize() {
				var latlng = new google.maps.LatLng(54.384251, -6.458579);
				var settings = {
					zoom: 14,
					center: latlng,
					mapTypeControl: true,
					mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
					navigationControl: true,
					navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
					mapTypeId: google.maps.MapTypeId.ROADMAP};
				var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
				var contentString = '<div id="content">'+
					'<div id="siteNotice">'+
					'</div>'+
					'<h1 id="firstHeading" class="firstHeading">Workshop 52 Markethill Road</h1>'+
					'<div id="bodyContent">'+
					'<p>Our workshop is always on the go and only up the road from our showroom</p>'+
					'</div>'+
					'</div>';
				var infowindow = new google.maps.InfoWindow({
					content: contentString
				});
				
				
				var contentString2 = '<div id="content">'+
					'<div id="siteNotice">'+
					'</div>'+
					'<h1 id="firstHeading" class="firstHeading">Showroom 148  Mahon Road</h1>'+
					'<div id="bodyContent">'+
					'<p>Our showroom has a wide varirty of products</p>'+
					'</div>'+
					'</div>';
				var infowindow2 = new google.maps.InfoWindow({
					content: contentString2
				});
				
				var companyImage = new google.maps.MarkerImage('images/map-logo.png',
					new google.maps.Size(100,50),
					new google.maps.Point(0,0),
					new google.maps.Point(50,50)
				);

				var companyShadow = new google.maps.MarkerImage('images/map-shadow.png',
					new google.maps.Size(130,50),
					new google.maps.Point(0,0),
					new google.maps.Point(65, 50));

				var companyPos = new google.maps.LatLng(54.383251, -6.457579);

				var companyMarker = new google.maps.Marker({
					position: companyPos,
					map: map,
					icon: companyImage,
					shadow: companyShadow,
					title:"Workshop",
					zIndex: 3});
				
				var showImage = new google.maps.MarkerImage('images/map-logo.png',
					new google.maps.Size(50,50),
					new google.maps.Point(0,0),
					new google.maps.Point(50,50)
				);

				var showShadow = new google.maps.MarkerImage('images/map-shadow.png',
					new google.maps.Size(70,50),
					new google.maps.Point(0,0),
					new google.maps.Point(60, 50)
				);

				var showPos = new google.maps.LatLng(54.388859, -6.447638);

				var showMarker = new google.maps.Marker({
					position: showPos,
					map: map,
					icon: showImage,
					shadow: showShadow,
					title:"Show Room",
					zIndex: 2
				});

				
				
				google.maps.event.addListener(companyMarker, 'click', function() {
					infowindow.open(map,companyMarker);
				});
				
				google.maps.event.addListener(showMarker, 'click', function() {
					infowindow2.open(map,showMarker);
				});
			}
