// JavaScript Document

<!--
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showWebmail() {
	//new Effect.SlideUp('accountform', {queue: 'front'});
	//new Effect.SlideDown('webmailform',{queue: 'end'});
	document.getElementById("SignOn").style.display = 'none';
	document.getElementById("webmailForm").style.display = 'block';
	document.getElementById("lhsFormHolder").style.backgroundImage = "url('/images/bg/webmail_form_bg.png')";
}

function showAccount() {
	//new Effect.SlideUp('webmailform',{queue: 'front'});
	//new Effect.SlideDown('accountform',{queue: 'end'});
	document.getElementById("SignOn").style.display = 'block';
	document.getElementById("lhsFormHolder").style.backgroundImage = "url('/images/bg/myaccount_form_bg.png')";
	document.getElementById("webmailForm").style.display = 'none';
}

NS4 = (document.layers) ? true : false;

function checkEnter(event)
{     
	var code = 0;
	
	if (NS4)
		code = event.which;
	else
		code = event.keyCode;
	if (code==13)
		submitTopForm();
}


function mainmenu(){
	$(" #inlineMenu ul ").css({display: "none"}); // Opera Fix
	$(" #inlineMenu li").hover(function(){
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(500);
        },function(){
        	$(this).find('ul:first').css({visibility: "hidden"});
        });
}

$(document).ready(function(){
		mainmenu();
});


jQuery(document).ready(function () {
								 
		
		var login_box = jQuery('#webmailDiv');
		var login_button = jQuery('.webmailLink');
		var login_button_text = login_button.html();
		var account_box = jQuery('#myAccountDiv');
		var account_button = jQuery('.myAccountLink');
		var account_button_text = account_button.html();
		
		jQuery('.webmailLink').bind('click', function (e) {
				e.preventDefault();
				
				if (account_box.css('display') == 'block') {
					account_box.hide(1, function () {
							
							
					});  
				}
				
				//login_button.addClass('login-button-alternative');
				if (login_box.css('display') == 'none') {
					login_box.show(1, function () {
				/*login_box.bind('mouseleave', function() {
											setTimeout( function()
									 {
										 login_box.fadeOut('slow');
										 }, 4000);
											});*/
				});
					}

				else {
					login_box.hide(1, function () {
							//login_button.removeClass('login-button-alternative');
							/*login_box.bind('mouseleave', function() {
											setTimeout( function()
									 {
										login_box.fadeOut('slow');
										 }, 4000);
											});*/
					});
				}
		});
		
		
		jQuery('.myAccountLink').bind('click', function (e) {
				e.preventDefault();
				
				if (login_box.css('display') == 'block') {
					login_box.hide(1, function () {
												
												
					});
				}
				
				//account_button.addClass('login-button-alternative');
				if (account_box.css('display') == 'none') {
					account_box.show(1, function () {
							//login_button.removeClass('login-button-alternative');
							/* account_box.bind('mouseleave', function() {
											setTimeout( function()
									 {
										 account_box.fadeOut('slow');
										 }, 4000);
											});*/
							
					});
				}
				
				else {
					account_box.hide(1, function () {
							//account_button.removeClass('login-button-alternative');
							/* account_box.bind('mouseleave', function() {
											setTimeout( function()
									 {
										 account_box.fadeOut('slow');
										 }, 4000);
											}); */
							});
				}
		});
		
		
});

$(document).ready(function(){
		$('#form1, #noChecker, #landing_form').formValidation({
				alias        : 'id'
				,required    : 'accept'
				,err_list    :    true
				,callback    : 'callback'
		});
});

function callback() {
	//return confirm("Click Submit to complete the process");
	return true;
}


function addInputSubmitEvent(form, input) {
	input.onkeydown = function(e) {
		e = e || window.event;
		if (e.keyCode == 13) {
			form.submit();
			return false;
		}
	};
}

window.onload = function() {
	
	var form1 = document.getElementById('webmailForm');
	var form2 = document.getElementById('SignOn');
	var input1 = form1.getElementsByTagName('input');
	var input2 = form2.getElementsByTagName('input');
	
	for (var i=0;i < input1.length;i++)
		addInputSubmitEvent(form1, input1[i]);
	
	for (var j=0;j < input2.length;j++)
		addInputSubmitEvent(form2, input2[j]);
};

//Google search field branding
function inputFocus() {
        document.getElementById('query-input').style['background'] = '';
}

function inputBlur() {
        var queryInput = document.getElementById('query-input');
        if (!queryInput.value) {
            queryInput.style['background'] = 'white url(http://www.google.com/coop/images/google_custom_search_watermark.gif) no-repeat 0% 50%';
        }
}

// eo google search branding


// orbit focus code

$(function() {
 
	$('.lrgSignUpButton, .coolFormButton').click(function() {
 
		$('#inlineNoCheckerHolder').expose();
		$('#inlineNoCheckerHolder').css('border', '2px outset #efefef');
		$('#area_code').focus();
 
	});
});



//Portal code

function buildModule(moduleName){
	var opt = {
		// Use POST
		method: 'post',
		// Send this lovely data
		postBody: "",
		// Handle successful response
		onSuccess: function(t) {
			moduleHtml = t.responseText;
			moduleHtml = moduleHtml.replace(/XXX_/g,'');
			$(moduleName +'_container').innerHTML = t.responseText;
			$(moduleName).innerHTML = moduleHtml;
			//$('toolbox_dialogue').innerHTML = '';
			
		},
		// Handle 404
		on404: function(t) {
			alert('Error 404: location "' + t.statusText + '" was not found.');
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	generatorUrl = 'http://w3.eftel.com.au/portalmanage/generate_XXX.cms';
	generatorUrl = generatorUrl.replace(/XXX/g,moduleName);
	new Ajax.Request(generatorUrl , opt);
	// $('toolbox_dialogue').innerHTML = 'Loading module ' + moduleName + '...';
}

function changeWeather(){
	var weatherDropdown = document.getElementById("weather.location")
	var target = weatherDropdown.options[weatherDropdown.selectedIndex].value;
	var location = weatherDropdown.options[weatherDropdown.selectedIndex].text;
	var opt = {
		// Use POST
		method: 'post',
		// Send this lovely data
		postBody: "weather.location=" + target ,
		// Handle successful response
		onSuccess: function(t) {
			$('weather_container').innerHTML = t.responseText;
			$('weather').innerHTML = t.responseText.replace(/XXX_/g,'');
		},
		// Handle 404
		on404: function(t) {
			alert('Error 404: location "' + t.statusText + '" was not found.');
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('http://w3.eftel.com.au/portalmanage/generate_weather.cms', opt);
	// $('toolbox_dialogue').innerHTML = 'Retrieving weather for ' + location;
}


//eo of portal code


// preloader code

$(function() {
                        $(".meter > span").each(function() {
                                $(this)
                                        .data("origWidth", $(this).width())
                                        .width(0)
                                        .animate({
                                                width: $(this).data("origWidth")
                                        }, 1200);
                        });
                })




//-->
