/* #############################################################################
Javascript WebFusion US Presales
################################################################################
 All JS in this file by:
 Karol.Kowalski@webfusion.com
 Aug 2008 onwards ...
 (c)2008 GX Networks
--------------------------------------------------------------------------------
 Notes: none
--------------------------------------------------------------------------------
 Dependancies:
 jQuery 1.2.6
 jQuery color animations by JResig http://plugins.jquery.com/project/color
 ############################################################################# */
 
var WF = {};

WF.Presales = {
	HQ:{}, //decision making
	UI:{}, //UI
	CONF:{}, //config
	API:{}, //API
	DATA:{}, //data
	UTILS:{}, //common functions
	OO:{}, //prototypes
	PROM:{} //js for promotions - don't live long
};

//shortcuts
WF.P=WF.Presales;

WF.A=WF.P.HQ;
WF.D=WF.P.DATA;
WF.C=WF.P.CONF;
WF.API=WF.P.API;
WF.F=WF.P.UTILS;
WF.UI=WF.P.UI;
WF.OO=WF.P.OO;
WF.PROM=WF.P.PROM;

WF.A.handleAction =						function(p) {
										
												switch (p.status) {
												
													case 'connectionerror':
														UI.showMessage({text:"There was a connection problem and we couldn't check for available domains. Please try again."});
											
												};
										
										};

WF.C.API = 								{
												
											geoLocate:{
											
																request: {
																	
																	"version":1.1,
																	"method" : "get_country_for_ip_address",
																	"params" : {
																		
																		"client" : {
																				"username" : "webfusion-us"
																					}/*,
																		
																		"ip_address": ''*/
																
																				}
																		}
																,
																url:"/api/order"
																}
											,
											type: "POST"
											
										};

//constructor for all API calls
//that is a modified version of the orderprocess constructor
//FIXME - make them the same
WF.API.Call =								function (p) {
				
											return function () {
														
													//cache request layout
													var _rl = p.requestLayout;
													//make a shallow copy
													var _r = $.extend({}, _rl.request);
													//make arguments available
													var _a = arguments;
														
													//last minute changes to request
													if (p.beforeAction) {
															p.beforeAction(_r,_a);
													}
														
													var config = {
														
														type	:	WF.C.API.type,
														url		:	_rl.url,
														data	:	F.toJSONString(_r),
														cache	:	false,
														success :	p.successAction,
														error	:	null
													};
														
													var send = function () {
														$.ajax(config);
													};
														
													send();
														
													if (p.returnThis) {
														return p.returnThis(_r);
													}
														
												};
													
											};

WF.API.getCountry =		 					WF.API.Call({
												  	requestLayout	:	WF.C.API.geoLocate,
													beforeAction	:	function(_r,_a) {
																			if (_a.length) {
																				_r.params.ip_address = _a[0];
																			}
																		},
												  	successAction	:	function(response) {
																		
																		alert(response);
																		
																		}
											});



//prototype of a function that clears input fields on focus
WF.OO.clearOnFocus =				function (params) {
					
										return function () {
											
											$(params.selector).
												find(':text').
													focus(function () {
																var _t = $(this);
																if (_t.val().indexOf(params.defaultWord)>=0) {_t.val(params.newContent)}
																						
																if ($.browser.msie) {
																						
																	var range= _t.get(0).createTextRange();
																	range.collapse(false);
																	range.select();
																																												
																	}
																						
																return false;
																						
																});
										};
			
									};

WF.F.rewriteDomainSearchToAjax =	function () {
										$('.f_domain').attr('method', 'get').each(function (i, val) {
											var form = $(this);
											var input = $('<input type="hidden" name="ajax_enabled" value="true" />');
											form.append(input)
										});
									};


