/*--------------------------------------------------------
 * 
 * Jquery.cookie.js
 * 
 * used for memory on advanced product search
 * 
 *-----------------------------------------------------
 
 /**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/* update to version 2010
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
*/ 
 
 /*--------------------------------------------------------
 * 
 * End of Jquery.cookie.js
 * 
 * 
 * 
 *-----------------------------------------------------*/
 
 
 function setCookie(name, value){
	
	options = { path: '/'};
	$.cookie(name,value,options);	
}

function getCookie(name){
	var c = $.cookie(name); 
	return c;
}
 
 
 
 $(document).ready(function(){
	$('.slideup_txt_bot').each(function(){
		$(this).slideUp(10);
	});
		
	$('.home_cta_box, .home_cta_box_last').hover(function(){
			$('.slideup_txt_bot',this).slideDown(100);
		},function(){
			$('.slideup_txt_bot',this).slideUp(100);		
	});
	
	
	$('.services_slideup_txt_bot').slideUp();
		
	$('.services_cta_box, .services_cta_box_last').hover(function(){
			$('.services_slideup_txt_bot',this).slideDown(50);
		},function(){
			$('.services_slideup_txt_bot',this).slideUp(50);		
	});
	
	$(".services_cta_white_ctn").click(function(){
		var href = $(this).parent().children("a").attr("href");		
		if(href)
			window.open(href);
	});
	
	
	$('.prod_img_bot').slideUp();
		
	$('.prod_cta_box, .prod_cta_box_last').hover(function(){
			$('.prod_img_bot',this).slideDown(200);
		},function(){
			$('.prod_img_bot',this).slideUp(200);		
	});
	
	$(".cta_white_ctn").click(function(){
		var href = $(this).parent().children("a").attr("href");		
		window.location.href = href;
	});
	
});


// JavaScript Document//clear text box on click
function clearText(field){

if (field.defaultValue == field.value) field.value = '';
else if (field.value == '') field.value = field.defaultValue;

}



// Cufon
Cufon.replace('h1')('h2');
Cufon.replace('.cufon-font', {hover: true});	
//Cufon.replace('.cta_white_ctn');
Cufon.replace('.underline_heading');
Cufon.replace('#header_phone');
Cufon.replace('.dropdown a', {hover: true});
Cufon.replace('.search_heading');
Cufon.replace('.cont_innerhead');
Cufon.replace('.retail a');
Cufon.replace('.banner_smalltxt');
Cufon.replace('.banner_bigtxt');
Cufon.replace('#corner_a');
Cufon.replace('.slideup_txt_top');
Cufon.replace('.services_slideup_txt_top');
//Cufon.replace('slideup_txt_bot');
Cufon.replace('.prodcat_option_column label');
Cufon.replace('.prodcat_search_column label');
Cufon.replace('.search_heading_ret');
Cufon.replace('.black_heading');



	
	function setVisibility(id, value){

document.getElementById(id).style.display=value
	//$(id).css('visibility',value);
}


//retailer

