// Copyright (c) 2011 Streamonix Ltd.

function initializeJQuery()
{jQuery(document).ready(function($)
{var tabContainers=$(".tab_content");tabContainers.hide();$(window).bind('hashchange',function()
{var hash=location.hash;if(hash=="")
{$("ul.tabs li:first").addClass("current").show();$(".tab_content:first").show();}
else
{$("ul.tabs li").removeClass("current");$("ul.tabs li:has(a[href="+hash+"])").addClass("current").show();tabContainers.hide();$(hash).fadeIn();}});$(window).trigger("hashchange");});}
function writeEmailAddress(address1,address2,address3)
{var address=address1+"@"+address2+address3;document.write("<a href=\"mailto:"+address+"\">"+address+"</a>");}
function writePhoneNumber(stringStart,var1,var2,var3,var4)
{document.write(stringStart+var1+var2+"-"+var3+"-"+var4);}
function SXHasClass(inElement,inClass)
{return inElement.className.match(new RegExp('(\\s|^)'+inClass+'(\\s|$)'));}
function SXAddClass(inElement,inClass)
{if(!SXHasClass(inElement,inClass))
inElement.className+=" "+inClass;}
function SXRemoveClass(inElement,inClass)
{if(SXHasClass(inElement,inClass))
{var reg=new RegExp('(\\s|^)'+inClass+'(\\s|$)');inElement.className=inElement.className.replace(reg,' ');}}
function SXSlide(inBackgroundImage,inBackgroundImageHeight,inMenuClass,inTitleImage,inDescription,inOwner,inOwnerURL)
{this.backgroundImage=inBackgroundImage;this.backgroundImageHeight=inBackgroundImageHeight;this.menuClass=inMenuClass;this.titleImage=inTitleImage;this.description=inDescription;this.owner=inOwner;this.ownerURL=inOwnerURL;}
var gSlideShow;function SXSlideShow(inSlideShowID,inIsRandomFirst,inIsRandomSequence,inSlideDataArray)
{var element=document.getElementById(inSlideShowID);element.innerHTML='';for(var i=0;i<inSlideDataArray.length;i++)
element.innerHTML+='<div id="id'+i+'">  </div>\n';this.slideShowID=inSlideShowID;this.slideDivs=$('#'+this.slideShowID+' div');this.slideIndex=0;this.isRandomFirst=inIsRandomFirst;this.isRandomSequence=inIsRandomSequence;this.photoInfoDialogArray=[];this.init(inSlideDataArray);}
SXSlideShow.prototype.init=function(inSlideDataArray)
{var menus='<p class="menus">\n \
       <a class="CLASS" href="/news.html" NEWS_MENU>NEWS</a>\n \
       <a class="CLASS" href="/company.html" COMPANY_MENU>COMPANY</a>\n \
       <a class="CLASS" href="/partners.html" PARTNERS_MENU>PARTNERS</a>\n \
       <a class="CLASS" href="/contact.html" CONTACT_MENU>CONTACT</a>\n \
       </p>\n';var titleTemplate='<a href="products.html">\n \
       <img class="CLASS" src="images/backgrounds/IMAGE" alt="video streaming and storage systems" />\n \
       </a>\n';var slideCount=this.slideDivs.length;var index=(this.isRandomFirst?(Math.floor(Math.random()*slideCount)):0);for(var i=0;i<slideCount;i++)
{var photoInfoID='photoInfo';var slideData=inSlideDataArray[i];var slideDiv=this.slideDivs[i];var buttonTopStyle='style="top: '+(slideData.backgroundImageHeight-30)+'px;"';var captionTopStyle='style="top: '+slideData.backgroundImageHeight+'px;"';var counter='<p class="counter" '+captionTopStyle+'>Image <span>'+(i+1)+'</span> of '+slideCount+'</p>\n';var button='<button id="'+photoInfoID+i+'" '+buttonTopStyle+' title="Click for credits and license info">&copy;</button>\n';var caption='<p class="caption" '+captionTopStyle+'>'+slideData.description+'</p>\n';slideDiv.innerHTML=menus.replace(/CLASS/g,slideData.menuClass)+'\n'+
titleTemplate.replace('IMAGE',slideData.titleImage)+'\n'+
counter+button+caption;slideDiv.style.backgroundImage='url(/images/backgrounds/water/'+slideData.backgroundImage+')';var photoInfo='<p>Photo of '+slideData.description+'.<br />Photographed by '+slideData.owner+'.<br />'+'Original image available  <a href="'+slideData.ownerURL+'">here</a>. <br />'+'This image is licensed under a <br /><a href="http://creativecommons.org/licenses/by/3.0">Creative Commons Attribution License</a>.</p>';this.initPhotoInfoDialog(i,photoInfoID,photoInfo);}
this.slideDivs[index].className+=' active';}
SXSlideShow.prototype.initPhotoInfoDialog=function(inIndex,inID,inText)
{$('#'+inID+inIndex).click(function()
{$.modal('<div><h1>Image '+(inIndex+1)+':<span> Info &amp; Credits</span></h1><p>'+inText+'</p></div>');return false;});}
SXSlideShow.prototype.Run=function()
{var $active=$('#'+this.slideShowID+' div.active');var $next;if($active.length==0)
$active=$('#'+this.slideShowID+' div:last');if(this.isRandomSequence)
{var siblings=$active.siblings();var slideIndex=this.slideIndex;while(slideIndex==this.slideIndex)
slideIndex=Math.floor(Math.random()*siblings.length);this.slideIndex=slideIndex;$next=$(siblings[slideIndex]);}
else
{$next=($active.next().length>0?$active.next():$('#'+this.slideShowID+' div:first'));}
$active.addClass('last-active');$next.css({opacity:0.0}).addClass('active').animate({opacity:1.0},1500,function(){$active.removeClass('active last-active');});}
function SXAccordion(inName)
{this.name=inName;this.array=[];}
SXAccordion.prototype.init=function(inAccordionULID,inHeaderElementTag,inMode,inIndex,inActiveClass)
{var i=count=0;var nodes=document.getElementById(inAccordionULID).childNodes;var nodesLength=nodes.length;this.activeClass=inActiveClass;this.mode=inMode;for(i;i<nodesLength;i++)
{var node=nodes[i];if(node.nodeType!=3)
{this.array[count]={};this.array[count].headerElement=headerElement=node.getElementsByTagName(inHeaderElementTag)[0];this.array[count].divElement=divElement=node.getElementsByTagName('div')[0];headerElement.onclick=new Function(this.name+'.expand(0,'+count+')');if(inIndex==count)
{headerElement.activeClass=this.activeClass;divElement.style.height='auto';divElement.expanded=1;}
else
{divElement.style.height=0;divElement.expanded=-1;}
count++;}}
this.nodesLength=count;}
SXAccordion.prototype.expand=function(inExpanded,inIndex)
{for(var i=0;i<this.nodesLength;i++)
{var headerElement=this.array[i].headerElement;var divElement=this.array[i].divElement;var styleHeight=divElement.style.height;styleHeight=(styleHeight=='auto'?1:parseInt(styleHeight));clearInterval(divElement.time);if((styleHeight!=1&&divElement.expanded==-1)&&(inExpanded==1||i==inIndex))
{divElement.style.height='';divElement.expandedHeight=divElement.offsetHeight;divElement.style.height=styleHeight+'px';divElement.expanded=1;headerElement.activeClass=this.activeClass;sx_set_interval(divElement,1);}
else if(styleHeight>0&&(inExpanded==-1||this.mode||i==inIndex))
{divElement.expanded=-1;headerElement.activeClass='';sx_set_interval(divElement,-1);}}}
SXAccordion.prototype.toString=function()
{return this.name;}
function sx_set_style(inDivElement)
{var offsetHeight=inDivElement.offsetHeight;var height=(inDivElement.expanded==1?inDivElement.expandedHeight-offsetHeight:offsetHeight);inDivElement.style.height=offsetHeight+(Math.ceil(height/5)*inDivElement.expanded)+'px';if((inDivElement.expanded==1&&offsetHeight>=inDivElement.expandedHeight)||(inDivElement.expanded!=1&&offsetHeight==1))
{if(inDivElement.expanded==1)
inDivElement.style.height='auto';clearInterval(inDivElement.time);}}
function sx_set_interval(inDivElement)
{inDivElement.time=setInterval(function(){sx_set_style(inDivElement)},20);}