WF.F.initCounter =					function () {
										
										var saved_start = +WF.F.readCookie('ui_counter');
										
										WF.F.count	({
											   			//start:+$('#howmany').text().replace(/,/g,''),
														//on the writing date timestamp in days (/86400000)
														//was 14161
														//add 400 everyday - number calculated by 10 years in business/ the number of registerd domains so far
						
														start:	saved_start
																?
																saved_start
																:
																(1395944 + 
																393 * (Math.round(+new Date()/86400000) - 14161)),
														end:	1874320,
									            		selector:'#howmany',
									            		format:	WF.F.formatThousands
            										});
										

									};
									


WF.F.count =						function (params) {
										
										var count = params.count||(params.start);
										var end = params.end||Infinity;
										var tick = params.tick||1000;
										var count_display;
										
										if (count < end) {
										
											count++;
											
											params.format?(count_display=params.format(count)):count_display=count+'';
											
											$(params.selector).text(count_display);
										
											var _i = setTimeout(function () {
																	   
																	   WF.F.count({	start:params.start,
																					end:end,
																					count:count,
																					tick:tick,
																					selector:params.selector,
																					timeout:_i,
																					format:params.format
																				  });
																	  
																	   }, tick);
											
											if (!(count%3)) {
												WF.F.createCookie('ui_counter', count, 1, location.hostname);
											}
											
										}

									};
									
WF.F.formatThousands = 				function (nr) {
									
										var _nr=nr+'';
										//chop of the first 1 character (this may change)
										var chopOff = 1;
										var nr_s = _nr.substr(0,chopOff);
										var nr_e = _nr.substr(chopOff);
										
										//add commas
										nr_e = nr_e.replace(/(\d{3})/g, ",$1");
										
										return nr_s+nr_e;								
									};
									
WF.F.toObject =						function(str_JSON) {
												
												if (typeof(str_JSON) == "string" && str_JSON.indexOf('{')==0 && str_JSON.lastIndexOf('}')==str_JSON.length-1) {
													return eval('(' + str_JSON + ')');
												}else if(typeof(str_JSON) != "string"){
													return str_JSON;
												}
												else {
													var e={error:1};
													return e;
												}
	
									};
									
//cookie functions from qirksmode.com
WF.F.createCookie =					function(name,value,days,domain) {
										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=/;domain="+domain;
									};

WF.F.readCookie =					function (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;
									};

WF.F.eraseCookie =					function(name) {
										WF.F.createCookie(name,"",-1);
									};

WF.F.validate_contact_form = 		function(){
										$('#contact_form').submit(function(){
												
												
												$('#contact_form .req').css('background-color','white');
												var err = 0;
												
												$('#contact_form .req').each(function(){
													if($(this).val()=='') {
														err++;
														$(this).css('background-color','#ebd3e2');
														
													}
												});
                                                                                                if(!$("#contact_form [name=email]").val().match(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/)){
                                                                                                    err++;
                                                                                                    $("#contact_form [name=email]").css('background-color','#ebd3e2');
                                                                                                }
												
												if (!err) {
													return true;
												}
												
												else {
													//WF.UI.showMessage({ text:'No ha rellenado todos los campos obligatorios marcados con *  Compruebe y vuelva a intentarlo'});
													return false;
												}
																		   
												});
										
									};
									





WF.UI.isModalOn =					false;
WF.UI.active_modal_components = 	[];
WF.UI.components =					{};

