﻿var mouseX;
var mouseY;
    
$(document).ready(function() {

    Cufon.replace('h1',{ fontFamily: 'din' });
	Cufon.replace('h2',{ fontFamily: 'din' }); 
	Cufon.replace('h3',{ fontFamily: 'din' });
	Cufon.replace('.h1effect',{ fontFamily: 'din' });
	Cufon.replace('#phonenum',{ fontFamily: 'din' });
	Cufon.replace('.topnavLink',{ fontFamily: 'din' });
	

    $(document).mousemove(function(e){
          mouseX = e.pageX;
          mouseY = e.pageY;
          movetooltip(".tooltipactive")
       }); 
              

    if (jQuery.browser.safari && document.readyState != "complete") {
        //console.info('ready...');
        setTimeout(arguments.callee, 100);
        return;
    } 

	$("a.tab_link").each(function() { 
	
		    if ($(this).html().length < 1){
		        $(this).parent().parent().hide();
		    }
        });

	
	  //start truncate script -->
    var the_obj = $('.ellipsis_1rows').ThreeDots({
        max_rows: 1,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'... <a href="@METAURL" class="small_text">read more &raquo;</a>'
    });
    var the_obj = $('.ellipsis_2rows').ThreeDots({
        max_rows: 2,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'... <a href="@METAURL" class="small_text">read more &raquo;</a>'
    });

    var the_obj = $('.ellipsis_3rows').ThreeDots({
        max_rows: 3,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'...'
    });

    var the_obj = $('.ellipsis_4rows').ThreeDots({
        max_rows: 4,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'...'
    });
    
     var the_obj = $('.ellipsis_5rows').ThreeDots({
        max_rows: 5,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'...'
    });
    
     var the_obj = $('.ellipsis_6rows').ThreeDots({
        max_rows: 6,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle:false,
        ellipsis_string:'... <a href="@METAURL" class="small_text">read more &raquo;</a>'
    });
    
    var the_obj = $('.ellipsis_7rows').ThreeDots({
        max_rows: 7,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'... <a href="@METAURL" class="small_text">read more &raquo;</a>'
    });
    
    var the_obj = $('.ellipsis_8rows').ThreeDots({
        max_rows: 8,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'... <a href="@METAURL" class="small_text">read more &raquo;</a>'
    });
     var the_obj = $('.ellipsis_9rows').ThreeDots({
        max_rows: 9,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'... <a href="@METAURL" class="small_text">read more &raquo;</a>'
    });
     var the_obj = $('.ellipsis_10rows').ThreeDots({
        max_rows: 10,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'... <a href="@METAURL" class="small_text">read more &raquo;</a>'
    });
    
    var the_obj = $('.ellipsis_11rows').ThreeDots({
        max_rows: 11,
        valid_delimiters: ['*'],
        whole_word: true,
        allow_dangle: false,
        ellipsis_string:'... <a href="@METAURL" class="small_text">read more &raquo;</a>'
    });



	
	
	
    //carousel script

    $('.indexList_vertical1').bxSlider({
    //$('#indexList_vertical1').livequery(function() {
        //$(this).bxSlider({
            infiniteLoop: true,
			mode: 'vertical',
            auto: true,
			captions: false,
			easing: 'easeInSine',
			autoHover: true,
			randomStart: false,
			pagerLocation: 'top',
			pagerType: 'full',
			pager: true,
			controls:false,
			displaySlideQty: 1,
			moveSlideQty: 1,
			speed: 1200,
			pause: 14000
			//});
    });

    $('.indexList_vertical3').bxSlider({
            infiniteLoop: true,
			mode: 'vertical',
            auto: true,
			captions: false,
			easing: 'easeInSine',
			autoHover: true,
			randomStart: false	,
			pagerLocation: 'top',
			pagerType: 'short',
			pager: true,
			controls:false,
			displaySlideQty: 3,
			moveSlideQty: 1,
			speed: 1000,
			pause: 3500
    });
    

    $('.indexList_vertical5').bxSlider({
            infiniteLoop: true,
			mode: 'vertical',
            auto: true,
			captions: false,
			easing: 'easeInSine',
			autoHover: true,
			randomStart: false	,
			pagerLocation: 'top',
			pagerType: 'short',
			pager: true,
			controls:false,
			displaySlideQty: 5,
			moveSlideQty: 1,
			speed: 2300		
    });


    $('.indexList_horizontal_withcontrols').bxSlider({
        infiniteLoop: true,
        mode: 'horizontal',
        auto: true,
        autoStart: true,
        captions: false,
        easing: 'easeInSine',
        autoHover: true,
        randomStart: false,
        pagerLocation: 'bottom',
        pagerType: 'full',
        controls:false,
        pager: true,
        displaySlideQty: 1,
        moveSlideQty: 1,
        speed: 800,
        pause: 3500
    });


    $('.indexList_horizontal_nocontrols').bxSlider({
        infiniteLoop: true,
        mode: 'horizontal',
        auto: true,
        autoStart: true,
        captions: false,
        easing: 'easeInSine',
        autoHover: true,
        randomStart: true,
			pagerLocation: 'top',
			pagerType: 'short',
			pager: true,
			controls:false,
        displaySlideQty: 1,
        moveSlideQty: 1,
        speed: 500,
		pause: 3500	
    });
    
        $('.indexList_fade_with_captions').bxSlider({
        infiniteLoop: true,
        mode: 'fade',
        auto: true,
        autoStart: true,
        easing: 'easeInSine',
        autoHover: true,
        randomStart: true,
        controls: false,
        pager: false,
        displaySlideQty: 1,
        moveSlideQty: 1,
        speed: 1200,
        pause: 6500,
        captions: true,
        captionsSelector: '.bx-captions',
        onAfterSlide: function(currentSlide, totalSlides) {$('.bx-captions').css("margin-left", "0px"); $('.bx-captions .cufon').css("background", "#fe0000"); Cufon.now();
        } 

    });
    
    //carousel script

    $('.carousel_fade').bxSlider({
        infiniteLoop: true,
        mode: 'fade',
        auto: true,
        autoStart: true,
        captions: false,
        easing: 'easeInSine',
        autoHover: true,
        randomStart: false,
		pagerLocation: 'bottom',
		pagerType: 'full',
		pager: true,
		controls:false,
        displaySlideQty: 1,
        moveSlideQty: 1,
        speed: 1000,
		pause: 4800	
    });

  //  $(window).resize(function() {
//        $('.carousel_fade').css('width','100%').css('height','100%');
 //       $('.bx-wrapper').css('width','100%').css('height','100%');
 //       $('.bx-window').css('width','100%').css('height','100%');
 // });
    //end carousel script
    

    
    $('#productlist_hor1').bxSlider({
        infiniteLoop: true,
        mode: 'horizontal',
        auto: true,
        autoStart: true,
        easing: 'easeInSine',
        autoHover: true,
        randomStart: true,
        controls: true,
        pager: false,
        displaySlideQty: 1,
        moveSlideQty: 1,
        speed: 800,
        pause: 3000,
        captions: false
    });
    
    $('#productlist_hor4').bxSlider({
        infiniteLoop: true,
        mode: 'horizontal',
        auto: true,
        autoStart: true,
        easing: 'easeInSine',
        autoHover: true,
        randomStart: true,
        controls: true,
        pager: false,
        displaySlideQty: 4,
        moveSlideQty: 1,
        speed: 1200,
        pause: 4000,
        captions: false
    });
    
    $('#productlist_2column').bxSlider({
        infiniteLoop: true,
        mode: 'vertical',
        auto: true,
        autoStart: true,
        easing: 'easeInSine',
        autoHover: true,
        randomStart: true,
        controls: false,
        pager: false,
        displaySlideQty: 1,
        moveSlideQty: 1,
        speed: 800,
        pause: 8000,
        captions: false
    });
    
    $('.assets_rotator').bxSlider({
        infiniteLoop: true,
        mode: 'fade',
        auto: true,
        autoStart: true,
        captions: false,
        easing: 'easeInSine',
        autoHover: true,
        randomStart: true,
        controls: false,
        pager: false,
        displaySlideQty: 1,
        moveSlideQty: 1,
        speed: 800,
        pause: 4800,
        captions: false,
        captionsSelector: null
    });
    
 

    //end carousel script
    
    
    //tabbed article script
    
   		//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;

	});

    
    //end tabbed script
    
  //toggle login script
  
	//$("#login_button a").click(function(){
			//$("#login_box").toggleClass("active").slideToggle("slow");
			//$("#login_button").toggleClass("active");
	      // });

  //end toggle login

  
  
  //toggle container script
  
  $(".toggle_container li h5 a").parent().next().hide();
	$(".toggle_container li h5 a").click(function(){
			$(this).toggleClass("active").parent().next().slideToggle("slow");
	});
  
  //end toggle container

    //## call the function to resize the edit overlay so it matches the content actually in the region.
    resizeOverlay();
  
  
  //feature list script