$(function () {
        $('.bubbleInfo').each(function () {
            var distance = 40;
            var time = 150;
            var hideDelay = 200;
			var showDelay = 700;
			var timerfunc;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger', this);
            var info = $('.popup', this).css('opacity', 1);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                
				if(this == info.get(0))
					showDelay = 0;
				
				timerfunc=setTimeout(function(){ 
				
					if (hideDelayTimer) clearTimeout(hideDelayTimer);
					if (beingShown || shown) {
						// don't trigger the animation again
						return;
					} else {
						// reset position of info box
						beingShown = true;
						
						

						info.css({
						top:0,
						right:0,
								
							display: 'block'
						}).animate({
							top: '-=' + distance + 'px',
							opacity: 1
						}, time, 'swing', function() {
							beingShown = false;
							shown = true;
						});
					}

					return false;
				},showDelay);
				
            }).mouseout(function () {
				window.clearTimeout(timerfunc);
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
					
                    info.animate({
                        top: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
        });
    });


//product sliders
//-------------------------

//custom code for Image gallery
$(document).ready(function(){
	$(".nav-controls").css("display","none");
	
	$("#gallery, #gallery1, #gallery2").hover(
		function(){
			$(".nav-controls").css("display","block");
		},
		function(){
			$(".nav-controls").css("display","none");
		}
	);
	
	if($("#country1").css('display')=="block"){
		
	}
});

$(function() {
		$("#searchfrm .searchBtn").hide();
		$( "#price-range" ).slider({
			range: true,
			min: 120,
			max: 500,	
			values: [ 120, 500 ],
			slide: function( event, ui ) {
				$( "#price" ).val( "" + ui.values[ 0 ] + ":" + ui.values[ 1 ] );
				
				var min = ui.values[ 0 ]+"k";
				var max = ui.values[ 1 ]+"k";
				var tt = "";
				
				if( $( "#minprice" ).val() != min)
				{
					$( "#minprice" ).val( min);
					tt = min;
				}
				if($( "#maxprice" ).val() != max)
				{
					$( "#maxprice" ).val( max);
					tt = max;
				}
				displayChangedValues();			
				$("#tooltip div.body").text(tt);
			},
			stop: function() {
				updateChangedValues();
				rememberSearchState();
			}
		});
				
		$( "#weight-range" ).slider({
			range: true,
			min: 5,
			max: 20,
			values: [ 5, 20 ],
			slide: function( event, ui ) {
				$( "#weight" ).val( "" + ui.values[ 0 ] + ":" + ui.values[ 1 ] );
				
				var min = ui.values[ 0 ]+"m";
				var max = ui.values[ 1 ]+"m";
				var tt = "";
				
				if( $( "#minweight" ).val() != min)
				{
					$( "#minweight" ).val( min);
					tt = min;
				}
				if($( "#maxweight" ).val() != max)
				{
					$( "#maxweight" ).val( max);
					tt = max;
				}
				$("#tooltip div.body").text(tt);
				displayChangedValues();
				
			},
			stop: function() {
				updateChangedValues();
				rememberSearchState();
			}
		});			
		$( "#size-range" ).slider({
			range: true,
			min: 15,
			max: 60,
			values: [ 15, 60 ],
			slide: function( event, ui ) {
				$( "#weight" ).val( "" + ui.values[ 0 ] + ":" + ui.values[ 1 ] );
				
				var min = ui.values[ 0 ]+"sq";
				var max = ui.values[ 1 ]+"sq";
				var tt = "";
				
				if( $( "#minsize" ).val() != min)
				{
					$( "#minsize" ).val( min);
					tt = min;
				}
				if($( "#maxsize" ).val() != max)
				{
					$( "#maxsize" ).val( max);
					tt = max;
				}
				$("#tooltip div.body").text(tt);				
				displayChangedValues();
			},
			stop: function() {
				updateChangedValues();
				rememberSearchState();
			}
		});
		
		//
		$("#price-range, #weight-range, #size-range").each(function(){
			var id1 = $(this).attr('id') + "_min";
			var id2 = $(this).attr('id') + "_max";
			$(this).find("a.ui-slider-handle:nth-child(2)").attr('id',id1);
			$(this).find("a.ui-slider-handle:last-child").attr('id',id2);
		});

		//Tooltip		
		$("a.ui-slider-handle").mouseover(function(){
			$(this).attr('title',' - ');
			initToolTip();
			var pid = $(this).parent().attr('id');
			var pid_ = "#"+pid;
			var id1 = pid+"_min";
			var id2 = pid+"_max";
			
			var minmax = $(pid_).slider("values");
			if($(this).attr('id') == id1)
			{
				var tt = minmax[0];
				$("#tooltip div.body").text(tt);				
			}
			else if($(this).attr('id') == id2){
				var tt = minmax[1];
				$("#tooltip div.body").text(tt);				
			}
			
			//$(pid_).slider("slide");
				
			$("#tooltip").fadeIn("fast");
		});
		$("a.ui-slider-handle").mouseup(function(){
			$("#tooltip").fadeOut("slow");			
		});
		
		//live event tracking for other form elements.
		$("#searchfrm :radio, #searchfrm .radio, #searchfrm select").live("click",function(){
			updateChangedValues();
			rememberSearchState();
		});
		
		//save last search to cookie
		$("#content_ctn .home_cta_box a").live("click",function(){
			rememberSearchState();
		});
		
		//reload last search from cookie
		recallSearchState();
	
		//displays dynamically altered property tiles during slider drags
		function displayChangedValues() {
			var s_data=collectSearchFormState();
			var fields=["price","lotwidth","storey","bedroom","bath","size"];
			$("#content_ctn .home_cta_box, #content_ctn .home_cta_box_last").each(function(j){
				var data={};
				var i;
				var flag=true;
				for (i=0; i<fields.length; i++) {
					data[fields[i]]=$(this).attr("data-"+fields[i]);
				}
				if (data.price!="0.0000" &&((s_data.price[0]*1000) > data.price || data.price > (s_data.price[1]*1000)) ) {
					//console.debug("fail price");
					////console.warn( ((s_data.price[0]*1000)>data.price>(s_data.price[1]*1000)) );
					flag=false;
				}
				if (data.lotwidth!="" && (s_data.lotwidth[0] > data.lotwidth || data.lotwidth > s_data.lotwidth[1])) {
					//console.debug("fail lotwidth");
					flag=false;
				}
				if (data.size!="" && (s_data.size[0] > data.size || data.size > s_data.size[1])) {
					//console.debug("fail lotwidth "+j);
					flag=false;
				}
				if (data.storey!="" &&  s_data.storey!="" && s_data.storey>data.storey) {
					//console.debug("fail storey");
					flag=false;
				}
				if (data.bedroom!="" &&  s_data.bedroom!="" &&  s_data.bedroom>data.bedroom) {
					//console.debug("fail bedroom");
					flag=false;
				}
				if (data.bath!="" &&  s_data.bath!="" && s_data.bath>data.bath) {
					//console.debug("fail bath");
					flag=false;
				}
				if (flag) {
					$(this).addClass("activated").removeClass("deactivated");
				} else {
					$(this).removeClass("activated").addClass("deactivated");
				}
			});
			$("#content_ctn").find(".activated").addClass("transitional").css({'display':'block'}).stop().animate({opacity:1},400);
			$("#content_ctn").find(".deactivated").not(":hidden").stop().animate({opacity:0.1},400);
		}
		
		//hides or reveals updated property tiles at end of slider drag or after
		//radio button or drop down selection
		function updateChangedValues() {
			//console.debug("updateChangedValues");
			//return false;
			var s_data=collectSearchFormState();
			var fields=["price","lotwidth","storey","bedroom","bath","size"];
			$("#content_ctn .home_cta_box, #content_ctn .home_cta_box_last").each(function(j){
				var data={};
				var i;
				var flag=true;
				for (i=0; i<fields.length; i++) {
					data[fields[i]]=$(this).attr("data-"+fields[i]);
				}
				if (data.price!="0.0000" &&((s_data.price[0]*1000) > data.price || data.price > (s_data.price[1]*1000)) ) {
					//console.debug("fail price");
					////console.warn( ((s_data.price[0]*1000)>data.price>(s_data.price[1]*1000)) );
					flag=false;
				}
				if (data.lotwidth!="" && (s_data.lotwidth[0] > data.lotwidth || data.lotwidth > s_data.lotwidth[1])) {
					//console.debug("fail lotwidth");
					flag=false;
				}
				if (data.size!="" && (s_data.size[0] > data.size || data.size > s_data.size[1])) {
					//console.debug("fail lotwidth "+j);
					flag=false;
				}
				if (data.storey!="" &&  s_data.storey!="" && s_data.storey!=data.storey && s_data.storey!="Both") {
					//console.debug("fail storey");
					flag=false;
				}
				if (data.bedroom!="" &&  s_data.bedroom!="" &&  s_data.bedroom>data.bedroom) {
					//console.debug("fail bedroom");
					flag=false;
				}
				if (data.bath!="" &&  s_data.bath!="" && s_data.bath>data.bath) {
					//console.debug("fail bath");
					flag=false;
				}
				if (flag) {
					$(this).addClass("activated").removeClass("deactivated");
				} else {
					$(this).removeClass("activated").addClass("deactivated");
				}
			});
			$("#content_ctn").find(".activated").show().stop().animate({opacity:1},1000);
			$("#content_ctn").find(".deactivated").stop().hide();//animate({opacity:0},1000,function(){$(this).hide();});
			
		}
		
		
		function collectSearchFormState() {
			var data={};
			data.price=$("#price-range").slider("values");
			data.lotwidth=$("#weight-range").slider("values");
			data.size=$("#size-range").slider("values");
			data.storey=$("#searchfrm :checked").val();
			data.bedroom=$("#searchfrm select").eq(0).val();
			data.bath=$("#searchfrm select").eq(1).val();
			return data;
		}
		
		function rememberSearchState() {
			//console.debug("rememberSearchState");
			var data=collectSearchFormState();
			var cookiestr=[];
			cookiestr.push(data.price.join("/"));
			cookiestr.push(data.lotwidth.join("/"));
			cookiestr.push(data.size.join("/"));
			cookiestr.push(data.storey);
			cookiestr.push(data.bedroom);
			cookiestr.push(data.bath);
			cookiestr=cookiestr.join("|");
			//console.debug(cookiestr);
			$.cookie('adv_srch', cookiestr, { path: '/'}); //session cookie only
		}
		
		function recallSearchState() {
			//console.warn("recallSearchState");
			var cookie=$.cookie('adv_srch');
			var price,lotwidth,size,storey,bedroom,bath,i;
			if (cookie && document.getElementById("searchfrm")) {
				//console.debug("cookie="+cookie);
				var srchState=cookie.split("|");
				//console.debug("srchState="+srchState);
				if (srchState[0]!="120/500") {
					price=srchState[0].split("/");
					$("#price-range").slider("values",0,price[0]);
					$("#price-range").slider("values",1,price[1]);
				}
				
				if (srchState[1] != "5/20") {
					lotwidth = srchState[1].split("/");
					$("#weight-range").slider("values", 0, lotwidth[0]);
					$("#weight-range").slider("values", 1, lotwidth[1]);
				}
				
				if (srchState[2] != "15/60") {
					size = srchState[2].split("/");
					$("#size-range").slider("values",0,size[0]);
					$("#size-range").slider("values",1,size[1]);
				}
				
				if (srchState[3]!="") {
					$("#searchfrm span.optbutton")
							.css("backgroundPosition","0px 0px")
					$("#searchfrm :radio[value='"+srchState[3]+"']")
							.attr("checked",true)
							.parent().find("span.optbutton").css("backgroundPosition","0px -42px");
				} 
				
				if (srchState[4] != "") {
					var bedrm_span = $("#selectfield_69");
					var bedrm_select = bedrm_span.parent().find("select")[0];
					for (i = 0; i < bedrm_select.options.length; i++) {
						if (bedrm_select.options[i].value == srchState[4]) {
							bedrm_select.selectedIndex = i;
							bedrm_span.html(bedrm_select.options[i].text);
							break;
						}
					}
					bedrm_span.html(bedrm_select.options[bedrm_select.selectedIndex].text);
				}
				if (srchState[5] != "") {
					var bathrm_span = $("#selectfield_71");
					var bathrm_select = bathrm_span.parent().find("select")[0];
					for (i = 0; i < bathrm_select.options.length; i++) {
						if (bathrm_select.options[i].value == srchState[5]) {
							bathrm_select.selectedIndex = i;
							bathrm_span.html(bathrm_select.options[i].text);
							break;
						}
					}
					bathrm_span.html(bathrm_select.options[bathrm_select.selectedIndex].text);
				}
				
				//update displayed properties
				updateChangedValues();
			}
		}
	
	});
	
	

//Homepage sliding banner	
/* Carousel Pack */

/* pack : 1  http://thomlx.free.fr/js/jquery.carousel.pack.js*/
;(function($){$.fn.carousel=function(params){var params=$.extend({direction:"horizontal",loop:false,dispItems:1,pagination:false,paginationPosition:"inside",nextBtn:"<span>Next</span>",prevBtn:"<span>Previous</span>",btnsPosition:"inside",nextBtnInsert:"appendTo",prevBtnInsert:"prependTo",autoSlide:false,autoSlideInterval:3000,delayAutoSlide:3000,combinedClasses:false,effect:"slide",slideEasing:"swing",animSpeed:"normal",equalWidths:"true",callback:function(){}},params);if(params.btnsPosition=="outside"){params.prevBtnInsert="insertBefore";params.nextBtnInsert="insertAfter";}
return this.each(function(){var env={$elts:{},params:params,launchOnLoad:[]};env.$elts.carousel=$(this).addClass("js");env.$elts.content=$(this).children().css({position:"absolute","top":0});env.$elts.wrap=env.$elts.content.wrap('<div class="carousel-wrap"></div>').parent().css({overflow:"hidden",position:"relative"});env.steps={first:0,count:env.$elts.content.find(">*").length};env.steps.last=env.steps.count-1;env.$elts.prevBtn=$(params.prevBtn)[params.prevBtnInsert](env.$elts.carousel).addClass("carousel-control previous carousel-previous").data("firstStep",-(env.params.dispItems));env.$elts.nextBtn=$(params.nextBtn)[params.nextBtnInsert](env.$elts.carousel).addClass("carousel-control next carousel-next").data("firstStep",env.params.dispItems);initButtonsEvents(env,function(e){slide(e,this,env);});if(env.params.pagination)initPagination(env);$(function(){var $firstItem=env.$elts.content.find(">*:eq(0)");env.itemWidth=$firstItem.outerWidth();if(params.direction=="vertical"){env.contentWidth=env.itemWidth;}else{if(params.equalWidths){env.contentWidth=env.itemWidth*env.steps.count;}else{env.contentWidth=(function(){var totalWidth=0;env.$elts.content.find(">*").each(function(){totalWidth+=$(this).outerWidth();});return totalWidth;})();}}
																																																																																																																																																																																																																																																																																																																								env.$elts.content.width(env.contentWidth);env.itemHeight=442;if(params.direction=="vertical"){env.$elts.content.css({height:+"442px"});env.$elts.content.parent().css({height:+"442px"});}else{env.$elts.content.parent().css({height:442});}   
																																																																																																																																																																																																																																																																																																																								   
/*env.$elts.content.width(env.contentWidth);env.itemHeight=$firstItem.outerHeight();if(params.direction=="vertical"){env.$elts.content.css({height:env.itemHeight*env.steps.count+"px"});env.$elts.content.parent().css({height:env.itemHeight*env.params.dispItems+"px"});}else{env.$elts.content.parent().css({height:env.itemHeight});}*/

updateButtonsState(env);$.each(env.launchOnLoad,function(i,fn){fn();});if(env.params.autoSlide){window.setTimeout(function(){env.autoSlideInterval=window.setInterval(function(){env.$elts.nextBtn.click();},env.params.autoSlideInterval);},env.params.delayAutoSlide);}});});};function slide(e,btn,env){var $btn=$(btn);var newFirstStep=$btn.data("firstStep");env.params.callback(newFirstStep);switch(env.params.effect){case"no":if(env.params.direction=="vertical"){env.$elts.content.css("top",-(env.itemHeight*newFirstStep)+"px");}else{env.$elts.content.css("left",-(env.itemWidth*newFirstStep)+"px");}
break;case"fade":if(env.params.direction=="vertical"){env.$elts.content.hide().css("top",-(env.itemHeight*newFirstStep)+"px").fadeIn(env.params.animSpeed);}else{ env.$elts.content.hide().css("left",-(env.itemWidth*newFirstStep)+"px").fadeIn(env.params.animSpeed);}
break;default:if(env.params.direction=="vertical"){env.$elts.content.stop().animate({top:-(env.itemHeight*newFirstStep)+"px"},env.params.animSpeed,env.params.slideEasing);}else{env.$elts.content.stop().animate({left:-(env.itemWidth*newFirstStep)+"px"},env.params.animSpeed,env.params.slideEasing);}}
env.steps.first=newFirstStep;updateButtonsState(env);if(!!e.clientX&&env.autoSlideInterval){window.clearInterval(env.autoSlideInterval);}};function updateButtonsState(env){env.$elts.prevBtn.data("firstStep",env.steps.first-env.params.dispItems);env.$elts.nextBtn.data("firstStep",env.steps.first+env.params.dispItems);if(env.$elts.prevBtn.data("firstStep")<0){if(env.params.loop&&env.steps.count>env.params.dispItems){env.$elts.prevBtn.data("firstStep",env.steps.count-env.params.dispItems);env.$elts.prevBtn.trigger("enable");}else{env.$elts.prevBtn.trigger("disable");}}else{env.$elts.prevBtn.trigger("enable");}
if(env.$elts.nextBtn.data("firstStep")>=env.steps.count){if(env.params.loop&&env.steps.count>env.params.dispItems){env.$elts.nextBtn.data("firstStep",0);env.$elts.nextBtn.trigger("enable");}else{env.$elts.nextBtn.trigger("disable");}}else{env.$elts.nextBtn.trigger("enable");}
if(env.params.pagination){env.$elts.paginationBtns.removeClass("active").filter(function(){return($(this).data("firstStep")==env.steps.first)}).addClass("active");}};function initButtonsEvents(env,slideEvent){env.$elts.nextBtn.add(env.$elts.prevBtn).bind("enable",function(){var $this=$(this).bind("click",slideEvent).removeClass("disabled");if(env.params.combinedClasses){$this.removeClass("next-disabled previous-disabled");}}).bind("disable",function(){var $this=$(this).unbind("click").addClass("disabled");if(env.params.combinedClasses){if($this.is(".next")){$this.addClass("next-disabled");}else if($this.is(".previous")){$this.addClass("previous-disabled");}}});env.$elts.nextBtn.add(env.$elts.prevBtn).hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});};function initPagination(env){env.$elts.pagination=$('<div class="center-wrap"><div class="carousel-pagination"><p></p></div></div>')[((env.params.paginationPosition=="outside")?"insertAfter":"appendTo")](env.$elts.carousel).find("p");env.$elts.paginationBtns=$([]);env.$elts.content.find("li").each(function(i){if(i%env.params.dispItems==0){env.$elts.paginationBtns=env.$elts.paginationBtns.add($('<a role="button"><span>'+('')+'</span></a>').data("firstStep",i));}});env.$elts.paginationBtns.appendTo(env.$elts.pagination);env.$elts.paginationBtns.slice(0,1).addClass("active");env.launchOnLoad.push(function(){env.$elts.paginationBtns.click(function(e){slide(e,this,env);});});};})(jQuery);