//this function is only called when the user uses IE6
WF.UI.fixIE6Bugs =					function () {
										
										//first of all IE will need an extension for jQuery fixing pngs
										
										(function($) {

											/**
											 * helper variables and function
											 */
											$.ifixpng = function(customPixel) {
												$.ifixpng.pixel = customPixel;
											};
											
											$.ifixpng.getPixel = function() {
												return $.ifixpng.pixel || '/library/images/theme/px.gif';
											};
											
											var hack = {
												ltie7  : $.browser.msie && $.browser.version < 7,
												filter : function(src) {
													return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";
												}
											};
											
											/**
											 * Applies ie png hack to selected dom elements
											 *
											 * $('img[@src$=.png]').ifixpng();
											 * @desc apply hack to all images with png extensions
											 *
											 * $('#panel, img[@src$=.png]').ifixpng();
											 * @desc apply hack to element #panel and all images with png extensions
											 *
											 * @name ifixpng
											 */
											 
											$.fn.ifixpng = hack.ltie7 ? function() {
												return this.each(function() {
													var $$ = $(this);
													var base = $('base').attr('href'); // need to use this in case you are using rewriting urls
													if ($$.is('img')) { // hack image tags present in dom
														if ($$.attr('src')) {
															if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { // make sure it is png image
																// use source tag value if set 
																var source = (base && $$.attr('src').substring(0,1)!='/') ? base + $$.attr('src') : $$.attr('src');
																// apply filter
																$$.css({filter:hack.filter(source), width:$$.width(), height:$$.height()})
																  .attr({src:$.ifixpng.getPixel()});
															}
														}
													}
												});
											} : function() { return this; };
										
										})(jQuery);
										
										//apply the hack
										$('img[@src$=.png]').ifixpng();

										
										/* rewriten to jQuery syntax, because IE7 shown js errors */
										
										$('#left_col_bg').height($('#body').height());
										$('.column.double').css('background-color','transparent');

										
									};

WF.UI.featuresTooltips =			function () {
	
										var tooltipsLinks = 'a.show_hint, input.show_hint',
										timeout;
										
										$(tooltipsLinks).
									
											mouseover(function () {
														
														clearTimeout(timeout);
														
														if ($('.triggerred').length) {
															
															$('.triggerred').remove();
															return false;
														
														}
														
														var _t=$(this),
														_title = $.data(_t.get(0),'ttl');
										
														var  _o=_t.offset(),
															_parent=$('#root'),
															_Po=_parent.offset(),
															_timestamp=new Date().getTime(),
															_tooltip=$(	'<div class="tooltip">'+
																	   		'<div class="tooltip_header"></div>'+
																				'<div class="tooltip_content">'+
																					'<div class="tooltip_gradient">'+
																						_title+
																					'</div>'+
																				'</div>'+
																			'<div class="tooltip_footer"></div>'+
																		'</div>').
														css('top', _o.top-_Po.top+_t.height()/2+10+'px').
														css('left', _o.left-_Po.left+_t.width()/2-22+'px').
														attr('id', _timestamp);
									
														//get the mouse coords
														//update when table expands
														$.data(_t.get(0),'tooltip',_timestamp);
														
														if (!arguments[1]) {
															timeout=setTimeout(function () {
																					_parent.append(_tooltip).find('#'+_timestamp);
																				}, 500);
														}
														
														else if(arguments[1]==='trigger') {
															_tooltip.addClass('hidden').addClass('triggerred').appendTo(_parent).show('slow');
														}
														
														return false;
														
														}).
									
											mouseout(function () {
														clearTimeout(timeout);
														var _t=$(this),
														_title = $.data(_t.get(0),'ttl'),
														_tooltip = '#'+$.data(_t.get(0),'tooltip');
									
														$(_tooltip).remove();
														}).
														each (function () {
														var _t=$(this);
														$.data(_t.get(0),'ttl',_t.attr('title'));
														_t.removeAttr('title');
														});
	
										};
										
WF.UI.clearDefaultDomainName = 			WF.OO.clearOnFocus(	{
														   	selector	: '.f_domain',
															defaultWord : 'yourdomain.com',
															newContent	: 'www.'
														   	});

WF.UI.clearLogin =			 			WF.OO.clearOnFocus(	{
														   	selector	: '#login_form',
															defaultWord : 'Your login name',
															newContent	: ''
														   	});

WF.UI.showTooltipAfterDelay = 			function (params) {
												
												//triggers mouseover to use tooltips function
												var st = setTimeout (	function () {
																			   $('.i_domain.show_hint').trigger('mouseover','trigger');
																		}, params.delay||5000);
										};

