/* Funcoes para o ecomerce * Hamilton Teixeira */

function flash(a, b, e, d) { var c = ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + b + '" height="' + e + '">'); c = c + ('<param name="movie" value="' + a + '" />'); c = c + ('<param name="quality" value="high" />'); c = c + ('<param name="menu" value="false" />'); c = c + ('<param name="wmode" value="transparent" />'); c = c + ('<embed src="' + a + '" width="' + b + '" height="' + e + '" quality="high" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>'); c = c + ("</object>"); $(d).append(c) }

function ValidarBusca(a) { if (a.value.length == "") { window.alert("Desculpe! \r Nenhum resultado encontrado \r Você pode: \r Tentar outra palavra ou grafia \r usar o menu lateral e comprar por categorias."); a.focus(); return (false) } else { if (a.value.length <= "3") { window.alert("Utilize no mínimo 4 letras, para que a busca possa ser efetuada"); a.select(); a.focus(); return (false) } else { var d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789-.,; /\t\r\n\f"; var b = a.value; var c = true; for (i = 0; i < b.length; i++) { ch = b.charAt(i); for (j = 0; j < d.length; j++) { if (ch == d.charAt(j)) { break } } if (j == d.length) { c = false; break } } if (!c) { window.alert("Para efetuar a procura são aceitos apenas letras (com ou sem acentos) ou números. Obrigado"); a.select(); a.focus(); return (false) } else { return (true) } } } } function openWin_disclaimer(a) { myWin = open(a, "Pagina", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,help:0,resizable=no,width=550,height=300,top=140,left=210") } function selectDrop(b, c, d) { var a = b; if (a.options[a.selectedIndex].value != "") { self.location = c + "?tipo=" + d + "&id=" + a.options[a.selectedIndex].value } } function MM_swapImgRestore() { var d, b, c = document.MM_sr; for (d = 0; c && d < c.length && (b = c[d]) && b.oSrc; d++) { b.src = b.oSrc } } function MM_findObj(f, e) { var c, b, a; if (!e) { e = document } if ((c = f.indexOf("?")) > 0 && parent.frames.length) { e = parent.frames[f.substring(c + 1)].document; f = f.substring(0, c) } if (!(a = e[f]) && e.all) { a = e.all[f] } for (b = 0; !a && b < e.forms.length; b++) { a = e.forms[b][f] } for (b = 0; !a && e.layers && b < e.layers.length; b++) { a = MM_findObj(f, e.layers[b].document) } if (!a && e.getElementById) { a = e.getElementById(f) } return a } function MM_swapImage() { var e, d = 0, b, c = MM_swapImage.arguments; document.MM_sr = new Array; for (e = 0; e < (c.length - 2); e += 3) { if ((b = MM_findObj(c[e])) != null) { document.MM_sr[d++] = b; if (!b.oSrc) { b.oSrc = b.src } b.src = c[e + 2] } } } function checavazio(c, d, b) { var a = ""; if (d == "s") { a = "Selecione .:" } else { a = "Preencha .:" } if (c.value.length == "") { window.alert(a); c.focus(); return (false) } } function MM_preloadImages() { var f = document; if (f.images) { if (!f.MM_p) { f.MM_p = new Array() } var e, c = f.MM_p.length, b = MM_preloadImages.arguments; for (e = 0; e < b.length; e++) { if (b[e].indexOf("#") != 0) { f.MM_p[c] = new Image; f.MM_p[c++].src = b[e] } } } };


var enablepersist = "on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious = "yes" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById) {
    document.write('<style type="text/css">')
    document.write('.switchcontent{display:none;}')
    document.write('</style>')
}

function getElementbyClass(classname) {
    ccollect = new Array()
    var inc = 0
    var alltags = document.all ? document.all : document.getElementsByTagName("*")
    for (i = 0; i < alltags.length; i++) {
        if (alltags[i].className == classname)
            ccollect[inc++] = alltags[i]
    }
}

function contractcontent(omit) {
    var inc = 0
    while (ccollect[inc]) {
        if (ccollect[inc].id != omit)
            ccollect[inc].style.display = "none"
        inc++
    }
}

function expandcontent(cid) {
    if (typeof ccollect != "undefined") {
        if (collapseprevious == "yes")
            contractcontent(cid)
        document.getElementById(cid).style.display = (document.getElementById(cid).style.display != "block") ? "block" : "none"
    }
}

function revivecontent() {
    contractcontent("omitnothing")
    selectedItem = getselectedItem()
    selectedComponents = selectedItem.split("|")
    for (i = 0; i < selectedComponents.length - 1; i++)
        document.getElementById(selectedComponents[i]).style.display = "block"
}

function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        if (offset != -1) {
            offset += search.length
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            returnvalue = unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}

function getselectedItem() {
    if (get_cookie(window.location.pathname) != "") {
        selectedItem = get_cookie(window.location.pathname)
        return selectedItem
    }
    else
        return ""
}

function saveswitchstate() {
    var inc = 0, selectedItem = ""
    while (ccollect[inc]) {
        if (ccollect[inc].style.display == "block")
            selectedItem += ccollect[inc].id + "|"
        inc++
    }

    document.cookie = window.location.pathname + "=" + selectedItem
}

function do_onload() {
    getElementbyClass("switchcontent")
    if (enablepersist == "on" && typeof ccollect != "undefined")
        revivecontent()
}


if (window.addEventListener)
    window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
    window.attachEvent("onload", do_onload)
else if (document.getElementById)
    window.onload = do_onload

if (enablepersist == "on" && document.getElementById)
    window.onunload = saveswitchstate
