/* js vissol */
function dropDownMenu(){this.parent=0;this.data=[];this.selector=0;this.fadetime=100;this.isCurrent=false;this.init=function(parent,data){this.parent=$(parent);if(data)this.data=data;if(this.parent.hasClass('current'))this.isCurrent=true;var self=this;$(window).resize(function(){self.setupCSS();});}
this.addUrl=function(title,href){this.data.push([title,href]);}
this.startup=function(){var output='<div id="'+this.getDropDownDivId()+'" class="dropdown-container"><ul class="dropdown-bg">';jQuery.each(this.data,function(){output+='<li><a href="'+this[1]+'">'+this[0]+'</a></li>';});output+='</ul><div class="dropdown-bottom"></div></div>';$('body').append(output);this.selector=$('#'+this.getDropDownDivId());this.setupCSS();var tmpObject=this;this.parent.hover(function(){tmpObject.show();},function(){tmpObject.hide();});this.selector.hover(function(){tmpObject.show();tmpObject.parent.addClass('hover');},function(){tmpObject.hide();if(!tmpObject.isCurrent)tmpObject.parent.removeClass('hover');});}
this.getDropDownDivId=function(){return this.parent.attr('id')+'_dropdownmenu';}
this.setupCSS=function(){this.selector.css('margin-left',this.parent.offset().left);this.hide();}
this.show=function(){if(jQuery.browser.msie&&(jQuery.browser.version<8.0)){this.selector.css('visibility','visible');return;}
this.selector.css('display','block');this.selector.stop().animate({opacity:1},this.fadetime);}
this.hide=function(){if(jQuery.browser.msie&&(jQuery.browser.version<8.0)){this.selector.css('visibility','hidden');return;}
var tmpSelector=this.selector;this.selector.stop().animate({opacity:0},this.fadetime,function(){tmpSelector.css('display','none');});}}
function countDownTimer(){this.objects={};this.endTime;this.endAction=function(){};this.init=function(endTime,elemDays,elemHours,elemMinutes,elemSeconds,endAction){if(endTime<now()){endAction();return;}
this.endTime=endTime;this.endAction=endAction;this.objects={'days':$(elemDays),'hours':$(elemHours),'minutes':$(elemMinutes),'seconds':$(elemSeconds)};var self=this;setTimeout(function(){self.tick(self)},1000);}
this.tick=function(self){var countDownAmountSeconds=self.endTime-now();if(countDownAmountSeconds<0){self.endAction();return;}
var timeValues=new this.getTimeValue(self);self.objects.days.html(''+intToTwoDigitString(timeValues.days));self.objects.hours.html(''+intToTwoDigitString(timeValues.hours));self.objects.minutes.html(''+intToTwoDigitString(timeValues.minutes));self.objects.seconds.html(''+intToTwoDigitString(timeValues.seconds));setTimeout(function(){self.tick(self)},1000);return;}
this.getTimeValue=function(self){var diff=self.endTime-now();if(diff<0)return;if(diff==0){this.days=0;this.hours=0;this.minutes=0;this.seconds=0;return;}
var day=24*60*60;var hour=60*60;var min=60;var days,hours,minutes,seconds;var rawdays,rawhours,rawminutes,rawseconds;var difference;rawdays=diff/day;days=Math.floor(rawdays);difference=rawdays-days;rawhours=(difference*day)/hour;hours=Math.floor(rawhours);difference=rawhours-hours;rawminutes=(difference*hour)/min;minutes=Math.floor(rawminutes);difference=rawminutes-minutes;rawseconds=(difference*min);seconds=Math.round(rawseconds);this.days=days;this.hours=hours;this.minutes=minutes;this.seconds=seconds;return;}}
function now(){var time=new Date();var now=time.getTime();return Math.round(now/1000);}
function intToTwoDigitString(int){if(int>99)return"99";var rnum=Math.round(int);if(rnum<10){return"0"+rnum;}else{return""+rnum;}}
var placeholderData={};function registerAndClickPlaceholder(item){item.onfocus=function(){};item.addEventListener('focus',function(){onPlaceholderPotentialClick(item);},false);item.addEventListener('blur',function(){onPlaceholderPotentialUnClick(item);},false);onPlaceholderPotentialClick(item);}
function onPlaceholderPotentialClick(item){if(item.name==''){return 1;}
if(!placeholderData[item.name]){placeholderData[item.name]={0:0,1:0};if(item.value!=0){placeholderData[item.name][0]=true;placeholderData[item.name][1]=item.value;}else{placeholderData[item.name][0]=false;return 1;}}
if(item.value==placeholderData[item.name][1]){item.value='';}
return 1;}
function onPlaceholderPotentialUnClick(item){if(item.name==''){return 1;}
if(placeholderData[item.name][0]==true){if(item.value==''){item.value=placeholderData[item.name][1];}}else{return 1;}}
function createSlideBanner(){this.container='';this.itemClass='';this.keysEnabled=true;this.currentItem=0;this.nItems=0;this.init=function(containerDiv,itemClass,keysEnabled){this.container=$(containerDiv);this.itemClass=$(itemClass);var self=this;if(keysEnabled){this.enableKeys();}
this.nItems=this.itemClass.size();this.currentItem=0;}
this.getItemWidth=function(){return this.itemClass.width();}
this.enableKeys=function(){this.keysEnabled=true;var self=this;$(window).keydown(function(e){if(e.which==37){self.goLeft();}else if(e.which==39){self.goRight();}});}
this.goLeft=function(){this.goToItem(this.currentItem-1);}
this.goRight=function(){this.goToItem(this.currentItem+1);}
this.goToItem=function(n){if(n<0){n=this.nItems-1;}
if(n>=this.nItems){n=0;}
this.container.stop().animate({'margin-left':(-1*this.getItemMargin(n))},400);this.currentItem=n;}
this.getItemMargin=function(n){return(n*this.getItemWidth());}
this.leftArrow=function(element){var self=this;$(element).click(function(){self.goLeft();});}
this.rightArrow=function(element){var self=this;$(element).click(function(){self.goRight();});}}
function createWHSwitcher(){this.navItemClass='';this.contentWrapper='';this.currentVisible=false;this.currentContentNav='';this.items=[];this.busy=false;this.init=function(contentWrapper){this.contentWrapper=$(contentWrapper);}
this.onClick=function(id){if(this.busy)return;this.busy=true;this.showContent(id);}
this.showContent=function(id){var id2=id;id=this.getContentID(id);var self=this;$(this.currentContentNav).removeClass("wh-current");if(this.currentVisible)$(this.currentVisible).fadeOut(200,function(){$(self.contentWrapper).css("margin-top",($(id).position().top*-1));$(id).fadeIn(200,function(){self.busy=false;$(id2).addClass("wh-current");});});this.currentVisible=id;this.currentContentNav=id2;}
this.getContentID=function(id){return"#wh-switcher-"+id.substr(1,id.length-1)+"-content";}
this.addItem=function(clicker,content){var self=this;$(clicker).click(function(){self.onClick(clicker);});this.items.push([clicker,content]);}}