/* overlay components */

WF.UI.prepareOverlay = 					function(c) {
											
											var c = c || {type:'default'},
												o;
											
											if (c.type === 'wide') {
												
												o = WF.UI.components.wide_overlay =			{};
												
												o.overlay =	$('<div id="trans_back" class="trans_back_wide hidden"></div>').appendTo('body');
												o.overlay.selector = '.trans_back_wide';
												o.header =	"Oops - there was a problem.";
												o.cancel =	"Okay";
												o.close =	"Close";
												o.msgbox =	$(	
																			
																				'<div id="overlay_wide_wrap" class="hidden">'+
																					'<div id="msgbox"  class="msgbox"></div>'+
																				'</div>'
																			
																			).insertAfter(o.overlay);
																			
												o.msgbox.selector = '#overlay_wide_wrap';
											
												if ($.browser.opera) {o.msgbox}
											
											}
											
											else {
														
												o = WF.UI.components.Overlay =			{};
												o.overlay =	$('<div id="trans_back" class="trans_back hidden"></div>').appendTo('body');
												o.overlay.selector = '.trans_back';
												o.header =	"Oops - there was a problem.";
												o.cancel =	"Okay";
												o.close =	"Close";
												o.msgbox =	$(	
																			
																				'<div id="overlay_wrap" class="hidden">'+
																					'<div id="msgbox" class="msgbox"></div>'+
																				'</div>'
																			
																			).insertAfter(o.overlay);
																			
												o.msgbox.selector = '#overlay_wrap';
											
												if ($.browser.opera) {o.msgbox}
											
											}
										
										};
										
WF.UI.showOverlay =						function (c) {
			
											var contentHeight=$('body').height();
											var oo = WF.UI.components.Overlay;
											var c = c || {type:'default'};
											
											if (c.type==='wide') {
												oo = WF.UI.components.wide_overlay;
											}
											
											var o = oo.overlay;
												o.
												removeClass('hidden').
													height(contentHeight).
														fadeTo(100,0.7);
			
											//if that's IE six we need to hide selects as well
											if ($.browser.msie && parseInt($.browser.version,10)<7) {$('select').css('visibility','hidden')}
													
										};

WF.UI.showMessage =						function (p,c) {
											
											var o = WF.UI.components.Overlay;
											var c = c || {type:'default'};
											
											if (c.type==='wide') {
												o = WF.UI.components.wide_overlay;
											}
											
											//lazyload
											if (!o) {
												WF.UI.prepareOverlay({type:c.type});
												var o = WF.UI.components.Overlay;
												if (c.type==='wide') {
													o = WF.UI.components.wide_overlay;
												}												
											}
																				
											//if modal dialog isn't already on
											if (!WF.UI.isModalOn) {
													
												WF.UI.isModalOn = true;
												WF.UI.active_modal_components.push(o.overlay.selector,o.msgbox.selector);
												
												WF.UI.showOverlay({type:c.type});
												
												//set dimensions and position
												o.msgbox.removeClass('hidden').
															
														css('top', (WF.UI.getWindowSize().height/2)-(o.msgbox.height()/2)+'px').
															
														css('left', o.overlay.width()/2-o.msgbox.width()/2).
														fadeTo(100,1);
												
												o.msgbox.find('.msgbox').html(	"<h3>"+(p.header||o.header)+"</h3>"+
																	"<p>"+
																		p.text+
																		"<br>"+
																		"<a id=\"msg_close\" href=\"javascript:WF.UI.cancelMessage()\">"+
																			"<span>"+o.close+"</span>"+
																		"</a>"+
																		"</p>");
												
											}
										};

