﻿//function $(element) {
//    if (arguments.length > 1) {
//        for (var i = 0, elements = [], length = arguments.length; i < length; i++)
//            elements.push($(arguments[i]));
//        return elements;
//    }
//    if (typeof element == 'string')
//        element = document.getElementById(element);
//    return Element.extend(element);
//}

function $(element) {
    return document.getElementById(element);
}

function createObjectCallback(obj, fn) {
    return function() { fn.apply(obj, arguments); };
}

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/;";
  //  if (document.domain != "localhost")
     //   cookie += " domain= .imperialfire.com;";
   // document.cookie = cookie;

}

function readCookie(name) {

    var nameEQ = name + "=";

    var ca = document.cookie.split(';');

    for (var i = 0; i < ca.length; i++) {

        var c = ca[i];

        while (c.charAt(0) == ' ') c = c.substring(1, c.length);

        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);

    }

    return null;

}


function eraseCookie(name) {

    createCookie(name, "", -1);
}

/* Client-side access to querystring name=value pairs
Version 1.3
28 May 2008
	
License (Simplified BSD):
http://adamv.com/dev/javascript/qslicense.txt
*/
function Querystring(qs) { // optionally pass a querystring to parse
    this.params = {};

    if (qs == null) qs = location.search.substring(1, location.search.length);
    if (qs.length == 0) return;

    // Turn <plus> back to <space>
    // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
    qs = qs.replace(/\+/g, ' ');
    var args = qs.split('&'); // parse out name/value pairs separated via &

    // split out each name=value pair
    for (var i = 0; i < args.length; i++) {
        var pair = args[i].split('=');
        var name = decodeURIComponent(pair[0]);

        var value = (pair.length == 2)
			? decodeURIComponent(pair[1])
			: name;

        this.params[name] = value;
    }
}

Querystring.prototype.get = function(key, default_) {
    if(key == null)
        return location.search.substring(1, location.search.length);
    else{
        var value = this.params[key];
        return (value != null) ? value : default_;
    }
}

Querystring.prototype.contains = function(key) {
    var value = this.params[key];
    return (value != null);
}


//*******************************//
function alertSize() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    window.alert('Width = ' + myWidth);
    window.alert('Height = ' + myHeight);
}
function getWindowHeight() {
    myHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
        //Non-IE
        myHeight = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
    }
    return myHeight;
}
function getWindowWidth() {
    myWidth = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
} else if (document.body && document.body.clientWidth) {
        //IE 4 compatible
    myWidth = document.body.clientWidth;
    }
    return myWidth;
}
document.getElementsByClassName = function(cl) {
    var retnode = [];
    var myclass = new RegExp('\\b' + cl + '\\b');
    var elem = this.getElementsByTagName('*');
    for (var i = 0; i < elem.length; i++) {
        var classes = elem[i].className;
        if (myclass.test(classes)) retnode.push(elem[i]);
    }
    return retnode;
};

function IsNullOrEmpty(checkValue)
{
    if ((window[checkValue] == undefined) ||(typeof checkValue == 'undefined') || (window[checkValue] == null) ||(typeof checkValue == 'null'))
    {
        return true;
    }
    else
    {
        return false;
    }
}