$(document).ready(function(){
        
		//Homepage banner rotator
		jQuery("div.carousel").carousel({
			/*direction: "verical",*/
			/*dispItems: 3,*/
			effect: "fade",
			pagination: true,
			autoSlide: true, 
			autoSlideInterval: 6000,			
			delayAutoSlide: 6000,
			animSpeed: 3000,
			loop: true
		});
		

$(".toggle_container").hide();

	$("a#qlinks").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
	});

					   
});


/* DROPDOWN NAVIGATION CODE
 * ==============================
 */
$(function(){

    $("ul.dropdown li").hover(function(){
    
        $(this).addClass("hover");
        //$('ul:first',this).css('visibility', 'visible');
            $('ul:first',this).css('left', '0px');						
    
    }, function(){
    
        $(this).removeClass("hover");
        //$('ul:first',this).css('visibility', 'hidden');
            $('ul:first',this).css('left', '-9999px');    			
    });
    
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

});



//////////////////////////
/*function checkImage(img){
	$(img).error(function(){
		$(this).attr("src","template_images/no_image.jpg");
		$(this).attr("alt","Sorry! This image is not available!");
	});
}*/


//////////////
$(document).ready(function(){
	
	//$("#country1").css("display","block");
	$("#country1").removeClass("offScreen");
	
	$("#countrytabs li a").click(function(){
		var rel = $(this).attr("rel");
		var targ = "#"+rel;
		
		/*$(".tabcontent ").each(function(){
			$(this).css("display","none");
			$("#countrytabs li a").each(function(){
				$(this).removeClass("selected");
			});
		});		
		$(targ).css("display","block");
		*/
		$(".tabcontent ").each(function(){
			$(this).addClass("offScreen");
			$("#countrytabs li a").each(function(){
				$(this).removeClass("selected");
			});
		});
		$(targ).removeClass("offScreen");
		$(this).addClass("selected");
	});
});

