// JavaScript Document
var applicationTweenFrameRate=10;
function showApplicationHover(){
	scroll(0,0);
	var mask=document.getElementById('hoverMask');
    var cont=document.getElementById('hoverContent');
    var maskFrame=document.getElementById('hoverIframe');
	if(mask && cont && maskFrame){
		var styleText="display:block; visibility:visible;opacity:0;filter:alpha(opacity=0);";
		var heightStyle=" height:"+document.body.offsetHeight+"px;";
		mask.style.cssText=styleText+heightStyle;
		maskFrame.style.cssText=styleText+heightStyle;
		cont.style.cssText=styleText;
		
		var easefunction=function(aTween){
			var t=aTween._step+1;
			var b=aTween.from;
			var c=aTween.to-aTween.from;
			var d=aTween._stepCount;
			return Math.round(c*((t=t/d-1)*t*t*t*t + 1) + b);	
		}
		
		var tween=new Tween(mask,"alpha",null,0,75,600,applicationTweenFrameRate);
		var tween4=new Tween(cont,"alpha",easefunction,0,100,600,applicationTweenFrameRate);
		//var tween6=new Tween(cont.firstChild,"alpha",easefunction,0,100,600,20);
		//tween4.addTween(tween6);
		var tween5=new Tween(cont,"top",easefunction,-1000,20,600,applicationTweenFrameRate);
		tween.addTween(tween4);
		tween.addTween(tween5);
		/*
		var tween2=new Tween(cont.firstChild,"width",null,0,850,6000,20);
		var tween3=new Tween(cont.firstChild,"margin-right",null,0,-425,6000,20);
		
		
		tween2.addTween(tween3);
		tween2.addTween(tween4);
		*/
		tween.start();
		//tween4.start();
	}
}
function hideApplicationHover(){
	scroll(0,0);
	var mask=document.getElementById('hoverMask');
    var cont=document.getElementById('hoverContent');
    var maskFrame=document.getElementById('hoverIframe');
	if(mask && cont && maskFrame){
		
		var tween=new Tween(mask,"alpha",null,75,0,300,applicationTweenFrameRate);
		var tween4=new Tween(cont,"alpha",null,100,0,300,applicationTweenFrameRate);
		tween.addTween(tween4);
		tween.callback=function(){			
			var styleText="display:none; visibility:hidden;";
			mask.style.cssText=styleText;
			maskFrame.style.cssText=styleText;
			cont.style.cssText=styleText;
		}
		tween.start();
	}
}