(function($) {
	$.fn.featureList = function(options) {
		var tabs	= $(this);
		var output	= $(options.output);

		new jQuery.featureList(tabs, output, options);

		return this;	
	};

	$.featureList = function(tabs, output, options) {
		function slide(nr) {
			if (typeof nr == "undefined") {
				nr = visible_item + 1;
				nr = nr >= total_items ? 0 : nr;
			}

			tabs.parent().removeClass('current').filter(":eq(" + nr + ")").addClass('current');

			output.stop(true, true).filter(":visible").fadeOut();
			output.filter(":eq(" + nr + ")").fadeIn(function() {
				visible_item = nr;	
			});
		}

		var options			= options || {}; 
		var total_items		= tabs.length;
		var visible_item	= options.start_item || 0;

		options.pause_on_hover		= options.pause_on_hover		|| true;
		options.transition_interval	= options.transition_interval	|| 5000;

		output.hide().eq( visible_item ).show();
		tabs.parent().eq( visible_item ).addClass('current');

		tabs.click(function() {
			if ($(this).hasClass('current')) {
				return false;	
			}

			slide( tabs.index( this) );
		});

		if (options.transition_interval > 0) {
			var timer = setInterval(function () {
				slide();
			}, options.transition_interval);

			if (options.pause_on_hover) {
				tabs.mouseenter(function() {
					clearInterval( timer );

				}).mouseleave(function() {
					clearInterval( timer );
					timer = setInterval(function () {
						slide();
					}, options.transition_interval);
				});
			}
		}
	};
})(jQuery);