//http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
WF.UI.getWindowSize = 					function () {

											var width = 0, height = 0, w = window, d = document;
										
											if (typeof( w.innerWidth ) == 'number' ) {
												//Non-IE
												width = w.innerWidth;
												height = w.innerHeight;
											}
											
											else {	
												
												if( d.documentElement && ( d.documentElement.clientWidth || d.documentElement.clientHeight ) ) {
												//IE 6+ in 'standards compliant mode'
												width = d.documentElement.clientWidth;
												height = d.documentElement.clientHeight;
												}
												
												else {
													
													if ( d.body && ( d.body.clientWidth || d.body.clientHeight ) ) {
													//IE 4 compatible
													width = d.body.clientWidth;
													height = d.body.clientHeight;
											  		}
												
												}
											}
											
											return {width:width, height:height};
										};

WF.UI.cancelMessage =					function () {
											
											
											var s = $(WF.UI.active_modal_components.join(','));

											s.
												fadeTo('fast',0, function() {
																				
																	s.addClass('hidden');
																		
																	//fix selects in IE6
																	if ($.browser.msie && parseInt($.browser.version,10)<7) {
																		$('select').css('visibility','visible');
																	}
												
																	WF.UI.isModalOn = false;
																	WF.UI.active_modal_components = [];
										
																	});
										};

WF.UI.Slideshow = 						function () {
	
											var slides = $('#slides li'),
												w = $('#slides li:first').width(),
												i = 0,
												mode = 'left',
												sI; //interval handle
											
											//create pointer
											$('<div id="pointer"></div>').appendTo('#slideshow').css('width','15px').css('height', '15px').css('background-color', 'green').css('position','absolute').css('top', '188px').css('left', '54px');
											
											//create frames
											$('<div id="slides_pointer"></div>').css('position','absolute').appendTo('#slideshow').css('top', '188px').css('left', '54px');
											
											
											//set slides in their initial position
											slides.each(function(i,val) {
												$(val).css('left', (i*w)+'px');
												
												//create tiny frames
												$('<div></div>').css('border', '3px solid #FFF').css('width','9px').css('height', '9px').css('float','left').appendTo('#slides_pointer');
											});
											
											
										
											
											function slide() {
												
												var delay = 5000;
												
												slides.each(function(i,val) {
																
																function getLeft() {
																	return parseInt($(val).css('left'),10);
																}
																
																
																
																if (i===0) {
																
																	if (getLeft()===0) {
																		mode = 'left';
																	}
																	
																	else {if (getLeft()===(slides.length-1)*w*-1) {
																		mode = 'right';
																	}}
																	
																	if (getLeft()===-w) {
																		delay*=3;
																	}
																
																}

																var newLeft = getLeft() + (mode==='right' ? w : (-w)) + 'px';
																var pointNewLeft = parseInt($('#pointer').css('left'),10) + (mode==='right' ? (-15) : 15) + 'px';
																
																
																$('#pointer').animate({left:pointNewLeft});
																$(val).animate({left:newLeft});
																
																
																});
																
																startSliding(delay);
																
											};
											
											function startSliding(delay) {
												var d = delay || 5000;
												sI = setTimeout(slide,d);
											};
											
											startSliding(15000);
											
											$('#slides').
													
													mouseover(
														function () {
															clearTimeout(sI);
															$(this).css('outline','1px solid #A59');
															$("#pointer").css('background-color', '#A59');
															//$("#pointer").animate({'background-color':'#FFF', height:'200px', width:'200px'}, function () {$(this).text('click it baby!')});
															}
													).
													
													mouseout(
														function () {
															startSliding();
															$(this).css('outline','none');
															$("#pointer").css('background-color', 'green');
														}
													);
	
										};
										
//WF.UI.state.new_win = window.open(strURL, "newWin", strOptions);
/*WF.UI.popmeup = function(strURL, strType, strHeight, strWidth) {
	function closeWin() { if (UI.state.new_win && UI.state.new_win != null) { if (!UI.state.new_win.closed) { UI.state.new_win.close();delete UI.state.new_win } } }
	//closeWin();
	var strOptions = "";
	if (strType == "console") { strOptions = "resizable,height=" + strHeight + ",width=" + strWidth; }
	if (strType == "fixed") { strOptions = "status,height=" + strHeight + ",width=" + strWidth; }
	if (strType == "elastic") { strOptions = "scrollbars,resizable,height=" + strHeight + ",width=" + strWidth; }
	UI.state.new_win = window.open(strURL, "newWin", strOptions);
	UI.state.new_win.focus();
	return false;
};*/