$(window).ready(function() {

	// Dropdowns
	
	var hostingDropDown = new dropDownMenu();
	hostingDropDown.init('a#web-hosting');
	hostingDropDown.addUrl('Shared Hosting','http://speedysparrow.com/web-hosting.html');
	hostingDropDown.addUrl('Business Hosting','http://speedysparrow.com/business.html');
	hostingDropDown.addUrl('Reseller Hosting','http://speedysparrow.com/reseller.html');
	hostingDropDown.addUrl('CloudFlare Hosting','http://speedysparrow.com/cloud-flare.html');
	hostingDropDown.addUrl('Cloud VPS Hosting','http://speedysparrow.com/vps-hosting.html');
	hostingDropDown.addUrl('Hosting Glossary','http://speedysparrow.com/glossary.html');
	hostingDropDown.addUrl('Domain Registration','https://my.speedysparrow.com/domainchecker.php');
	hostingDropDown.startup();

	
	var companyDropDown = new dropDownMenu();
	companyDropDown.init('a#company');
	companyDropDown.addUrl('Latest News','https://my.speedysparrow.com/members/index.php?/News/List');
	companyDropDown.addUrl('Company/Network','http://speedysparrow.com/company.html');
	companyDropDown.addUrl('Service Guarantees','http://speedysparrow.com/guarantees.html');
	companyDropDown.addUrl('Coupons & Specials','http://forums.speedysparrow.com/index.php?/forum/6-webhosting-promotions/');
	companyDropDown.addUrl('Client Testimonials','http://speedysparrow.com/reviews.html');
	companyDropDown.addUrl('Affiliates Program','http://speedysparrow.com/affiliates.html');
    companyDropDown.addUrl('Company Blog','http://blog.speedysparrow.com');
	companyDropDown.addUrl('Community Forums','http://forums.speedysparrow.com/');
	companyDropDown.startup();
		
		
	var supportDropDown = new dropDownMenu();
	supportDropDown.init('a#support');
	supportDropDown.addUrl('Client Area','https://my.speedysparrow.com/clientarea.php');
	supportDropDown.addUrl('Support Tickets','https://my.speedysparrow.com/members/index.php?/Tickets/Submit');
	supportDropDown.addUrl('Invoices','https://my.speedysparrow.com/clientarea.php?action=invoices');
	supportDropDown.addUrl('Downloads','https://my.speedysparrow.com/members/index.php?/Knowledgebase/List/Index/23');
	supportDropDown.addUrl('Knowledgebase','https://my.speedysparrow.com/members/index.php?/Knowledgebase/List');
	supportDropDown.addUrl('Network Issues','https://my.speedysparrow.com/networkissues.php');
	supportDropDown.addUrl('Server Status','https://my.speedysparrow.com/serverstatus.php');
	supportDropDown.startup();		
  	
    
    // Selection Box
    
    $('.drizzle-sign-up').click(function() {
      $('#drizzle-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });	
    
    $('.shower-sign-up').click(function() {
      $('#shower-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });	    
    
    $('.thunder-sign-up').click(function() {
      $('#thunder-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });	    
        
    $('.lightning-sign-up').click(function() {
      $('#lightning-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });
	
    $('.close').click(function() {
      $('.bg-overlay').fadeOut('fast', function() {
        // Animation complete
      });
    });
    
    $('.stratus-sign-up').click(function() {
      $('#stratus-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });	
    
    $('.cumulus-sign-up').click(function() {
      $('#cumulus-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });	    
    
    $('.altostratus-sign-up').click(function() {
      $('#altostratus-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });	    
        
    $('.nimbus-sign-up').click(function() {
      $('#nimbus-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });
	
	$('.light-sign-up').click(function() {
      $('#light-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });
	
	$('.moderate-sign-up').click(function() {
      $('#moderate-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });
	
	$('.heavy-sign-up').click(function() {
      $('#heavy-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });
	
	$('.downpour-sign-up').click(function() {
      $('#downpour-overlay').fadeIn('fast', function() {
        // Animation complete
      });
    });
	
    $('.close').click(function() {
      $('.bg-overlay').fadeOut('fast', function() {
        // Animation complete
      });
    });
    
    
    
    
    
});