var applicationsList={}
applicationsList.currentIndex=0;
applicationsList.currentTween;
applicationsList.currentX=0;
applicationsList.targetX=0;
applicationsList.currentY=0;
applicationsList.targetY=0;
applicationsList.currentHLX=0;
applicationsList.targetHLX=0;
applicationsList.currentHLY=20;
applicationsList.targetHLY=20;
applicationsList.items=[
						{icon: "/static/images/applicationIcons/applicationIcon_video.png", title: "Video Gallery", description: "Users can easily browse and view videos with a 10Duke video gallery for your site"},
						{icon: "/static/images/applicationIcons/applicationIcon_photos.png", title: "Photo Gallery", description: "Display photo thumbnails in a gallery and let users view the ones they want in detail"},
						{icon: "/static/images/applicationIcons/applicationIcon_music.png", title: "Music Player", description: "Give your site visitors something to listen to with a music player and playlist"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_registration.png", title: "Registration and Sign-On", description: "Get users to sign up and activate via email or integrate with an existing database"},
						{icon: "/static/images/applicationIcons/applicationIcon_profiles.png", title: "Profiles", description: "Users of your site can build their own personal space to store their information and content"},
						{icon: "/static/images/applicationIcons/applicationIcon_friends.png", title: "Friends", description: "Let profiles connect and open up interaction features with the friends application"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_comments.png", title: "Commenting", description: "Let users leave short messages on any page of your site with the 10Duke commenting app"},
						{icon: "/static/images/applicationIcons/applicationIcon_privateMessaging.png", title: "Private Messaging", description: "Let users communicate privately with each other by sending email type messages"},
						{icon: "/static/images/applicationIcons/applicationIcon_ratings.png", title: "Ratings", description: "Give your users more interactive features by allowing them to rate content"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_analytics.png", title: "Analytics", description: "Understand your website data and make informed decisions"},
						{icon: "/static/images/applicationIcons/applicationIcon_syndication.png", title: "Content Syndication", description: "Take your brand to the users by syndicating into social networks, blogging platforms and websites"},
						{icon: "/static/images/applicationIcons/applicationIcon_patternRecognition.png", title: "Pattern Recognition", description: "Use pattern recognition to create engagement with applications such as 'face matching'"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_moderation.png", title: "Moderation", description: "Control all aspects of your community with the moderation toolset"},
						{icon: "/static/images/applicationIcons/applicationIcon_mobileDownload.png", title: "Mobile Download", description: "Send content to mobile devices using a 10Duke mobile download application"},
						{icon: "/static/images/applicationIcons/applicationIcon_playlists.png", title: "Playlists", description: "Add videos, photos or audio tracks to a playlist and view or listen to them in order"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_mobileUpload.png", title: "Mobile Upload", description: "Let users upload photos and videos easily from their mobile phones"},
						{icon: "/static/images/applicationIcons/applicationIcon_email.png", title: "Viral Email Invitations", description: "Spread your message by letting users send an email easily to all addresses in their address book"},
						{icon: "/static/images/applicationIcons/applicationIcon_chat.png", title: "Chat", description: "Add engaging discussion or allow customers to ask live questions to your administrator or sales team"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_poll.png", title: "Poll", description: "Get feedback from users and ask questions with the 10Duke poll"},
						{icon: "/static/images/applicationIcons/applicationIcon_search.png", title: "Search", description: "Let users quickly locate content with a search feature"},
						{icon: "/static/images/applicationIcons/applicationIcon_games.png", title: "Games", description: "Integrate your games into a community and engage the users"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_userGroups.png", title: "User Groups", description: "The groups app allows your users to create their own micro communities"},
						{icon: "/static/images/applicationIcons/applicationIcon_events.png", title: "Events", description: "Create an event and share the information through the community"},
						{icon: "/static/images/applicationIcons/applicationIcon_askExpert.png", title: "Ask an Expert", description: "Put questions to a designated respondent"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_rss.png", title: "RSS / MRSS Feed", description: "Syndicate content from your site across the internet and straight to the users with RSS and MRSS"},
						{icon: "/static/images/applicationIcons/applicationIcon_presentations.png", title: "Presentations", description: "Add slide shows for your users to scroll through at their leisure"},
						{icon: "/static/images/applicationIcons/applicationIcon_liveTV.png", title: "Live TV Streaming", description: "Stream live TV from your site and keep users engaged for hours"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_blog.png", title: "Blog", description: "Allow users to share their thoughts and opinions with a blog app"},
						{icon: "/static/images/applicationIcons/applicationIcon_forum.png", title: "Forum", description: "Let users chat, discuss and argue with an engaging forum app"},
						{icon: "/static/images/applicationIcons/applicationIcon_reviews.png", title: "Reviews", description: "Users can review products and services and file them with a reviews app"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_videoTranscoding.png", title: "Video Transcoding", description: "Use our transcoding engine to quickly and easily convert between almost any media types"},
						{icon: "/static/images/applicationIcons/applicationIcon_cms.png", title: "Content Management", description: "Manage the availability and meta data of your own premium content"},
						{icon: "/static/images/applicationIcons/applicationIcon_cdn.png", title: "CDN", description: "Stream and serve content around the world using 10Duke's Content Delivery Network solution"},
						
						{icon: "/static/images/applicationIcons/applicationIcon_maps.png", title: "Maps", description: "Integrate maps and find content by location"},
						{icon: "/static/images/applicationIcons/applicationIcon_mobileAlerts.png", title: "Mobile Alerts", description: "Notify users of events and community features with a mobile alert"}]

applicationsList.showFromIndex=function(index){
	if(index<0){
		index=this.items.length-3;		
		if(this.items.length%3!=0){
			index=this.items.length-this.items.length%3;	
		}
	}
	if(index>this.items.length){
		index=0;	
	}
	if(this.currentTween!=null){
		this.currentTween.pause();
	}
	this.currentIndex=index;
	/*var d= document.getElementById('applicationsContent');
	if(d){
			var s=[];
			s[s.length]='<div class="elementSet">';
            for(var i=index; i<index+3 && this.items.length; i++){
	            if(this.items[i]){
					s[s.length]='<div class="item">';
					s[s.length]='<img id="icon" src="';
					s[s.length]=this.items[i].icon;
					s[s.length]='" alt="" title="" width="230" />';
					s[s.length]='<h2 id="title">';
					s[s.length]=this.items[i].title;
					s[s.length]='</h2>';
            		s[s.length]='<p id=description: "DESCRIPTION">';
					s[s.length]=this.items[i].description;
					s[s.length]='</p>';
                    s[s.length]='</div>';
				}
			}
            s[s.length]='</div>';
			d.innerHTML=s.join('');
			d=document.getElementById("applicationsList_"+this.currentIndex);
			if(d){
				d.className="elementSet";	
			}
			this.currentIndex=index;
			d=document.getElementById("applicationsList_"+this.currentIndex);
			if(d){
				d.className="elementSet selected";	
			}
	}*/
	var l=document.getElementById('applicationsList');
	if(l){
		var divs=l.getElementsByTagName('div');
		if(divs){
			for(var i in divs){
				if(divs[i].className && divs[i].className.indexOf("selected")!=-1){
					divs[i].className=divs[i].className.split("selected").join("");
				}
			}
			var sel=document.getElementById('applicationsList_'+this.currentIndex);
			if(sel){
				sel.className="elementSet selected";											   
			}
		}
		
	}
	var img=document.getElementById("applicationIcon_"+this.currentIndex);
	if(img && img.src!=this.items[this.currentIndex].icon){
		img.src=this.items[this.currentIndex].icon;
	}
	img=document.getElementById("applicationIcon_"+(this.currentIndex+1));
	if(this.items.length>(this.currentIndex+1) && img && img.src!=this.items[this.currentIndex+1].icon){
		img.src=this.items[this.currentIndex+1].icon;
	}
	img=document.getElementById("applicationIcon_"+(this.currentIndex+2));
	if(this.items.length>(this.currentIndex+2) && img && img.src!=this.items[this.currentIndex+2].icon){
		img.src=this.items[this.currentIndex+2].icon;
	}

	var d= document.getElementById('applicationsContentView');
	if(d){
		if(index==0){
			this.targetX=0;
			this.targetY=0;
			this.targetHLX=0;
			this.targetHLY=20;
		}
		else if(index==3){
			this.targetX=-830;
			this.targetY=0;
			this.targetHLX=262;
			this.targetHLY=20;
		}
		else if(index==6){
			this.targetX=-1660;
			this.targetY=0;
			this.targetHLX=524;
			this.targetHLY=20;
		}
		else if(index==9){
			this.targetX=0;
			this.targetY=-296;
			this.targetHLX=0;
			this.targetHLY=122;
		}
		else if(index==12){
			this.targetX=-830;
			this.targetY=-296;
			this.targetHLX=262;
			this.targetHLY=122;
		}
		else if(index==15){
			this.targetX=-1660;
			this.targetY=-296;
			this.targetHLX=524;
			this.targetHLY=122;
		}
		else if(index==18){
			this.targetX=0;
			this.targetY=-592;
			this.targetHLX=0;
			this.targetHLY=224;
			
		}
		else if(index==21){
			this.targetX=-830;
			this.targetY=-592;
			this.targetHLX=262;
			this.targetHLY=224;
			
		}
		else if(index==24){
			this.targetX=-1660;
			this.targetY=-592;
			this.targetHLX=524;
			this.targetHLY=224;
			
		}
		else if(index==27){
			this.targetX=0;
			this.targetY=-886;
			this.targetHLX=0;
			this.targetHLY=326;
			
		}
		else if(index==30){
			this.targetX=-830;
			this.targetY=-886;
			this.targetHLX=262;
			this.targetHLY=326;
			
		}
		else if(index==33){
			this.targetX=-1660;
			this.targetY=-886;
			this.targetHLX=524;
			this.targetHLY=326;
			
		}
		var easefunction=function(aTween){
			var t=aTween._step+1;
			var b=aTween.from;
			var c=aTween.to-aTween.from;
			var d=aTween._stepCount;
			
			if ((t/=d/2) < 1){
				return  Math.round(c/2*t*t*t*t*t + b);
			}
			return  Math.round(c/2*((t-=2)*t*t*t*t + 2) + b);
		};
		var tweenTime=1000;
		if(this.currentTween!=null){
			var cx,cy, chlx,chly;
			cx=this.currentTween.modifyValue(this.currentTween.easing(this.currentTween));
			if(this.currentTween.tweens && this.currentTween.tweens[0]){
				cy=this.currentTween.tweens[0].modifyValue(this.currentTween.tweens[0].easing(this.currentTween.tweens[0]));
			}
			if(this.currentTween.tweens && this.currentTween.tweens[1]){
				chlx=this.currentTween.tweens[1].modifyValue(this.currentTween.tweens[1].easing(this.currentTween.tweens[1]));
			}
			if(this.currentTween.tweens && this.currentTween.tweens[2]){
				chly=this.currentTween.tweens[2].modifyValue(this.currentTween.tweens[2].easing(this.currentTween.tweens[2]));
			}
			if(cx != null && cy != null){
				this.currentX=cx;
				this.currentY=cy;
			}
			if(chlx != null && chly != null){
				this.currentHLX=chlx;
				this.currentHLY=chly;
			}
			
			easefunction=function(aTween){
				var t=aTween._step+1;
				var b=aTween.from;
				var c=aTween.to-aTween.from;
				var d=aTween._stepCount;
				return Math.round(c*((t=t/d-1)*t*t*t*t + 1) + b);	
			}
		}	
		this.currentTween=new Tween(d,"left",easefunction,this.currentX,this.targetX,tweenTime,applicationTweenFrameRate);
		var tween2=new Tween(d,"top",easefunction,this.currentY,this.targetY,tweenTime,applicationTweenFrameRate);
		this.currentTween.addTween(tween2);
		
		var highLighter = document.getElementById("applicationsHighlight");
		if(highLighter){
			var tween3=new Tween(highLighter,"left",easefunction,this.currentHLX,this.targetHLX,tweenTime,applicationTweenFrameRate);
			var tween4=new Tween(highLighter,"top",easefunction,this.currentHLY,this.targetHLY,tweenTime,applicationTweenFrameRate);
			this.currentTween.addTween(tween3);
			this.currentTween.addTween(tween4);
		}
		var me=this;
		this.currentTween.callback=function(){
			me.currentTween=null;
			me.currentX=me.targetX;
			me.currentY=me.targetY;
			me.currentHLX=me.targetHLX;
			me.currentHLY=me.targetHLY;
		}
		this.currentTween.start();
		
	}
}
