$(document).ready(function() {

   /* Adjust the middle div height to show borders properly on sub pages */
   $('.sub_middle').css({'min-height' : $('.subpage_main').height()});

   $('#newsletter_submit').click(function(){
      //alert('hello');
       $.ajax({
         type: "POST",
         url: "../ajaxtpl/nl_subscriber.php",
         data: "news_name="+$('#news_name').val()+"&news_email="+$('#news_email').val(),
         success: function(msg){
         alert(msg);
          $('#news_name').attr('value', '');
          $('#news_email').attr('value', ''); 
         }
       });
   });
		$('#footer_search').focus(function() {	
			if($("#footer_search").val() == "search")	{
			$("#footer_search").val("");
			}
		});
		$('#footer_search').blur(function() {
			if($("#footer_search").val() == "")	{
			$("#footer_search").val("search");
			}
		});
    if(DetectFlashVer(9,0,0) == false){
        $('.mobile_header').css('display', 'block');
        $('#home_flash, #sub_flash').css('display','none');
        $('#logo_scroller').css('display','none');
        $('body').addClass('mobile');
    }
});

	function flashevent(objEvent)
	{
		switch(objEvent)
		{
			case 'online_marketing':
				pageTracker._trackEvent('Flash', 'onClick', 'Online Marketing');
			break;
			case 'web_design':
				pageTracker._trackEvent('Flash', 'onClick', 'Web Design');
			break;
			case 'ecommerce':
				pageTracker._trackEvent('Flash', 'onClick', 'E-Commerce');
			break;
			case 'seo':
				pageTracker._trackEvent('Flash', 'onClick', 'SEO');
			break;
			case 'web':
				pageTracker._trackEvent('Flash', 'onClick', 'Web');
			break;
			case 'email_marketing':
				pageTracker._trackEvent('Flash', 'onClick', 'Email Marketing');
			break;

                    		
		}
	}

function popitup(url) 
	{var newwindow = '';
		if (newwindow.location && !newwindow.closed) 
		{ newwindow.location.href = url; newwindow.focus(); } 
		else 
		{ newwindow=window.open(url,'call_now','menubar=0,resizable=0,location=0,status=0,scrollbars=0,width=606,height=440') ; }
	}


$(document).ready(function() {
     $('#perth_div').simpletip({content: 'Perth <a class="tooltip1" href="tel:+61 8 9443 9905">+61 (0)8 9443 9905</a>,<br/>102 Walters Drive <br/>Osbome Park, WA 6017',fixed:true, position: [-30,-54]});
		$('#melb_div').simpletip({content: 'Melbourne<br/><a class="tooltip1" href="tel:+61 3 9889 6888">+61 (0)3 9889 6888</a>,<br/>1186 Toorak Road,<br/>Camberwell, VIC 3124',fixed:true, position: [-135,-71] });
		$('#sydney_div').simpletip({content: 'Sydney <a class="tooltip1" href="tel:+61 2 8004 1999">+61 (0)2 8004 1999</a>,<br/>64 Talavera Road, North Ryde<br/>Sydney, NSW 2113',fixed:true, position: [-200,-56] });
		$('#brisb_div').simpletip({content: 'Brisbane <a class="tooltip1" href="tel:+61 7 3173 1667">+61 (0)7 3173 1667</a>,<br/>123 Eagle Street,<br/>Brisbane Qld 4000',fixed:true, position: [-200,-20] });
		$('#ald_div').simpletip({content: 'Adelaide <a class="tooltip1" href="tel:+61 8 7002 9409">+61 (0)8 7002 9409</a>,<br/>18 Dequetteville Terrace,<br/> Kent Town, Adelaide SA 5067',fixed:true, position: [-83,-82] });
  
/* Simple tip used for folio page */
   $('.country').simpletip({content: 'Site not available in your country',fixed:true});

  $('.android_exa_quotes').simpletip({content: 'To get Exa Quotes via the Android Market, launch the Marketplace application on Android and search for "Exa Quotes"',fixed:true, position: [-25,-80] });
});