//findcss uses CSS selectors in js
// use findCSS ('selectorHere')
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 5=9(a,b){1S{5.P=b?b:X;7 r=q();7 c=a.1o(",");8(c.m==1){r=5.1g(a)}p{v(7 i=0;i<c.m;i++){r=5.17(r,5.1g(5.1t(c[i])))}}6 r}1Z(e){6"1U 1R 1Q 1O 1L 2e 2c 29"}};9 N(a,b){b=b?b:X;8(!N.V[a]){N.V[a]=5(a,b)}6 N.V[a]}9 24(a){5.1c=o;7 r=5(a);5.1c=k;6 r}N.V={};5.1g=9(a){5.L=q();7 b=5.1C(a);7 c=k;7 i=0;7 x=5.1c?q(k,0):5.1B(b);8(x[1]===o||x[1]>0){7 r=q();7 d=x[0].1v();1A(d){r.u(d);d=x[0].1v()}8(x[1]===o){6 r}p{i=x[1]%2==0?x[1]:x[1]-1;8(i%2==0){c=5.I(b[i])}}}p{c=5.I(b[0]);7 e=5.1p(c,5.P);8(e!==k){7 r=e;i=1}p{7 r=5.S(c,5.P.15(c[1]))}}v(;i<b.m;i++){8(i%2==0){r=5.S(c,r)}p{c=5.I(b[i+1]);r=5.1m(b[i],c[1],r)}}6 r};5.1C=9(a){7 b=q();7 d="";7 e=k;7 f=0;7 l=a.m;1A(f<l){7 c=a.C(f);8(e==k&&(c=="+"||c==">"||c=="~")){b.u(d);b.u(c);d=""}p{8(e==k&&c==" "){7 g=a.C(f+1);7 h=a.C(f-1);8(g!=" "&&h!=" "&&h!=">"&&g!=">"&&g!="+"&&h!="+"&&h!="~"&&g!="~"){b.u(d);b.u("16");d=""}}p{8(c=="]"){e=k;d+=c}p{8(c=="["){e=o;d+=c;8(a.C(f+1)=="@"){f++}}p{d+=c}}}}f++}b.u(d);6 b};5.I=9(a){7 b="";7 d=q("1b");7 e=0;7 c=a.C(0);8(c=="#"||c==":"||c=="."||c=="["){a="*"+a}v(7 f=0;f<a.m;f++){c=a.C(f);8(e==0&&(c=="#"||c==":"||c=="."||c=="[")){d.u(b);d.u(c);b=""}p{8(c=="("){b+=c;e++}p{8(c==")"){b+=c;e--}p{b+=c}}}}d.u(b);6 d};5.S=9(a,b){7 r=q();8(a.m==2){6 b}v(7 j=0;j<b.m;j++){7 c=o;v(7 i=2;i<a.m;i+=2){8(!5.11[a[i]](b[j],a[i+1])){c=k;W}}8(c){r[r.m]=b[j]}}6 r};5.1m=9(a,b,c){7 r=q();v(7 i=0;i<c.m;i++){r=5.17(r,5.1G[a](c[i],b))}6 r};5.1B=9(a){8(X.1F){7 b="";7 c;7 d="//";10:v(7 i=0;i<a.m;i++){8(i%2==0){c=5.I(a[i]);v(7 j=0;j<c.m;j+=2){8(5.y[c[j]]){7 s=5.y[c[j]](c[j+1]);8(!s){i--;W 10}d+=s}p{i--;W 10}}b+=d}p{8(5.y[a[i]]){d=5.y[a[i]]}p{W 10}}}8(i>0){6 q(X.1F(b,5.P,1e,26.25,1e),i==a.m-1?o:i)}p{6 q(k,0)}}6 q(k,0)};5.1p=9(a,b){8(a.m==2){6 b.15(a[1])}p{8(a.m==4&&a[2]=="#"){7 c=b.23(a[3]);8(c.M==a[1].J()||a[1]=="*"){6 q(c)}}}6 k};5.17=9(a,b){7 c=b.m;7 r=a;v(7 i=0;i<c;i++){8(!5.1E(r,b[i])){a.u(b[i])}}6 a};5.1E=9(b,c){7 d=b.m;v(7 i=0;i<d;i++){8(b[i]==c){6 o}}6 k};5.1D=9(a){7 r=q();v(7 i=0;i<a.w.F.m;i++){8(a.w.F[i]!=a){r.u(a.w.F[i])}}6 r};5.1a=9(a){7 c=5.E(a.w);v(7 i=0;i<c.m;i++){8(c[i]==a){6 i}}6 k};5.E=9(a){8(!a.19){a.19=5.K(a.F,"22",1)}6 a.19};5.K=9(b,c,d){7 r=q();v(7 i=0;i<b.m;i++){8(b[i][c]==d||d=="*"){r.u(b[i])}}6 r};5.U=9(a,b,c){8(!5.L[a]){5.L[a]=a.1o(b)}v(7 i=0;i<5.L[a].m;i++){8(5.L[a][i]==c){6 o}}6 k};5.1t=9(a){6 a.1x(/^\\s+|\\s+$/g,"")};5.D={"1w-A":9(a){7 c=5.E(a.w);6 c[0]==a},"1u-A":9(a){7 c=5.E(a.w);6 c[c.m-1]==a},"1y-A":9(a){7 c=5.E(a.w);6 c.m==1},"1z":9(a){6 a.F.m==0},"21-A":9(a,b){8(b=="1s"||b=="1r"){6 5.D[b](a)}7 c=5.E(a.w);6 c[b-1]==a},"1s":9(a){6 5.1a(a)%2!=0},"1r":9(a){6 5.1a(a)%2==0},"T":9(a,b){7 c=5.I(b);7 d=5.S(c,q(a));8(d.m==1){6 k}6 o},"20":9(a){6 a.w?k:o},"1d":9(a,b){8(a.1q){7 c=a.1q}p{7 d=a.1Y.1x(/<[\\1W-1V-Z\\/]+>/g,"")}b=b.B(1,-1);6 d.O(b)==-1?k:o},"1T":9(a){8(1i.1l.1k){7 b=1i.1l.1k.14(1);8(a.13==b){6 o}}6 k},"Q":9(a){8(a.Q){6 o}6 k},"R":9(a){8(a.R){6 o}6 k}};5.1G={"16":9(a,b){6 a.15(b)},">":9(a,b){6 5.K(a.F,"M",b.J())},"+":9(a,b){7 r=q();8(a.1j){r.u(a.1j)}8(a.1n){r.u(a.1n)}6 5.K(r,"M",b.J())},"~":9(a,b){6 5.K(5.1D(a),"M",b.J())}};5.y={"1b":9(a){6 a},"#":9(a){6"[@13=\'"+a+"\']"},".":9(a){6"[1d(1P(\' \', @1X, \' \'), \' "+a+" \')]"},"[":9(a){7 b=5.11["["](1e,a,o);8(b===o){6"[@"+a+"]"}p{8(5.y.12[b[1]]){6 5.y.12[b[1]](b[0],b[2])}}6 k},"12":{"=":9(a,b){6"[@"+a+"=\\""+b+"\\"]"},"*=":9(a,b){6"[1d(@"+a+",\'"+b+"\')]"},"^=":9(a,b){6"[1N-1K(@"+a+",\'"+b+"\')]"},"$=":9(a,b){6"[1M-1K(@"+a+",\'"+b+"\')]"}},":":9(a){8(5.y.18[a]){6 5.y.18[a]}6 k},"18":{"1w-A":"[T(1h-G::*)]","1u-A":"[T(Y-G::*)]","1y-A":"[T(1h-G::* 1I Y-G::*)]","1z":"[1H(*) = 0 2d (1H(1J()) = 0 1I 2b(1J(), \' \\t\\r\\n\', \'\') = \'\')]","Q":"[@Q]","R":"[@R]"},"16":"//",">":"/","+":"./Y-G::*[1]","~":"./Y-G::*"};5.11={"1b":9(a,b){8(a.M!=b.J()&&b!="*"){6 k}6 o},".":9(a,b){6 5.U(a.2a," ",b)},"#":9(a,b){8(a.13!=b){6 k}6 o},":":9(a,b){8(5.D[b]){6 5.D[b](a)}p{7 c=b.28(/[a-z\\-]+/)[0];7 d=b.B(c.m+1,-1);8(5.D[c]){6 5.D[c](a,d)}p{6 k}}},"[":9(a,b,c){7 d=b.O("=");8(d==-1){7 e=b.B(0,-1);8(c){6 o}6 a.27(e)}p{7 f=b.B(0,-2);7 g=f.14(d+2);7 h=f.B(d-1,d+1);8(5.1f[h]){d=d-1}p{h="="}7 i=f.B(0,d);8(c){6 q(i,h,g)}6 5.1f[h](a,i,g)}}};5.1f={"=":9(a,b,c){6 a.H(b)==c},"*=":9(a,b,c){7 d=a.H(b);8(d&&d.O(c)!=-1){6 o}6 k},"~=":9(a,b,c){7 d=a.H(b);8(d&&5.U(d," ",c)){6 o}6 k},"|=":9(a,b,c){7 d=a.H(b);8(d&&5.U(d,"-",c)){6 o}6 k},"^=":9(a,b,c){7 d=a.H(b);8(d&&d.O(c)==0){6 o}6 k},"$=":9(a,b,c){7 d=a.H(b);8(d){8(d.14(d.m-c.m)==c){6 o}}6 k}};',62,139,'|||||findCSS|return|var|if|function|||||||||||false||length||true|else|Array||||push|for|parentNode||xpath||child|slice|charAt|pseudos|fakeChildren|childNodes|sibling|getAttribute|buildIStack|toUpperCase|filterByValue|temp|nodeName|findCSSc|indexOf|node|checked|disabled|filterSelector|not|splitAndCheck|cached|break|document|following||stk|selectors|att_xpath|id|substring|getElementsByTagName|space|merge|pseudo_xpath|children|findElement|tag|noX|contains|null|att_types|findSingle|preceding|window|nextSibling|hash|location|filterCombinator|previousSibling|split|filterQuick|innerText|odd|even|trim|last|iterateNext|first|replace|only|empty|while|filterXpath|buildStack|findAllSiblings|inA|evaluate|combinators|count|or|text|with|in|ends|start|error|concat|an|was|try|target|There|zA|sa|class|innerHTML|catch|root|nth|nodeType|getElementById|findCSSx|UNORDERED_NODE_ITERATOR_TYPE|XPathResult|hasAttribute|match|syntax|className|translate|CSS|and|you'.split('|'),0,{}))

