﻿var xx; var yy; var r = Math.round(Math.random() * 1000000000);
var ptc;

function ac(c_name) {
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=");
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(";", c_start);
if (c_end == -1) c_end = document.cookie.length
return unescape(document.cookie.substring(c_start, c_end));
}}return ""
}

function bc(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + expiredays);
document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + exdate.toGMTString());
}

function cc(z, y) { var x = new Date(); var w = new Date(x.getTime() + 360000);
document.cookie = z + "=" + escape(y) + "; expires=" + w.toGMTString();
}

function pc(z, y) {
    var px = new Date(); var pw = new Date(px.getTime() + 1800000);
    document.cookie = z + "=" + escape(y) + "; expires=" + pw.toGMTString();
}

function QueryString(variavel) {
    var variaveis = location.search.replace(/\x3F/, "").replace(/\x2B/g, " ").split("&")
    var nvar
    if (variaveis != "") {
        var qs = []
        for (var i = 0; i < variaveis.length; i++) {
            nvar = variaveis[i].split("=")
            qs[nvar[0]] = unescape(nvar[1])
        }
        return qs[variavel]
    }
    return null
}

function pt1() {
    var id = ac("ust_p");
    if (id == "TWITTER") {
        document.write("<a href='javascript:void(0);' class='showTip TW2'><img src='images/sou_twitter.gif' width='265' height='20'></a>");
    }
    else {
    document.write("<a href='http://www.twitter.com/lojaiomega' class='showTip TW1'><img src='images/nao_sou_twitter.gif' width='335' height='20'></a>");
    }
}

function pt2() {
    var id = ac("ust_p");
    if (id == "EMC_empresa") {
        document.write("<a href='twitter.asp' class='showTip pt1'><img src='images/eu_sou_um_emc.gif' width='150' height='20'></a>");
    }
    else if (id == "TWITTER") {
    document.write("<a href='http://www.lojaiomega.com.br/twitter.asp' class='showTip TW3'><img src='images/eu_sou_twitter.gif'></a>");
    }
    else {
        document.write("<a href='http://www.lojaiomega.com.br/twitter.asp' class='showTip TW3'><img src='images/promo_twitter.gif'></a>");
    }
}

function cpt() {
    var id = ac("ust_p");
    document.write(id);
}

//window.onload = function() {
//    var g = 121212; var v; var s; x = ac("ust_v"); z = ac("ust_s");
//    if (x != null && x != "") { bc("ust_v", x, 365); v = ""; } else { bc("ust_v", r, 365); v = "New"; x = r }
//    if (z != null && z != "") { cc("ust_s", "cc"); s = ""; } else { cc("ust_s", "cc"); s = "Visitor"; }
//    var t = "hRefer=" + document.referrer + "&Entrada=" + document.URL + "&Plataforma=" + navigator.platform + "&Domain=" + document.domain + "&ClientID=" + g + "&xx=" + x + "&rr=" + r + "&ss=" + v + s
//    
//    var AJAX = new XMLHttpRequest();
//    AJAX.onreadystatechange = function() { 
//    if (AJAX.readyState != 4) return false; }
//    
//    AJAX.open("GET", 'https://www.soipod.com.br/ust/sitetrack.aspx?' + t, false); AJAX.send(null);
//    document.write("<img src=http://www.soipod.com.br/ust/sitetrack.aspx?" + t + " width=1 height=1>");
//}

//window.onload = function() {
function c() {
    var g = 121212;
    var pt = QueryString("partner");
    if (pt != null && pt != "") { pc("ust_p", pt); }
    var sc1 = QueryString("?q");
    var sc2 = QueryString("&q");

    var v; var s; x = ac("ust_v"); z = ac("ust_s"); ptc = ac("ust_p");
    if (x != null && x != "") { bc("ust_v", x, 365); v = ""; } else { bc("ust_v", r, 365); v = "New"; x = r }
    if (z != null && z != "") { cc("ust_s", "cc"); s = ""; } else { cc("ust_s", "cc"); s = "Visitor"; }
    if (ptc != null && ptc != "") { pc("ust_p", ptc); }
    var t = "hRefer=" + document.referrer + "&Entrada=" + document.URL + "&Plataforma=" + navigator.platform + "&Domain=" + document.domain + "&ClientID=" + g + "&xx=" + x + "&rr=" + r + "&ss=" + v + s + "&pt=" + pt + "&pc=" + ptc + "&sch=" + sc1 + sc2



    var xmlhttp = false;
    //    /* running locally on IE5.5, IE6, IE7 */; /*@cc_on
    //    if (location.protocol == "file:") {
    //        if (!xmlhttp) try { xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); } catch (e) { xmlhttp = false; }
    //        if (!xmlhttp) try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; }
    //    }; @cc_off@*/
    /* IE7, Firefox, Safari, Opera...  */
    if (!xmlhttp) try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; }
    /* IE6 */
    if (typeof ActiveXObject != "undefined") {
        if (!xmlhttp) try { xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); } catch (e) { xmlhttp = false; }
        if (!xmlhttp) try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; }
    }
    /* IceBrowser */
    if (!xmlhttp) try { xmlhttp = createRequest(); } catch (e) { xmlhttp = false; }



    if (!xmlhttp) return alert("Your browser doesn't seem to support XMLHttpRequests.");
    xmlhttp.open("GET", 'http://www.lojaiomega.com.br/ust/sitetrack.aspx?' + t, false); //make sure open appears before onreadystatechange lest IE will encounter issues beyond the first request
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState != 4) return;
        if (!xmlhttp.status || xmlhttp.status == 200)
        //alert(xmlhttp.responseText);
            ;
        else
            alert(xmlhttp.responseText);
    }; //onreadystatechange
    xmlhttp.send(null);
}

window.onbeforeunload = function() {
// No error checking
var AJAX=new XMLHttpRequest(); AJAX.onreadystatechange= function() { if (AJAX.readyState!=4) return false; }
AJAX.open("GET", 'http://www.lojaiomega.com.br/ust/updatest.aspx?sts=OUT&pid=' + r, false); AJAX.send(null);
}

//window.onblur = function() {
//var AJAX = new XMLHttpRequest(); AJAX.onreadystatechange = function() { if (AJAX.readyState != 4) return false; }
//AJAX.open("GET", 'http://www.soipod.com.br/ust/updatest.aspx?sts=BCK&pid=' + r, false); AJAX.send(null);
//}

//window.onfocus = function() {
//var AJAX = new XMLHttpRequest(); AJAX.onreadystatechange = function() { if (AJAX.readyState != 4) return false; }
//AJAX.open("GET", 'http://www.soipod.com.br/ust/updatest.aspx?sts=YES&pid=' + r, false); AJAX.send(null);
//}


//function showfilm(kinofile)
//{
//if(!xmlhttp)return alert("Your browser doesn't seem to support XMLHttpRequests.");
//xmlhttp.open("GET",kinofile,true);//make sure open appears before onreadystatechange lest IE will encounter issues beyond the first request
//xmlhttp.onreadystatechange=function(){
//if(xmlhttp.readyState!=4)return;
//if(!xmlhttp.status||xmlhttp.status==200)
//alert(xmlhttp.responseText);
//else
//alert("Request failed!");
//};//onreadystatechange
//xmlhttp.send(null);
//}//showfilm