WF.UI.popUp = function (strURL, strType, strHeight, strWidth) {
	var newWin = null;

function closeWin(){

            if (newWin != null){

                        if(!newWin.closed)

                                    newWin.close();

            }

};


	var strOptions = "";
	if (strType == "console") { strOptions = "resizable,height=" + strHeight + ",width=" + strWidth; }
	if (strType == "fixed") { strOptions = "status,height=" + strHeight + ",width=" + strWidth; }
	if (strType == "elastic") { strOptions = "scrollbars,resizable,height=" + strHeight + ",width=" + strWidth; }
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();

	return false;
};

										
										
										
/* promo functions */

WF.PROM.makeGuruIconPullFace = 		function() {
										
											//if we are on a page with hosting comparizon
											if ( $('#hosting_compare').length ) {
												
												//cache guru node
												var gn = $('#hosting_compare #guru_icon');
												//old icon src
												var oi = gn.css('background-image');
												//new icon src
												var ni = oi.replace('icon_guru.png','icon_guru_tongue.gif');
												
												//preload
												(new Image()).src = ni.replace('url(','').replace(')','');
												
												//show on mouseover
												$('#hosting_compare th.last, #hosting_compare td.last').
													mouseover(function () {gn.css('background-image',ni)}).
													mouseout(function () {gn.css('background-image',oi)});
												
											}
										
										
										};
										
WF.F.rememberMe = 		function() {
											WF.F.createCookie('WF_login_name_remember', $('#login_name').val(), 3650, location.hostname);
										};						
WF.F.notRememberMe =		function() {
											WF.F.createCookie('WF_login_name_remember', '', -1, location.hostname);
										};	

WF.F.loadLoginName =  		function() {
											if (WF.F.readCookie('WF_login_name_remember') == "") {
											  	WF.UI.clearLogin();
											  	$('#remember').attr('checked', false);
									  		} else {
												$('#login_name').val(WF.F.readCookie('WF_login_name_remember'));
												$('#remember').attr('checked', true);
											}

								    		};
											

WF.UI.clic = function(){
	
	$('#us_promo_tel a#pop').click(function () {

	return WF.UI.popmeup(this.href,'elastic',450,575);

});
	
};




WF.UI.expandHostingFeatures =
			function () {
				var url = window.location.href;
				var url_s = url.split('#');
				var hide_more = true;
				
				if (url_s.length == 2) {
					if (url_s[1] == "show-all") {
						hide_more = false;
					}
				}
				if (hide_more) {
					jQuery("#hidden_features").hide();
					jQuery("#show_hidden_features > .button_content").html("Show more");
				}
				jQuery("#show_hidden_features").show();
                jQuery("#show_hidden_features").toggle(
					function () {
						if (jQuery("#hidden_features").is(":hidden")) {
							jQuery("#show_hidden_features > .button_content").html("Show less");
							//jQuery("#hidden_features").slideDown("slow");
							jQuery("#hidden_features").show();
						} else {
							jQuery("#show_hidden_features > .button_content").html("Show more");
							//jQuery("#hidden_features").slideUp("slow");
							jQuery("#hidden_features").hide();
						}
					},
					function () {
						if (jQuery("#hidden_features").is(":hidden")) {
							jQuery("#show_hidden_features > .button_content").html("Show less");
							//jQuery("#hidden_features").slideDown("slow");
							jQuery("#hidden_features").show();
						} else {
							jQuery("#show_hidden_features > .button_content").html("Show more");
							//jQuery("#hidden_features").slideUp("slow");
							jQuery("#hidden_features").hide();
						}
					}
				);
			};
			