function getProvider(productKey){
    var keyInfo;
    var provider = "";
    if (productKey != null && productKey != "")
    {
        keyInfo = productKey.split("=");
        if (keyInfo.length > 0){provider = keyInfo[2];}
        provider = provider.replace("&id", "");
        return provider;
    }
}
function getPhoneNumber(){
    var phoneNum = "Customer Service";
    var phoneDiv = $('divPhoneNum');
    if (phoneDiv != null)
    {
        if(phoneDiv.innerHTML != null && phoneDiv.innerHTML != ""){phoneNum = phoneDiv.innerHTML;}
    }
    return phoneNum;
  }
  function getPromo() {
    var promoNum = "Promo";
    var promoDiv = $('divpromo');
    if (promoDiv != null) {
      if (promoDiv.innerHTML != null && promoDiv.innerHTML != "") { promoNum = promoDiv.innerHTML; }
    }
    return promoNum;
  }

function notSellingProvider(provider){
    if (provider == "ATT" || provider == "Verizon" || provider == "Vonage" || provider == "Qwest" || provider == "Dish")
    {
     return true;
    }else{return false;}
    KillSplash();
}
  // ****************************************************************
    // * Resusable overlay for popup windows
    // ****************************************************************

function ReplaceEmbedWithSpan(isReplaceBack)
{
 var arSelect = document.getElementsByTagName("embed");
 
 for(var i=0;i<arSelect.length;i++)
 {
 if(!isReplaceBack)
 {
       arSelect[i].style.marginLeft = "-5000px";
  }
     else
   {    arSelect[i].style.marginLeft = "";}
 }
}




       function toggle(obj) {
           var el;
           if (typeof obj == 'string')
               el = document.getElementById(obj);
           else
               el = obj;
        if (el.style.display != 'none') {
            el.style.display = 'none';
        }
        else {
            el.style.display = 'block';
        }
    }

    
    
    function toggleVisibility(obj, initialValue) {
        var el;
        if (typeof obj == 'string')
            el = document.getElementById(obj);
        else
            el = obj;
        if ((el.style.visibility == '') && !(initialValue === undefined)) {
            el.style.visibility = initialValue;
        }
        if (el.style.visibility != 'hidden') {
            el.style.visibility = 'hidden';
        }
        else {
            el.style.visibility = 'visible';
        }
    }

