function googlesearch(){
	window.open('http://www.google.com/search?sitesearch=www.mycaroma.com.au&as_q='+ $('#google_search_txt').val() ,'GoogleSearch');
}

function showOverlay() {
	if ($('facebox_overlay').length == 0){
		$("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')
	}
	$('#facebox_overlay').hide().addClass("facebox_overlayBG")
	  .click(function() { $(document).trigger('close.facebox') })
	  .css('opacity', 0)
	  .fadeIn(1)
	  $('#facebox_overlay').fadeTo(200, 0.4);
	return false
}

function hideOverlay() {
	$('#facebox_overlay').fadeOut(200, function(){
	  $("#facebox_overlay").removeClass("facebox_overlayBG")
	  $("#facebox_overlay").addClass("facebox_hide") 
	  $("#facebox_overlay").remove()
	})
	return false
}

function show_popup_signin(){
	var popup_login_box_width=574;
	showOverlay();
//	$('#popup_login_lightbox div.popup').fadeTo(1,0,function(){
		//alert($('#popup_login_lightbox div.popup').width());
		$('#popup_login_lightbox div.popup').css('opacity', 0).css('display', 'block');
		left = $(window).width() / 2 - (popup_login_box_width / 2);
		$('#popup_login_lightbox div.popup').css('left', left);
		$('#popup_login_lightbox div.popup').css('top', 100);
		$('#popup_login_lightbox').css('display', 'block').fadeTo(200,1,function(){
			$('#popup_login_lightbox div.popup').fadeTo(200,1,function(){
				//$('#popup_login_lightbox div.popup').fadeIn(400);
			});
		});
//	});
}

function hide_popup_signin(){
	$('#popup_login_lightbox').fadeTo(200,0,function(){
		$('#popup_login_lightbox div.popup').fadeTo(200,0,function(){
			$('#popup_login_lightbox div.popup').css('display', 'none');
			$('#popup_login_lightbox').css('display', 'none');
			hideOverlay();
		});
	});
}

function ArticleListwImg(obj){
	document.getElementById("whatsnew_img").src= $(obj).attr("rel");
}



function ClickTab(v){
	if(v==5){
		$("#TOMForm").show();
	}else{
		$("#TOMForm").hide();
	}

	for(i=1;i<=5;i++){
		obj = $("#tradehometab_"+i);
		if(i==v){
			obj.show();
			$("#tap_list_trade ul li.tap"+i+"_list_trade a").css("background-position","right");
		}else{
			obj.hide();
			$("#tap_list_trade ul li.tap"+i+"_list_trade a").css("background-position","left");
		}
	}

}

function HomeTabOver(v){
	if(v==1){
		obj = $("#list2_news_1");
		obj.show();
		$("#tap_news ul li.tap1_consumer a").css("background-position","left");
		obj = $("#list2_news_2");
		obj.hide();
		$("#tap_news ul li.tap2_proefessional a").css("background-position","right");
	}else{
		obj = $("#list2_news_1");
		obj.hide();
		$("#tap_news ul li.tap1_consumer a").css("background-position","right");
		obj = $("#list2_news_2");
		obj.show();
		$("#tap_news ul li.tap2_proefessional a").css("background-position","left");	}
}

function PromoTabClick(v){
	for(i=1;i<=3;i++){
		obj = $("#promo_div_"+i);
		if(i==v){
			obj.show();
			$("#promo_a_"+i).css("background-position","right");
		}else{
			obj.hide();
			$("#promo_a_"+i).css("background-position","left");
		}
	}
}

function poplog_fail(){
	$(window).load(function () {
		poplog_delay();
	});
}

function poplog_delay(){
	show_popup_signin();
	var tmp_obj = document.getElementById("login_fail_text");
	tmp_obj.innerHTML=" <br />If you can't remember your password, please enter your email address <a href='/LoginRetrieve'>here</a> and we will send you your password.";
}


$(document).ready(function() {

	if($("#HomeTradeSlide").html()!=null){
		$("#HomeTradeSlide").scrollable({speed:700,size:1,loop:true,clickable:false,vertical:false,next:"div#HomeTradeSlideArrow a.next",prev:"div#HomeTradeSlideArrow a.prev"}).circular().autoscroll({interval:3000});
	}

	if($("#HomeConsumerSlide").html()!=null){
		$("#HomeConsumerSlide").scrollable({speed:700,size:2,loop:true,clickable:false,vertical:false,next:"div#HomeConsumerSlideArrow a.next",prev:"div#HomeConsumerSlideArrow a.prev"}).circular().autoscroll({interval:3000});
	}

	if($("div.ArticleContainer div.MyProfilePanel").html()!=null){
		tmp_obj = $("#UserDetails :input");
		tmp_email = tmp_obj[0].value;
		tmp_username = tmp_obj[1].value;

		tmp_target = $("#TOMForm :input");
		tmp_target[0].value=tmp_username;
		tmp_target[1].value=tmp_email;

		$("#plc_lt_container_SubContent_SubContent_lt_zoneSubLeft_SubContents_SubContents_lt_contents_tipofmonth_viewBiz").css("float","left");
	}

	$("#plc_lt_container_SubContent_SubContent_lt_zoneTop_CustomRegistrationForm_btnRegister").click(function(){
		tmp_1=$("#plc_lt_container_SubContent_SubContent_lt_zoneTop_CustomRegistrationForm_formUser_ctl00_Email_txtEmailInput").val();
		tmp_2=$("#VerifyEmail").val();
		if(tmp_1!=tmp_2){
			MSG="<span>Please check your email address.</span>";
			$("#reg_email span.reg_errmsg").html(MSG);
			$("#reg_email span.reg_errmsg span").show(500).css("z-index","10");
			return false;
		}else{
			return true;
		}
	});

	if($("#reg_username")){

		$("#reg_username span.reg_input input").focus(function(){
			MSG="<span>Username needs to use at least six characters.</span>";
			$("#reg_username span.reg_errmsg").html(MSG);
			$("#reg_username span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_username span.reg_input input").blur(function(){$("#reg_username span.reg_errmsg span").hide(200).css("z-index","1");});

		$("#reg_email span.reg_input input").focus(function(){
			MSG="<span>After registering, you will receive an email to activate your account. Please ensure your email address is valid.</span>";
			$("#reg_email span.reg_errmsg").html(MSG);
			$("#reg_email span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_email span.reg_input input").blur(function(){$("#reg_email span.reg_errmsg span").hide(200).css("z-index","1");});

		$("#reg_password span.reg_input input").focus(function(){
			MSG="<span>For security, your password needs to use at least six characters.</span>";
			$("#reg_password span.reg_errmsg").html(MSG);
			$("#reg_password span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_password span.reg_input input").blur(function(){$("#reg_password span.reg_errmsg span").hide(200).css("z-index","1");});






		$("#reg_firstname span.reg_input input").focus(function(){
			MSG="<span>First name is required.</span>";
			$("#reg_firstname span.reg_errmsg").html(MSG);
			$("#reg_firstname span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_firstname span.reg_input input").blur(function(){$("#reg_firstname span.reg_errmsg span").hide(200).css("z-index","1");});

		$("#reg_lastname span.reg_input input").focus(function(){
			MSG="<span>Last name is required.</span>";
			$("#reg_lastname span.reg_errmsg").html(MSG);
			$("#reg_lastname span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_lastname span.reg_input input").blur(function(){$("#reg_lastname span.reg_errmsg span").hide(200).css("z-index","1");});



		$("#reg_dob span.reg_input input").focus(function(){
			MSG="<span>e.g. 25/12/1970</span>";
			$("#reg_dob span.reg_errmsg").html(MSG);
			$("#reg_dob span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_dob span.reg_input input").blur(function(){$("#reg_dob span.reg_errmsg span").hide(200).css("z-index","1");});

		$("#reg_mobile span.reg_input input").focus(function(){
			MSG="<span>Mobile No is required.</span>";
			$("#reg_mobile span.reg_errmsg").html(MSG);
			$("#reg_mobile span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_mobile span.reg_input input").blur(function(){$("#reg_mobile span.reg_errmsg span").hide(200).css("z-index","1");});

		$("#reg_street span.reg_input input").focus(function(){
			MSG="<span>Street Address is required</span>";
			$("#reg_street span.reg_errmsg").html(MSG);
			$("#reg_street span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_street span.reg_input input").blur(function(){$("#reg_street span.reg_errmsg span").hide(200).css("z-index","1");});

		$("#reg_suburb span.reg_input input").focus(function(){
			MSG="<span>Suburb / Town / City is required.</span>";
			$("#reg_suburb span.reg_errmsg").html(MSG);
			$("#reg_suburb span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_suburb span.reg_input input").blur(function(){$("#reg_suburb span.reg_errmsg span").hide(200).css("z-index","1");});

		$("#reg_postcode span.reg_input input").focus(function(){
			MSG="<span>e.g. 2000</span>";
			$("#reg_postcode span.reg_errmsg").html(MSG);
			$("#reg_postcode span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_postcode span.reg_input input").blur(function(){$("#reg_postcode span.reg_errmsg span").hide(200).css("z-index","1");});

		$("#reg_license span.reg_input input").focus(function(){
			MSG="<span>Trade License No is optional.</span>";
			$("#reg_license span.reg_errmsg").html(MSG);
			$("#reg_license span.reg_errmsg span").show(500).css("z-index","10");
		});
		$("#reg_license span.reg_input input").blur(function(){$("#reg_license span.reg_errmsg span").hide(200).css("z-index","1");});

	}

	if($("#logo_top")){
		$("#logo_top").click(function(){
			document.location.href='/';
		});
	}


	if($("#SignInButton")){
		$("#SignInButton").click(function(){
			show_popup_signin();
		});
	}

	if($("#popup_login_close_btn")){
		$("#popup_login_close_btn").click(function(){
			hide_popup_signin();
		});
}

	$("li.professionals").mouseover(function(){
		$("div.sub_trade").show();
	});
	$("li.professionals").mouseout(function(){
		$("div.sub_trade").hide();
	});
	$("div.sub_trade").mouseout(function(){
		$("div.sub_trade").hide();
	});
	$("div.sub_trade").mouseover(function(){
		$("div.sub_trade").show();
	});


	$("li.consumers").mouseover(function(){
		$("div.sub_consumer").show();
	});
	$("li.consumers").mouseout(function(){
		$("div.sub_consumer").hide();
	});
	$("div.sub_consumer").mouseout(function(){
		$("div.sub_consumer").hide();
	});
	$("div.sub_consumer").mouseover(function(){
		$("div.sub_consumer").show();
	});


});






