// Put all your lovely jQuery / Javascript goodies right down here.

// fade in
$(window).ready(function() {
//$('body').hide();
//$('body').fadeIn(100);
$('.bg').hide();
$('.bg').fadeIn(700); /*fadeIn rate in milliseconds. A higher number = slower fadeIn*/
$('.box_img').hide();
$('.box_img').fadeIn(3700)
});

// navigation
$(document).ready(function() {

	$("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag

	$("#topnav li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the <a> tag
		$(this).find("span").show().html(linkText); //Add the text in the <span> tag
	}); 

	$("#topnav li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({
			marginTop: "-40" //Find the <span> tag and move it up 40 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0"  //Move the <span> back to its original state (0px)
		}, 250);
	});

});

// flags
$(document).ready(function() {

	$("#topflags li").prepend("<span></span>"); //Throws an empty span tag right before the a tag

	$("#topflags li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the <a> tag
		$(this).find("span").show().html(linkText); //Add the text in the <span> tag
	}); 

	$("#topflags li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({
			marginTop: "-40" //Find the <span> tag and move it up 40 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0"  //Move the <span> back to its original state (0px)
		}, 250);
	});

});

// photo js
$(document).ready(function(){
	$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({
			animation_speed: 'normal', /* fast/slow/normal */
			slideshow: 8500, /* false OR interval time in ms */
			autoplay_slideshow: true, /* true/false */
			opacity: 0.9, /* Value between 0 and 1 */
			show_title: true, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
//			default_width: 500,
//			default_height: 344,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'pp_default', /* pp_default / light_rounded / dark_rounded / light_square / dark_square / facebook */
			horizontal_padding: 20, /* The padding on each side of the picture */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
//			wmode: 'opaque', /* Set the flash wmode attribute */
//			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			deeplinking: false, /* Allow prettyPhoto to update the url to enable deeplinking. */
			overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
			social_tools: false /*'<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>'*/ /* html or false to disable */
	});
});  

// box img gallery
$(document).ready(function(){

    // Set up our options for the slideshow...
    var myOptions = {
        noImages: 4,
        path: "img/box_img/",  //"Examples/Example 1/slideshow_images/", Relative path with trailing slash.
        captions: {                 
            1:'<b>RESIDENCE PLAYA SIRENA</b> <div style="font-size:18px;margin-top:10px;">Aperto tutto l&acute;anno</div>',
            2:'<b>Per una vacanza di puro relax</b>',
            3:'<b>A due passi dal lungomare</b>',
            4:'<b>Trascorri vacanze indimenticabili</b>',
           // 5:'<b>So for now I\'ll say goodbye!</b<div style="font-size:14px;margin-top:5px;">Although there is still one caption left to fill...</div>',
           // 6:'<b>Thank you for reading this nonsense!</b> <div style="font-size:14px;margin-top:5px;">I realise it is just nonsense, but at least you can see how captions can look with some text in them.</div>'
        },	
			//links: { // Each image number must be listed here, unless no links are required at all, then links option can be ommitted.
            //1:"http://www.google.com",
            //2:"http://www.yahoo.com",
            //3:"",
            //4:"http://www.jquery.com",
            //5:"http://www.youtube.com",
            //6:""
        //},
        //linksOpen:'newWindow',
		
    timerInterval: 8500, // 6500 = 6.5 seconds
	randomise: true // Start with random image? true / false
    };
    // Woo! We have a jquery slideshow plugin!
    $('#example_1_container').easySlides(myOptions);
}) 

// form validation
//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use
var checkobj
function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}
function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}