//**********  Start Dictionary Section **********//
//    var providerRedirect = new Dictionary();
//    providerRedirect.Add("comcast", "http://www.onlinecomcast.com");
//    providerRedirect.Add("charter", "http://www.buycharter.com");
//    providerRedirect.Add("cox", "http://www.buycox.com");
//    providerRedirect.Add("brighthouse", "http://www.buybrighthouse.com");
//    providerRedirect.Add("insight", "http://www.buyinsightnow.com");
//    providerRedirect.Add("optimum", "http://www.buyoptimum.com");
//    providerRedirect.Add("time_warner", "http://www.buytimewarnercable.com");

//    var keys = providerRedirect.Keys;

//    function Lookup(key) {
//        key = key.toString().toLowerCase();
//        var newUrl = 'http://www.saveology.com';
//        for (var i = 0; i < this.Keys.length; i++) {
//            if (this[key] != null)
//                newUrl = (this[key]);
//            break;
//        }
//        return newUrl;
//    }

//    function Delete() {
//        for (c = 0; c < Delete.arguments.length; c++) {
//            this[Delete.arguments[c]] = null;
//        }
//        // Adjust the keys (not terribly efficient)
//        var keys = new Array()
//        for (var i = 0; i < this.Keys.length; i++) {
//            if (this[this.Keys[i]] != null)
//                keys[keys.length] = this.Keys[i];
//        }
//        this.Keys = keys;
//    }

//    function Add() {
//        for (c = 0; c < Add.arguments.length; c += 2) {
//            // Add the property
//            this[Add.arguments[c]] = Add.arguments[c + 1];
//            // And add it to the keys array
//            this.Keys[this.Keys.length] = Add.arguments[c];
//        }
//    }

//    function Dictionary() {
//        this.Add = Add;
//        this.Lookup = Lookup;
//        this.Delete = Delete;
//        this.Keys = new Array();
//    }
    //**********  End Dictionary Section **********//
    function getInternetExplorerVersion()
    // Returns the version of Internet Explorer or a -1
    // (indicating the use of another browser).
    {
        var rv = -1; // Return value assumes failure.
        if (navigator.appName == 'Microsoft Internet Explorer') {
            var ua = navigator.userAgent;
            var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
            if (re.exec(ua) != null)
                rv = parseFloat(RegExp.$1);
        }
        return rv;
    }