//end feature list script
});



function resizeOverlay() {
    var toArray;
    var locStr
    var locID;

    //## create an array of template overlay regions, then loop through each one adjusting it's height
    //## to match that of the acutal page template.  This will ensure they overlap correctly even if the 
    //## contained content grows the div.
    toArray = $("#templateoverlay").find("div");
    toArray.each(function(i) {
        locStr = $(this).attr('id');
        if (locStr.substr(0, 14) == "templateregion") {
            locID = locStr.substr(14, locStr.length - 13);
            $(this).css('height', $('#template').find('#region' + locID).css('height'));
            $(this).css('width', $('#template').find('#region' + locID).css('width'));
        }
    });
    
    

}


//tooltip code

function movetooltip(tooltipname){
    $(tooltipname).css("left",mouseX + 10);
    $(tooltipname).css("top",mouseY + 10);  
}

function tipshow(obj_tooltip){
    $(tooltipid).hide();
    $(tooltipid).removeClass("tooltipactive"); 
    var tooltipid = "#"+obj_tooltip;
    $(tooltipid).fadeIn('slow');
    $(tooltipid).css("left",mouseX + 10);
    $(tooltipid).css("top",mouseY + 10);
    $(tooltipid).addClass("tooltipactive");    
}

function tiphide(obj_tooltip){
    var tooltipid = "#"+obj_tooltip;
    $(tooltipid).fadeOut('fast');
    $(tooltipid).removeClass("tooltipactive"); 
}

function tipurl(url, opt){
  if (opt == 0) // current window
    window.location = url;
  else if (opt == 1) // new window
    window.open(url);
  else if (opt == 2) // background window
    {window.open(url); self.focus();}
}

//end tooltip code

