﻿$(document).ready(function () {
    //Carousel
    $(function () {
        $("div.slider").carousel({
            dispItems: 4,
            loop: false
        });
    });
    //Open external links in a new browser tab/window
    $('a[rel=external]').attr('target', '_blank')
    //Remove Skype phone number detection
    window.setTimeout(function () {
        $('.skype_pnh_container').html('');
        $('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
    }, 800);
    //Create xhtml strict friendly iframe
    $('a.iframe').each(
		function (i) {
		    $(this).replaceWith("<iframe src='" + this.getAttribute("href") + "?wmode=transparent' width='640' height='390' frameborder='0' scrolling='no' allowfullscreen></iframe>");
		}
	);
});

function BuscaDicionarios() {

    
    var valid = false;

    if (jQuery("#campopesquisa").val().replace(/^\s+|\s+jQuery/g, "") == "") {
        alert("Digite uma palavra para buscar no dicionário!");
        jQuery("#campopesquisa").focus();
        valid = false;
        return false;
    }

    jQuery('.check_dicionarios').each(function () {
        if (this.checked)
            valid = true;
    });

    if (valid != true) {
        alert("Selecione um ou mais dicionários para realizar a busca.");
        return false;
    }

    if (jQuery("#dic_cambridge").attr("checked") && valid == true) {
        window.open("http://dictionary.cambridge.org/search/british/?q=" + jQuery("#campopesquisa").val(), "CambridgeTab");
    }

    if (jQuery("#dic_oxford").attr("checked") && valid == true) {
        window.open("http://www.oxfordadvancedlearnersdictionary.com/search/?q=" + jQuery("#campopesquisa").val(), "OxfordTab");
    }

    if (jQuery("#dic_macmillan").attr("checked") && valid == true) {
        window.open("http://www.ldoceonline.com/search/?q=" + jQuery("#campopesquisa").val(), "MacmillanTab");
    }

}

