// JavaScript Document
var popUpWin=0;

function popUpWindow(URLStr, width, height, left, top)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

function getFolderName(){
	var pathArray = window.location.pathname.split( "/" );
	var newPathname = "";
	for ( i = 0; i<pathArray.length; i++ ) {
	newPathname += "/";
	newPathname += pathArray[i];
	}
	return(pathArray[1]);	
}

function baseURL(){
	return(window.location.protocol + "//" + window.location.host + "/");
}

function isActive(s){
	var folder=getFolderName();
	if (s==folder){
		return"active";		
	}
	return"";
}


function breadcrumb(){
	var separator = "<span class=\"separator\"></span>";
	var baseWord= "home";
	var base=baseURL();
	
	
	// make the home >
	var breadcrumbs="<a href=\"" + base+ "\">"+baseWord+"</a>"+ separator;
	
	
	var pathArray = window.location.pathname.split( "/" );
	var words = "";
	for ( i = 1; i<pathArray.length; i++ ) {
		if (i<pathArray.length-1){
			words+=pathArray[i] + "/";
			breadcrumbs=breadcrumbs+"<a href=\"" + base + words + "\">"+pathArray[i]+"</a>" + separator;			
		}
	}
	
	return(breadcrumbs);
	
}

$(function(){
	$(breadcrumb()).appendTo('div.breadcrumb');
});

//chat and support
$(function(){
	$('#support a').click(function(){
		popUpWindow("https://esupport.wowrack.com/index.php",850,500,50,50);
	});
	$('div.chat-email-info a').each(function() {
	    if (this.className != 'emailus') {
			this.className = 'livechat';
		}
	});
	/*
	$('a.livechat').click(function(){
		popUpWindow('http://www.wowrack.com/phplive/request.php?l=administrator&x=1&deptid=0&pagex=http%3A//www.wowrack.com/',460,360,350,200);
	});
	*/
	$('a.emailus').click(function(){
		popUpWindow('https://esupport.wowrack.com/index.php?_m=tickets&_a=submit',850,500,50,50);
	});	

});


// JQUERY MENU
$(function(){
	var n= $('#primary-menu ul.menu >li').size();
	for (var i=0; i<n; i++ ){		
		var title = $('#primary-menu ul.menu >li:eq('+ i +')').attr("title");
		$('#primary-menu ul.menu >li:eq('+ i +')').addClass(isActive(title));
//		console.log(""+i+" "+title + " " + getFolderName());
	}

});

//JQUERY MENU PERSISTENT
$(function(){
	$('#primary-menu ul.menu li.active > ul').css('visibility','visible');		
	$('#primary-menu ul.menu li.active > ul').hide().fadeIn('normal'); 	

//	when out the menu is visible again 
    $('#primary-menu > ul').mouseleave(function(e){	   
		$('#primary-menu ul.menu li.active > ul').css('visibility','visible').hide().fadeIn();	
	});

	
	$('#primary-menu ul.menu > li').mouseover(function(){	
		$('#primary-menu ul.menu li.active > ul').css('visibility','hidden');	
	});
	
	$('#primary-menu ul.menu > li.active').mouseover(function(){	
		$('#primary-menu ul.menu li.active > ul').css('visibility','visible');	
	});
	
	
	
});




$(function() {
	$('div.main-banner').cycle({ 
		fx:      'scrollDown', 
		timeout: 7000,
		pause: 1
	});
})

$(function() {
	var phone='<div id="c-hover-phone" class="tiny-font">';
	phone+="<div class='span-1-7'>Toll Free:<br/>Within U.S:<br/>International:<br/>Fax:</div>";
	phone+="<div class='span-2-5 last'><strong>1.866.883.8808<br/>206.522.4402<br/>+001.206.522.4402<br/>1.866.969.8878</strong></div>";
	var email='<div id="c-hover-email" class="tiny-font">';
	email+='<div class="span-2">Sales:<br/>24/7 Support:<br/>Billing:<br/>Abuse:<br/>NOC:</div>';
	email+='<div class="span-2-5 last">';
	email+='<a href="mailto:sales@wowrack.com">sales@wowrack.com</a><br/>';
	email+='<a href="mailto:support@wowrack.com">support@wowrack.com</a><br/>';
	email+='<a href="mailto:billing@wowrack.com">billing@wowrack.com</a><br/>';
	email+='<a href="mailto:abuse@wowrack.com">support@wowrack.com</a><br/>';
	email+='<a href="mailto:noc@wowrack.com">noc@wowrack.com</a><br/>';
	email+='</div></div>';	
	var address='<div id="c-hover-address" class="tiny-font">';
	address+='<strong>2001 6th Ave<br/>Suite 2008<br/>Seattle, WA 98121<br/>United States of America</strong>';
	address+='</div>';	
	var facebook='<div id="c-hover-facebook" class="tiny-font"><strong>Wowrack Community on Facebook</strong></div>';
	var twitter='<div id="c-hover-twitter" class="tiny-font"><strong>Follow Wowrack on Twitter</strong></div>';
	
	$('.contact-btn a.phone-btn').hover(function(){
		$(phone).appendTo($(this)).hide().slideDown();		
	}, function(){
		$('#c-hover-phone').remove();
	})
	$('.contact-btn a.email-btn').hover(function(){
		$(email).appendTo($(this)).hide().slideDown();		
	}, function(){
		$('#c-hover-email').remove();
	})
	$('.contact-btn a.address-btn').hover(function(){
		$(address).appendTo($(this)).hide().slideDown();		
	}, function(){
		$('#c-hover-address').remove();
	})
	$('.contact-btn a.facebook-btn').hover(function(){
		$(facebook).appendTo($(this)).hide().slideDown();		
	}, function(){
		$('#c-hover-facebook').remove();
	})
	$('.contact-btn a.twitter-btn').hover(function(){
		$(twitter).appendTo($(this)).hide().slideDown();		
	}, function(){
		$('#c-hover-twitter').remove();
	})	
})
$(function() {
	var hint='<div id="c-hover-hint" class="tiny-font">';
	hint+="<div><h4 style='margin-top:0;'>Virtual or Reseller Hosting</h4>Please enter your primary domain name (e.g: domain.com) that you used when you placed your initial order.<br/>";
	hint+="<h4>Dedicated or Colocation Hosting</h4>Please include your main IP Address for your equipment in order to prevent confusion on server cancellation.</div>";
	$('#hint').hover(function(){
	$(hint).appendTo($(this)).hide().show();			
	}, function(){
		$('#c-hover-hint').remove();
	})	
})
$(function() {
   $('a.tooltip').hover(function(){
	 var title=$(this).attr("title");
	 $(this).data("tooltipTitle", title);
	 var content='<div id="tooltip-text">'+title+'</div>';
	 $(content).appendTo($(this)).hide().show();
	 $(this).removeAttr("title");
   }, function(){
	 $("#tooltip-text").remove();  
	 $(this).attr("title",$(this).data("tooltipTitle"));
   });
   
})

