var useaxis = "";

//var originaltotal = 20000;
//var total = originaltotal;
//var carval = 113.31;
//var planeval = 303.36;
//var continuing = false;
var thetimeout;
var myEl;
//var pta = 0;

var vscrolltime = 700;
var hscrolltime = 1168;




function formwrangler(loc) {

    $('input,select,textarea').attr("disabled", "true");

    if (!loc) { } else {
        lclstr = "#" + loc + " input," + "#" + loc + " select," + "#" + loc + " textarea";
        $(lclstr).removeAttr("disabled");

    }
}

function settransit() { currentloc = "transit"; }
//function footDynamic() {

//}

//THIS FUNCTION HAS BEEN REMOVED IN FAVOR OF REFRESHING THE PAGE
/*function resetpta(){
$("#Ax0 .acar,#Ax0 .aplane").show().css('visibility','visible').css('display','inline').removeClass("active");

$(".startingat").hide();
var total = originaltotal;
subtractelement();
pta = 0;
};

*/

function resetpta() {
    //window.location = "index.htm";
    window.location = "/";
}


function resetcalc() {
    $('.calcvp').scrollTo($('.inputbox'), 200);
    var numplanes = $('#numplanes').val("");
    var numcars = $('#numcars').val("");
}


function scrollit(target, speed, useaxis) {
    /* if (target == "Ax5"){
    // pageTracker._trackPageview('/user_clicked_submit');
    //window.location = parent.myRefer;

    //$.post("https://www.thinkgreenmeeting.com/rlcore/manage_newuser",{ as : '1740755397', cam: '1740755397' , pageid : '19' , cont_country_id : '1' , sysSubrateid: '1' , cmd:'landing'});

    }*/

    formwrangler(target);

    //("." + currentloc + ".");
    //("." + target + ".");

    var efftarget = target;
    var effcurrentloc = currentloc;

    /*if (target == "Ax0") {
    myEl = "<a href=\"Ax5\" >" + "<img src=\"images/blank.png\" class=\" \" />" + "" + "<a/>";
    $('.footer').html(myEl);
    $('.footer').click(function () {
    alert("get free quote");
    target == "Ax3";
    if (scrollit($(this).attr("href"))) {
    $('.footer .active').removeClass("active");
    $(this).addClass("active");
    }
    })
    }

    else if (target == "Ax1") {
    myEl = "<a href=\"#\" class=\"getsamp \" >" + "<img src=\"images/blank.png\" class=\"getsample_icon\">" + "Get a Free Quote" + "<a/>";
    $('.footer').html(myEl);
    }
    else if (target == "Ax3") {
    myEl = "<a href=\"#\" >" + "<img src=\"images/blank.png\" class=\"getsample_icon\">" + "Get a Free Quote" + "<a/>";
    $('.footer').html(myEl);
       
    }
    else if (target == "Cx2") {
    myEl = "<a href=\"#\" >" + "<img src=\"images/blank.png\" class=\"getsample_icon\">" + "Get a Free Quote" + "<a/>";
    $('.footer').html(myEl);
    }
    else if (target == "Ax4") {
    myEl = "<a href=\"#\" class=\"unclickable scrollink bigscrollink\">" + "<img src=\"images/blank.png\" class=\"getsample_icon\">" + "Get a Free Quote" + "<a/>";
    $('.footer').html(myEl);
    }
    else if (target == "Ax5") {
    myEl = "<a href=\"http://dotscoms.com/index.asp \" target=\"_blank\" >" + "<img src=\"images/blank.png\" class=\"supportTicket_icon\">" + "Generate Support Ticket" + "<a/>";
    $('.footer').html(myEl);
    }
    else if (target == "Ax6") {
    myEl = "<a href=\"http://dotscoms.com/index.asp \" target=\"_blank\" >" + "<img src=\"images/blank.png\" class=\"supportTicket_icon\">" + "Generate Support Ticket" + "<a/>";
    $('.footer').html(myEl);
    }
    else if (target == "Ax7") {
    myEl = "<a href=\"#\">" + "<img src=\"images/blank.png\" class=\"testimony_icon\">" + "Testimonials" + "<a/>";

    $('.footer').html(myEl);
    }
    else if (target == "Ax8") {
    myEl = "<a href=\"#\">" + "<img src=\"images/blank.png\" class=\"testimony_icon\">" + "Testimonials" + "<a/>";

    $('.footer').html(myEl);
    }
    else if (target == "Ax9") {
    myEl = "<a href=\"#\">" + "<img src=\"images/blank.png\" class=\"testimony_icon\">" + "Testimonials" + "<a/>";
    $('.footer').html(myEl);
    }
    else {
    myEl = "<a href=\"#\">" + "<img src=\"images/blank.png\" class=\"testimony_icon\">" + "Testimonials" + "<a/>";
    $('.footer').html(myEl);
    }*/


    if (target == "Cx2") efftarget = "Cx2";
    if (currentloc == "Cx2") effcurrentloc = "Cx2";

    if (target == "Cx1") efftarget = "Cx1";
    if (currentloc == "Cx1") effcurrentloc = "Cx1";
    if (!useaxis) useaxis = "y";
    if (!speed) speed = vscrolltime * (Math.abs(coord(efftarget)['y'] - coord(effcurrentloc)['y'])); if (speed < vscrolltime) speed = 200;

    function coord(thedata) {
        var thesplit = thedata.split("x");
        var out = new Array();
        out['x'] = thesplit[0];
        out['y'] = parseFloat(thesplit[1]);
        return out;
    }

    $(".contentLayer").stop();
    $(".contentLayer").dequeue();
    $(".contentLayer").dequeue();
    $(".contentLayer").dequeue();
    $(".contentLayer").dequeue();


    if (currentloc == "transit") {
        $(".contentLayer").scrollTo($('#' + target), 400, { queue: true,
            axis: 'xy',
            easing: "jswing",
            over: { top: .5, left: .5 },
            offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
            onAfter: function () { currentloc = target }
        });

    } else if (target == currentloc) {
        //alert("target == currentloc");
        $(".contentLayer").scrollTo($('#' + currentloc), 400, { queue: true,
            axis: 'xy',
            easing: "jswing",
            over: { top: .5, left: .5 },
            offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
            onAfter: function () { currentloc = target }
        });
    }
    else if (currentloc == "Cx2") {
        settransit();
        if (target == "Cx3") {
            $(".contentLayer").scrollTo($('#Cx3'), vscrolltime,

  { queue: false,
      axis: "y",
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () { currentloc = target; }
  });

        } else {
            $(".contentLayer").scrollTo($('#Ax3'), 2 * hscrolltime,
  { queue: true,
      axis: "x",
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () {
          $(".contentLayer").scrollTo($('#' + target), speed,
  { queue: false,
      axis: 'y',
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () { currentloc = target }
  })
      }
  });
        }
    }

    else if (currentloc == "Cx3") {
        settransit();
        if (target == "Cx2") {
            $(".contentLayer").scrollTo($('#Cx2'), vscrolltime,
  { queue: false,
      axis: "y",
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () { currentloc = target; }
  });
        } else {
            $(".contentLayer").scrollTo($('#Ax2'), 2 * hscrolltime,
  { queue: false,
      axis: "x",
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () {
          $(".contentLayer").scrollTo($('#' + target), speed,
  { queue: false,
      axis: 'y',
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () { currentloc = target }
  })
      }
  });
        }


    }
    else if (target == "Cx2") {
        settransit();
        $(".contentLayer").scrollTo($('#Ax2'), speed,
  { queue: false,
      axis: "y",
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () {
          $(".contentLayer").scrollTo($('#Cx2'), 2 * hscrolltime,
  { queue: false,
      axis: 'x',
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () { currentloc = "Cx2" }
  });
      }
  });
    } else if (target == "Cx3") {
        $(".contentLayer").scrollTo($('#Ax4'), speed,
  { queue: false,
      axis: "y",
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () {
          $(".contentLayer").scrollTo($('#Cx3'), (2 * hscrolltime),
  { queue: false,
      axis: 'x',
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () { currentloc = "Cx3" }
  });
      }
  });
    } else {

        $(".contentLayer").scrollTo($('#' + target), speed,
  { queue: false,
      axis: useaxis,
      easing: "jswing",
      over: { top: .5, left: .5 },
      offset: { top: -(vpover2('h')), left: -(vpover2('w')) },
      onAfter: function () { currentloc = target; }
  });

    } // /else
    return true;
}