/*

//rss feed
var gfeedfetcher_loading_image="/images/page-images/loader.gif" //Full URL to "loading" image. No need to config after this line!!
 
google.load("feeds", "1") //Load Google Ajax Feed API (version 1)
 
function gfeedfetcher(divid, divClass, linktarget){
    this.linktarget=linktarget || "" //link target of RSS entries
    this.feedlabels=[] //array holding lables for each RSS feed
    this.feedurls=[]
    this.feeds=[] //array holding combined RSS feeds' entries from Feed API (result.feed.entries)
    this.feedsfetched=0 //number of feeds fetched
    this.feedlimit=5
    this.showoptions="" //Optional components of RSS entry to show (none by default)
    this.sortstring="date" //sort by "date" by default
    document.write('<div id="'+divid+'" class="'+divClass+'"></div>') //output div to contain RSS entries
    this.feedcontainer=document.getElementById(divid)
    this.itemcontainer="<li>" //default element wrapping around each RSS entry item
}
 
gfeedfetcher.prototype.addFeed=function(label, url){
    this.feedlabels[this.feedlabels.length]=label
    this.feedurls[this.feedurls.length]=url
}
 
gfeedfetcher.prototype.filterfeed=function(feedlimit, sortstr){
    this.feedlimit=feedlimit
    if (typeof sortstr!="undefined")
    this.sortstring=sortstr
}
 
gfeedfetcher.prototype.displayoptions=function(parts){
    this.showoptions=parts //set RSS entry options to show ("date, datetime, time, snippet, label, description")
}
 
gfeedfetcher.prototype.setentrycontainer=function(containerstr){  //set element that should wrap around each RSS entry item
this.itemcontainer="<"+containerstr.toLowerCase()+">"
}
 
gfeedfetcher.prototype.init=function(){
    this.feedsfetched=0 //reset number of feeds fetched to 0 (in case init() is called more than once)
    this.feeds=[] //reset feeds[] array to empty (in case init() is called more than once)
    this.feedcontainer.innerHTML='<p><img class="textmiddle" src="'+gfeedfetcher_loading_image+'" /> Loading blog feeds...</p>'
    var displayer=this
    for (var i=0; i<this.feedurls.length; i++){ //loop through the specified RSS feeds' URLs
        var feedpointer=new google.feeds.Feed(this.feedurls[i]) //create new instance of Google Ajax Feed API
        var items_to_show=(this.feedlimit<=this.feedurls.length)? 1 : Math.floor(this.feedlimit/this.feedurls.length) //Calculate # of entries to show for each RSS feed
        if (this.feedlimit%this.feedurls.length>0 && this.feedlimit>this.feedurls.length && i==this.feedurls.length-1) //If this is the last RSS feed, and feedlimit/feedurls.length yields a remainder
            items_to_show+=(this.feedlimit%this.feedurls.length) //Add that remainder to the number of entries to show for last RSS feed
        feedpointer.setNumEntries(items_to_show) //set number of items to display
        feedpointer.load(function(label){
            return function(r){
                displayer._fetch_data_as_array(r, label)
            }
        }(this.feedlabels[i])) //call Feed.load() to retrieve and output RSS feed.
    }
}
 
gfeedfetcher._formatdate=function(datestr, showoptions){
    var itemdate=new Date(datestr)
    var parseddate=(showoptions.indexOf("datetime")!=-1)? itemdate.toLocaleString() : (showoptions.indexOf("date")!=-1)? itemdate.toLocaleDateString() : (showoptions.indexOf("time")!=-1)? itemdate.toLocaleTimeString() : ""
    return "<span class='datefield'>"+parseddate+"</span>"
}
 
gfeedfetcher._sortarray=function(arr, sortstr){
    var sortstr=(sortstr=="label")? "ddlabel" : sortstr //change "label" string (if entered) to "ddlabel" instead, for internal use
    if (sortstr=="title" || sortstr=="ddlabel"){ //sort array by "title" or "ddlabel" property of RSS feed entries[]
        arr.sort(function(a,b){
        var fielda=a[sortstr].toLowerCase()
        var fieldb=b[sortstr].toLowerCase()
        return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
        })
    }
    else{ //else, sort by "publishedDate" property (using error handling, as "publishedDate" may not be a valid date str if an error has occured while getting feed
        try{
            arr.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)})
        }
        catch(err){}
    }
}
 
gfeedfetcher.prototype._fetch_data_as_array=function(result, ddlabel){
    var thisfeed=(!result.error)? result.feed.entries : "" //get all feed entries as a JSON array or "" if failed
    if (thisfeed==""){ //if error has occured fetching feed
        alert("Some blog posts could not be loaded: "+result.error.message)
    }
    for (var i=0; i<thisfeed.length; i++){ //For each entry within feed
        result.feed.entries[i].ddlabel=ddlabel //extend it with a "ddlabel" property
    }
    this.feeds=this.feeds.concat(thisfeed) //add entry to array holding all feed entries
    this._signaldownloadcomplete() //signal the retrieval of this feed as complete (and move on to next one if defined)
}
 
gfeedfetcher.prototype._signaldownloadcomplete=function(){
    this.feedsfetched+=1
    if (this.feedsfetched==this.feedurls.length) //if all feeds fetched
        this._displayresult(this.feeds) //display results
}
 
gfeedfetcher.prototype._displayresult=function(feeds){
    var rssoutput=(this.itemcontainer=="<li>")? "<ul>\n" : ""
    gfeedfetcher._sortarray(feeds, this.sortstring)
    for (var i=0; i<feeds.length; i++){
        var itemtitle="<a rel=\"nofollow\" href=\"" + feeds[i].link + "\" target=\"" + this.linktarget + "\" class=\"titlefield\">" + feeds[i].title + "</a>"
        var itemlabel=/label/i.test(this.showoptions)? '<span class="labelfield">['+this.feeds[i].ddlabel+']</span>' : " "
        var itemdate=gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions)
        var itemdescription=/description/i.test(this.showoptions)? "<br />"+feeds[i].content : /snippet/i.test(this.showoptions)? "<br />"+feeds[i].contentSnippet  : ""
        rssoutput+=this.itemcontainer + itemtitle + " " + itemlabel + " " + itemdate + "\n" + itemdescription + this.itemcontainer.replace("<", "</") + "\n\n"
    }
    rssoutput+=(this.itemcontainer=="<li>")? "</ul>" : ""
    this.feedcontainer.innerHTML=rssoutput
}

//end rs feed

*/