/* Show hide functionality for sitemap page */
$(document).ready(function(){
	$('div.sub_items').css({'display' : 'none'});
	$('img[class="expand_alert"]').click(function(event) {
		var img_id = this.id;
		if($('#alert_div_'+img_id).css('display') == 'none'){
			$('div.sub_items').css({'display' : 'none'});
			$('img[src="../images/grey_minus_new.gif"]').attr({ 
				src: "../images/grey_plus_new.gif"
			});
		}
		$('#alert_div_'+img_id).toggle(200);
		var img_src = $("#"+img_id).attr("src");
		if(img_src.indexOf("grey_minus_new.gif") > 0){
			$("#"+img_id).attr({ 
				src: "../images/grey_plus_new.gif"
			});
		}else{
			$("#"+img_id).attr({ 
				src: "../images/grey_minus_new.gif"
			});
		}
		return false;
	});
 if(typeof(dlvrf) != "undefined" && dlvrf == "1") { window.location = base_url+"/downloads/Social_Media.pdf?20110614";}
 if(typeof(dlvrfsmnr) != "undefined" && dlvrfsmnr == "1") { window.location = base_url+"/downloads/Exa_Mobile-Marketing_LT.pdf?20110719";
 }
});
$(document).ready(function(){
		$("input:text").focus(function(){
		$(this).addClass("formfield_focus");
		$(this).removeClass("formfield_blur");
		});
		$("textarea").focus(function(){
		$(this).addClass("formfield_focus");
		$(this).removeClass("formfield_blur");
		});
		
		$("#footer_search").focus(function(){
		$(this).addClass("search_border");
		});
		$("#footer_search").blur(function(){
		$(this).addClass("search_border");
		});
		$("input:text").blur(function(){
		$(this).addClass("formfield_blur");
		$(this).removeClass("formfield_focus");
		});
		$("textarea").blur(function(){
		$(this).addClass("formfield_blur");
		$(this).removeClass("formfield_focus");
		});
});
$(document).ready(function(){	
$('#firsthear').change(function() {
	if ($('#firsthear').val() == "Word of Mouth" || $('#firsthear').val() == "Client Referral") {
	$('p#referee').show();
	$('p#cpny_name').show();
	}
	else{
	$('p#referee').hide();
	$('p#cpny_name').hide();
	}
});
});

/* Show hide functionality for footer- Articles  */
$(document).ready(function(){

    $('.main_articles div').css({
        'display' : 'none'
    });
    $('.expand_sub').attr({
        src: base_url+"/images/articles_select.jpg"
    });
    $('img[class="expand_sub"]').click(function(event) {

        var img_id = this.id;
        if($('.sub_'+ img_id).css('display') == 'none'){
            $('.expand_sub').attr({
                src:base_url+ "/images/articles_select.jpg"
            });
            $('.main_articles div').fadeOut(100);
            $('.sub_'+ img_id).fadeIn(100);
            $('#'+img_id).attr({
                src: base_url+"/images/articles_selected.jpg"
            });

        }
        else
        {
           $('.sub_'+ img_id).fadeOut(100);
            $('#'+img_id).attr({
                src: base_url+"/images/articles_select.jpg"
            });
        }

        return false;
    });

    //footer subarticles 

    $('.main_articles').css({
        'display':'none'
    });

    $('img[class="expand_articles"]').click(function(event) {
   
        if($('.main_articles').css('display') == 'none'){
                  $('div.main_articles').fadeIn(100);
                  
            $('.expand_articles').attr({
                src: base_url+"/images/articles_selected.jpg"
            });

        }else
        {
             $('.main_articles').fadeOut(100);
            $('.expand_articles').attr({
                src: base_url+"/images/articles_select.jpg"
            });
        }
    });

});

  
  
  
  
$(document).ready(function(){
   $('.revamp_div li').addClass('display_none');
   $('.slider_thumbnail li').click(function(event){
   var thum_id=this.id;
   var end_index= thum_id.indexOf('_');
   var parent_elm = thum_id.substr(0,end_index);
   $('#'+ parent_elm +' li').removeClass('display_block');
   $('.revamp_div li#large_'+ thum_id).addClass('display_block');
  });
});


function loadLargeTestimonial(){
	var soTestimonial = new SWFObject("http://www.exa.com.au/tv/flash/tv_ad.swf", "large_testimonial_video", "510", "375", "9", "");
	var var_load_img_path;
	if($("a#video_name").attr("rel") == 'hi_res.flv'){
		var_load_img_path = 'http://www.exa.com.au/images/home_page/loading_img.jpg';
	}
	else{
		var_load_img_path = 'http://www.exa.com.au/images/home_page/loading_exa.jpg';
	}
	soTestimonial.addParam("allowFullScreen","true");	
	soTestimonial.addParam("allowScriptAccess","sameDomain");
	soTestimonial.addParam("wmode","transparent");

	soTestimonial.addParam('FlashVars','stageW=590&stageH=380&autoStart=false&autoHide=true&autoHideTime=3&hideLogo=true&volAudio=60&disableMiddleButton=false&playSounds=true&extendVideo=true&videoPath=http://video.exa.com.au/ad/flash/'+$("a#video_name").attr("rel")+'&imagePath=http://www.exa.com.au/images/home_page/loading_img.jpg');	
	soTestimonial.write("large_testimonial_video");
}
function unloadLargeTestimonial(){
$('#large_testimonial_video').html("");
}

/* Code to track if 80% page is viewed */
var IsDuplicateScrollEvent = 0;

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

function SetupGoogleAnalyticsTrackEvents(){
    TrackEventsForMinimumPageScroll();
}

function TrackEventsForMinimumPageScroll(){
    $(window).scroll(function(){
        var scrollPercent = GetScrollPercent();
        if(scrollPercent > 80){
            if(IsDuplicateScrollEvent == 0){ 
                IsDuplicateScrollEvent = 1;
                TrackEvent("Content Engagement", "Scrolled To 80%", document.location.href);
            }
        }
    });
}

function GetScrollPercent(){
    var bottom = $(window).height() + $(window).scrollTop();
    var height = $(document).height();
    return Math.round(100*bottom/height);
}

function TrackEvent(Category, Action, Label){
    pageTracker._trackEvent(Category, Action, Label);
}