function flushThis(id){
   var msie = 'Microsoft Internet Explorer';
   var tmp = 0;
   var elementOnShow = document.getElementById(id);
   if (navigator.appName == msie){
      tmp = elementOnShow.parentNode.offsetTop  +  'px';
   }else{
      tmp = elementOnShow.offsetTop;
   }
}

$(document).ready(function(){
	var show = $('#show_Displays_tab').text();
	var tab_id = $('#show_Displays_tab').parent().attr('id');
	if(show == "Hide Displays Tab")
	{
		$("#countrytabs li a").each(function(){
			if($(this).attr('rel') == tab_id)
			{
				$(this).removeClass('selected').addClass('hide');				
				var id1 = $(this).attr('rel');
				id1 = '#'+id1;
				$(id1).addClass('offScreen');
				
				
				var id2 = $(this).parent().next().children().addClass('selected').attr('rel');
				id2 = '#'+id2;
				
				$(id2).removeClass('offScreen');
			}
		});
	}	
});




/* Script for Media Page Video*/

function callplayer(playurl)
{
 		$f("player", {src:"/players/flowplayer-3.2.7.swf", wmode:'transparent'}, {
              clip: {
          		// our song
              	url: playurl /*,   	
              	coverImage: 'http://nationalbuilderscomau.corewebdna.net.au/template_images/no_image.jpg'*/
				,wmode:'transparent'
              },
          	plugins:  {		
          		controls: {
          			backgroundColor:'#00BDF2',
          			height: 30,
          			fullscreen: false,
          			autoHide: false			
          		}
          		
          	}		
          });
}

$(document).ready(function(){
	$(".media").each(function(){
		var video = $(this).attr('href');		
		callplayer(video);
	});
});

function initToolTip(){
	$("a.ui-slider-handle").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fixPNG: true,
		showBody: " - ",
		extraClass: "slider_tooltip",
		top: -55,
		left: -24
	});
}

function goToByScroll(id){
	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

function Reg_redir(ret_page){
	var success = $("#feedback_success").html();
	var error =  $("#feedback_error").html();
	
	if(error)
		setCookie('fb_msg',error);
	else if(success)
		setCookie('fb_msg',success);	
	
	window.location.href=ret_page;
}

function loadFBMsg(){
	var fb_msg = getCookie('fb_msg');
	setCookie('fb_msg','');
		
	if(fb_msg){
		goToByScroll("hcf_form");
		if(fb_msg.indexOf("reasons")!=-1){
			$("#home_fb_error").html(fb_msg);
		}else{
			$("#home_fb_success").html(fb_msg);
			$("#hcf_form").hide();
			$(".home_contact_heading").hide();
		}
	}
}

function autofill_EnqDesign(enq_hs){	
	
	$("input[name='field_791']").val(enq_hs);
}