function adjustframe() {
    clearTimeout(thetimeout);
    thetimeout = window.setTimeout(function () {
        scrollit(currentloc, "fast", 'xy');
        movemenu();
    }, 300);
}

function movemenu() {
    width = document.documentElement.clientWidth
    height = document.documentElement.clientHeight

    left = (width - 1100) / 2 + "px";
    topx = (height - 550) / 2 + "px";

    $(".navcontainer").animate({
        left: left,
        top: topx
    });

}

/*function formatCurrency(num) {
var original = num;
num = num.toString().replace(/\$|\,/g, '');
if (isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num * 100 + 0.50000000001);
cents = num % 100;
num = Math.floor(num / 100).toString();
if (cents < 10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
num = num.substring(0, num.length - (4 * i + 3)) + ',' +
num.substring(num.length - (4 * i + 3));
if (original > 10000) {
return (((sign) ? '' : '-') + '$' + num);
} else {
return (((sign) ? '' : '-') + '$' + num + '.' + cents);
}
}*/

/*function subtractelement(type) {
if (type == 'car') {
total = total - carval;
} else if (type == 'plane') {
total = total - planeval;
} else {
total = originaltotal;
}

formattotal = formatCurrency(total);
pta++;
if (pta == 96) {
$(".startingat").fadeIn("slow");
formattotal = "<span class='darkgreen'>$9.95</span>"
}
$('.meetingequals').html("MEETING=" + formattotal);
}*/

