var golf=false;

$(document).ready(function() {

    var viatype = "";

    if (screen.height < 800) {
        $("#contenido").css("min-height", "338px");
        $("#footer").css("position", "relative");
    } else {
        $("#footer").css("position", "absolute");
        $("#footer").css("bottom", "0px");
    }

    loadGif = '<div id="loading" class="loading"><img src="img/ajax-loader.gif" alt="Cargando..." width="32" height="32" align="absmiddle" />Cargando...</div>';

    function loadComplete(seccion) {

        $("#contenido").animate({
            opacity: 0.0
        },
        300,
        function() {
            finalLoad(seccion)
        });

        function finalLoad(seccion) {
            secciones = new Array("nosotros.html", "paquetes.html", "golf.html", "herramientas.html", "reservaciones.html", "contacto.html", "tell.html");

            $("#contenido").load(secciones[seccion]);
            $("#contenido").ajaxSuccess(function(evt, request, settings) {
                $("#contenido").animate({
                    opacity: 1.0
                },
                300);
            });
        }
    }

    function loadSec(sec) {

        $("#contenido").html(loadGif);
        $("#contenido").animate({
            opacity: 1.0
        },
        100,
        function() {
            loadComplete(sec)
        });
    }

    // MENU BOTONES *****************************************
    // MENU BOTONES *****************************************
    // MENU BOTONES *****************************************
    // MENU BOTONES *****************************************
    $("#menu").find("li").each(function(i) {
        $(this).mouseover(function() {
            $(this).addClass("over");
        })

        $(this).mouseout(function() {
            $(this).removeClass("over");
        })

        $(this).click(function() {

            $("#contenido").animate({
                opacity: 0.0
            },
            300,
            function() {
                loadSec(i)
            });

            $("#menu").find("li").removeClass("selected");
            $(this).addClass("selected");
        })
    })

    //default
    function lDefault() {
	    $("#contenido").animate({
	        opacity: 0.0
	    },
	    300,
	    function() {
	        loadSec('0')
	    });
	    $("#menu").find("li").removeClass("selected");
	    $('#b0').addClass("selected");
    }
    
    $("#logo").click(function(){
			lDefault();
				})
	
	if (tell) {
		//nah
	} else {
		lDefault();
	}
	
	
	function ltell() {
	    $("#contenido").animate({
	        opacity: 0.0
	    },
	    300,
	    function() {
	        loadSec('6')
	    });
	    //$("#menu").find("li").removeClass("selected");
	    //$('#b0').addClass("selected");
    }
    
});

function array_push ( array ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: array_push(['kevin','van'], 'zonneveld');
    // *     returns 1: 3
 
    var i, argv = arguments, argc = argv.length;
 
    for (i=1; i < argc; i++){
        array[array.length++] = argv[i];
    }
 
    return array.length;
}

function strip_tags(str, allowed_tags) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Luke Godfrey
    // +      input by: Pul
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +      input by: Alex
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strip_tags('<p>Kevin</p> <br /><b>van</b> <i>Zonneveld</i>', '<i><b>');
    // *     returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
    // *     example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
    // *     returns 2: '<p>Kevin van Zonneveld</p>'
    // *     example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
    // *     returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
 
    var key = '', tag = '', allowed = false;
    var matches = allowed_array = [];
    var allowed_keys = {};
 
    var replacer = function(search, replace, str) {
        return str.split(search).join(replace);
    };
 
    // Build allowes tags associative array
    if (allowed_tags) {
        allowed_array = allowed_tags.match(/([a-zA-Z]+)/gi);
    }
  
    str += '';
 
    // Match tags
    matches = str.match(/(<\/?[^>]+>)/gi);
 
    // Go through all HTML tags
    for (key in matches) {
        if (isNaN(key)) {
            // IE7 Hack
            continue;
        }
 
        // Save HTML tag
        html = matches[key].toString();
 
        // Is tag not in allowed list? Remove from str!
        allowed = false;
 
        // Go through all allowed tags
        for (k in allowed_array) {
            // Init
            allowed_tag = allowed_array[k];
            i = -1;
 
            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}
            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
            if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}
 
            // Determine
            if (i == 0) {
                allowed = true;
                break;
            }
        }
 
        if (!allowed) {
            str = replacer(html, "", str); // Custom replace. No regexing
        }
    }
 
    return str;
}

function telly(){
		$('#tellx').html('<form style=\"display: block; float: left; clear: left; font-size: 12px; margin-top: 20px; color: white\" method=POST action=tell.php>Tu nombre:<br><input name=from style=\"border: 1px solid gray; width: 250px; height: 20px\" /><br>E-mail de tu amigo:<br><input style=\"border: 1px solid gray; width: 250px; height: 20px\" name=to size=20 /><br>Contenido:<br><textarea name=body style=\"border: 1px solid gray; width: 450px; height: 150px\" >Hola,\nte recomiendo el siguiente paquete que vi en http://www.gsm-mexico.com:\n\n'+ gtitle +'\n'+ gbody +'\n\nEspero sea de tu interes.</textarea><br><br><input type=submit value=\"Enviar\" /></form>');
	}