WF.UI.expandDomainList =
			function () {

                jQuery(".domains_sidebar .show_more").click(
					function () {
						var id = jQuery(this).attr("rel");
						var action = "expand";
						if (jQuery(this).hasClass("clicked")) {
							action = "collapse";
						}
						switch(action)
						{
							case "expand":
								if (jQuery(".domains_sidebar .show_more").hasClass("clicked")) {
									var id2 = jQuery(".domains_sidebar .clicked").removeClass("clicked").html("Show more domains").attr("rel");
									jQuery(".domains_sidebar ul#" + id2 + "").slideUp("slow");
								}
								jQuery(this).html("Show less domains").addClass("clicked");
								jQuery(".domains_sidebar ul#" + id + "").slideDown("slow");
							break;
							
							case "collapse":
								jQuery(this).html("Show more domains").removeClass("clicked");
								jQuery(".domains_sidebar ul#" + id + "").slideUp("slow");
							break;
						
							default:
								alert("default");
						}
						return false;
					}
				);
			};
WF.UI.showBlackWindow =
			function () {
				jQuery(".showBlackWindow").click(
					function () {
						var id = jQuery(this).attr("alt");
						var _t=$(this),
							_o=_t.offset(),
							_h=_t.height(),
							_w=_t.width(),
							_parent=$('#root'),
							_po=_parent.offset();
							_blackWindow=jQuery("#"+id);
							_bw=_blackWindow.width();
						_blackWindow.css("top", _o.top-_po.top-(_h/2)).css("left", _o.left-_po.left+(_w/2)-(_bw/2)).fadeIn();
						return false;
					});
			};
WF.UI.closeBlackWindow =
			function () {
				jQuery(".closeBlackWindow").click(
					function () {
						jQuery(this).parents(".tr_overlay").fadeOut();
						return false;
					});
			};
WF.UI.fancySelect =
			function () {
				jQuery(".o_domain").change(
					function () {
						var _ext = jQuery(this).val();
						jQuery("#span_domain_ext").html("."+_ext);
					});
			};
			
	
WF.UI.bannerRotator =
			function () {
				jQuery("#domains-banner").addClass("hidden");
				var slide_interval = 5000;
				var timer = setInterval('WF.UI.swapBanners()', slide_interval);
				$('#banner').hover(function(){
					clearInterval(timer)
				},function(){
					timer = setInterval('WF.UI.swapBanners()', slide_interval); 
				});
			};
WF.UI.swapBanners =
			function () {
				if(jQuery("#hosting-banner").is(":visible")) {
					jQuery("#hosting-banner").fadeOut(200);
					jQuery("#domains-banner").fadeIn(700);
				} else if(jQuery("#domains-banner").is(":visible")) {
							jQuery("#domains-banner").fadeOut(200);
							jQuery("#hosting-banner").fadeIn(700);
				}
			};



//main init, on DOM ready
$(document).ready(function() {
	
	if($.browser.msie && $.browser.version.indexOf('6')>=0) {
		WF.UI.fixIE6Bugs();
	}
	
	WF.F.initCounter();
	WF.F.rewriteDomainSearchToAjax();
	WF.UI.featuresTooltips();
	WF.UI.clearDefaultDomainName();
	//WF.UI.clearLogin();
	if (WF.F.readCookie('WF_login_name_remember')) {
		WF.F.loadLoginName();
	} else {
		WF.UI.clearLogin();
	}
	
	//WF.UI.showTooltipAfterDelay({delay:5000});
	WF.UI.Slideshow();
	
	WF.PROM.makeGuruIconPullFace();
	WF.F.validate_contact_form();
	//WF.UI.popUp();
	
	
	WF.UI.expandHostingFeatures();
	WF.UI.expandDomainList();
	WF.UI.showBlackWindow();
	WF.UI.closeBlackWindow();
	WF.UI.fancySelect();
	WF.UI.bannerRotator();
	

	
});