$(document).ready(function () {

    $('.sliding')._TMS({
        prevBu: false,
        nextBu: false,
        playBu: false,
        duration: 800,
        easing: 'easeOutQuad',
        preset: 'simpleFade',
        pagination: '.pagination',
        slideshow: 5000,
        numStatus: true,
        banners: 'fromTop', // fromLeft, fromRight, fromTop, fromBottom
        waitBannerAnimation: true,
        pauseOnHover: true,
        progressBar: '<div class="progbar"></div>'
    })

    $("p.ftr1").show();
    $("p.ftr2").hide();
    $("p.ftr3").hide();
    $("p.ftr4").hide();
    $("p.ftr5").hide();
    $("p.ftr6").hide();


    $("a#dnc1").click(function (event) {
        event.preventDefault();
        $("p.ftr1").show();
        $("p.ftr2").hide();
        $("p.ftr3").hide();
        $("p.ftr4").hide();
        $("p.ftr5").hide();
        $("p.ftr6").hide();
    });
    $("a#dnc2").click(function (event) {
        event.preventDefault();
        $("p.ftr1").hide();
        $("p.ftr2").show();
        $("p.ftr3").hide();
        $("p.ftr4").hide();
        $("p.ftr5").hide();
        $("p.ftr6").hide();
    });
    $("a#dnc3").click(function (event) {
        event.preventDefault();
        $("p.ftr1").hide();
        $("p.ftr2").hide();
        $("p.ftr3").show();
        $("p.ftr4").hide();
        $("p.ftr5").hide();
        $("p.ftr6").hide();
    });
    $("a#dnc4").click(function (event) {
        event.preventDefault();
        $("p.ftr1").hide();
        $("p.ftr2").hide();
        $("p.ftr3").hide();
        $("p.ftr4").show();
        $("p.ftr5").hide();
        $("p.ftr6").hide();
    });
    $("a#dnc5").click(function (event) {
        event.preventDefault();
        $("p.ftr1").hide();
        $("p.ftr2").hide();
        $("p.ftr3").hide();
        $("p.ftr4").hide();
        $("p.ftr5").show();
        $("p.ftr6").hide();
    });
    $("a#dnc6").click(function (event) {
        event.preventDefault();
        $("p.ftr1").hide();
        $("p.ftr2").hide();
        $("p.ftr3").hide();
        $("p.ftr4").hide();
        $("p.ftr5").show();
        $("p.ftr6").hide();
    });
    $("a#dnc7").click(function (event) {
        event.preventDefault();
        $("p.ftr1").hide();
        $("p.ftr2").hide();
        $("p.ftr3").hide();
        $("p.ftr4").hide();
        $("p.ftr5").hide();
        $("p.ftr6").show();
    });
    $("a#dnc8").click(function (event) {
        event.preventDefault();
        $("p.ftr1").hide();
        $("p.ftr2").hide();
        $("p.ftr3").hide();
        $("p.ftr4").hide();
        $("p.ftr5").hide();
        $("p.ftr6").show();
    });
    $("a#dnc9").click(function (event) {
        event.preventDefault();
        $("p.ftr1").hide();
        $("p.ftr2").hide();
        $("p.ftr3").hide();
        $("p.ftr4").hide();
        $("p.ftr5").hide();
        $("p.ftr6").show();
    });

    $('.slider').bxSlider({
        pager: true,
        mode: 'horizontal', // 'horizontal', 'vertical', 'fade'
        controls: true,
        auto: true,
        speed: 1000,
        pause: 3000,
        easing: 'swing'
    });
    $('.carousel_slide').bxSlider({
        pager: false,
        mode: 'horizontal', // 'horizontal', 'vertical', 'fade'
        controls: false,
        auto: true,
        speed: 1000,
        pause: 3000,
        easing: 'swing'
    });

    /*$('.trackconversion').click(function () {
    pageTracker._trackPageview('/user_clicked_submit');

    })*/


    /* $('.j_submit').click(function () {
    $(this).parents('form:first').submit();
    });*/

    /*$.fn.clearForm = function () {
    return this.each(function () {
    var type = this.type, tag = this.tagName.toLowerCase();
    if (tag == 'form')
    return $(':input', this).clearForm();
    if (type == 'text' || type == 'password' || tag == 'textarea')
    this.value = '';
    else if (type == 'checkbox' || type == 'radio')
    this.checked = false;
    else if (tag == 'select')
    this.selectedIndex = -1;
    });
    };

    $('.j_reset').click(function () {
    $(this).parents('form:first').clearForm();
    });*/

    formwrangler();
    //var total = originaltotal;
    //subtractelement();
    //pta = 0;
    var myOpen = function (hash) { hash.w.fadeIn('fast'); hash.o.css('opacity', 0.5).fadeIn('fast'); };
    var myClose = function (hash) { hash.w.fadeOut('fast'); hash.o.css('opacity', 0.5).fadeOut('fast'); };

    $('#funfacts').jqm({ onShow: myOpen, onHide: myClose, trigger: 'a.trigger_funfacts' });
    $('#onlinerequest').jqm({ onShow: myOpen, onHide: myClose, trigger: 'a.trigger_onlinerequest' });
    $('#designformreq').jqm({ onShow: myOpen, onHide: myClose, trigger: 'a.trigger_designformreq' });
    $('#ecomformreq').jqm({ onShow: myOpen, onHide: myClose, trigger: 'a.trigger_ecomformreq' });
    $('#hostinplan').jqm({ onShow: myOpen, onHide: myClose, trigger: 'a.trigger_hostinplan' });
    $('#domainreg').jqm({ onShow: myOpen, onHide: myClose, trigger: 'a.trigger_domainreg' });
    $('#askQuest').jqm({ onShow: myOpen, onHide: myClose, trigger: 'a.trigger_askQuest' });

    adjustframe();

    resetcalc();

    window.onresize = adjustframe;

    $('.unclickable').click(function (event) {
        event.preventDefault();
    });

    $('.scrollink').click(function () {
        if (scrollit($(this).attr("href"))) {
            $('.navlist .active').removeClass("active");
            $(this).addClass("active");
        }
    });
    /*$('.remotelinknewwindow').click(function () {
    window.open('http://www.remotelink.com');
    });*/
    /*$('.calcbutton').click(function () {
    var numplanes = $('#numplanes').val();
    if (numplanes == '') numplanes = 0;
    var numcars = $('#numcars').val();
    if (numcars == '') numcars = 0;
    //alert ("cars: " + numcars + "\rplanes: " + numplanes);
    if ((numplanes == 0) && (numcars == 0)) {
    alert("Please enter a number of vehicles");
    } else if ((numplanes >= 100) && (numcars.length >= 100)) {
    alert("Too many cars or planes!");
    } else if ((parseInt(numplanes) != numplanes - 0) || (parseInt(numcars) != numcars - 0)) {
    alert("Please enter a valid number");
    } else {
    var numtrees = Math.floor((numplanes * 5) + (numcars * 1));
    var displaytrees = numtrees;
    if (numtrees > 80) displaytrees = 80;
    $('.treebox').css('width', ((displaytrees * 48) + 'px'));
    for (i = 0; i < displaytrees; i++) $('.treebox').append("<img src=\"/_img/tree100x81.gif\" class=\"atree\" />");
    $('.numtrees').html(numtrees);
    $('.tonscarbon').html(((numtrees) * (3 / 5)).toFixed(1));
    $('.calcvp').scrollTo($('.finalbox'), 1500, { margin: true, easing: 'easeOutCirc' });
    }
    });*/

    /*$(".acar").mouseover(function () {
    if ($(this).hasClass("active")) { } else {
    $(this).addClass("active");
    var int = Math.floor(Math.random() * 8)
    theeffect = effects[int];
    $(this).hide(theeffect);
    subtractelement('car');
    }
    });

    $(".aplane").mouseover(function () {
    if ($(this).hasClass("active")) { } else {
    $(this).addClass("active");
    var int = Math.floor(Math.random() * 8)
    theeffect = effects[int];
    $(this).addClass("active");
    $(this).hide(theeffect, { queue: false });
    subtractelement('plane');
    }
    });


    $('.button_free-trial').hover(function () {
    $(this).attr('src', '/_img/button_free-trial_r.png');
    }, function () {
    $(this).attr('src', '/_img/button_free-trial.png');
    });

    $('.button_get-started').hover(function () {
    $(this).attr('src', '/_img/button_get-started_r.png');
    }, function () {
    $(this).attr('src', '/_img/button_get-started.png');
    });

    $('.button_how-it-works').hover(function () {
    $(this).attr('src', '/_img/button_how-it-works_r.png');
    }, function () {
    $(this).attr('src', '/_img/button_how-it-works.png');
    });*/

});


PreImage1 = new Image(88, 31);
PreImage1.src = "\/_img\/tree100x81.gif";

var effects = new Array();
effects[0] = "scale";
effects[1] = "blind";
effects[2] = "clip";
effects[3] = "drop";
effects[4] = "explode";
effects[5] = "fold";
effects[6] = "puff";
effects[7] = "slide";


function vpover2(dim) {
    var activedim;

    switch (dim) {
        case 'w':
            activedim = document.documentElement.clientWidth;
            break;
        case 'h':
            activedim = document.documentElement.clientHeight;
            break;
    }
    return ((activedim / 2) - 1);
}

function preloadImages(imgs) {

    var picArr = [];

    for (i = 0; i < imgs.length; i++) {

        picArr[i] = new Image(100, 100);
        picArr[i].src = imgs[i];
    }
}

preloadImages(['images/dnc.gif',
		'images/window.png',
		'images/webfrm.png',
		'images/testimonial.png',
		'images/icon_domainaspx.png',
        'images/banner1.png',
        'images/banner2.png',
        'images/banner3.png',
        'images/banner4.png',
        'images/banner5.png']);
