if(!String.prototype.startsWith){
    String.prototype.startsWith = function (str) {
        return !this.indexOf(str);
    }
}

var bLoadTab = false;	
var current_tab = 1;

var current_button_class = "tab_button";

function tabActivate(element_id, num){
	if(num != current_tab){
		var oElement = document.getElementById(element_id);
		var className = oElement.className;
		var useClass = "";
		if(className.startsWith("tab_previous")){
			useClass = "tab_previous";
		}
		if(className.startsWith("tab_next")){
			useClass = "tab_next";
		}
		if(className.startsWith("tab_button")){
			useClass = "tab_button";
		}
		oElement.className = useClass + "_active";
	}
}

function tabDeactivate(element_id, num){
	if(num != current_tab){
		var oElement = document.getElementById(element_id);
		var className = oElement.className;
		var useClass = "";
		if(className.startsWith("tab_previous")){
			useClass = "tab_previous";
		}
		if(className.startsWith("tab_next")){
			useClass = "tab_next";
		}
		if(className.startsWith("tab_button")){
			useClass = "tab_button";
		}
		oElement.className = useClass + "";
	}
}

function tabChange(tab){
	var oElement = document.getElementById('tab1');
	oElement.className = 'tab_button';
	var oElement = document.getElementById('tab2');
	oElement.className = 'tab_button';
	var oElement = document.getElementById('tab3');
	oElement.className = 'tab_button';
	var oElement = document.getElementById('tab4');
	oElement.className = 'tab_button';
	var oElement = document.getElementById('tab5');
	oElement.className = 'tab_button';
	var oElement = document.getElementById(tab);
	oElement.className = 'tab_button_active';
}
function setInfo(section_header){
	var oElement = document.getElementById('section1_text');
	oElement.innerHTML = section_header;
}
function tabPrevious(){
	var next_tab = current_tab - 1;
	tab(next_tab);
}
function tabNext(){
	var next_tab = current_tab + 1;
	tab(next_tab);
}
function tab(iTabNumber){
	
	changeView(true);
	
	// Min and Max
	if(iTabNumber < 1){ iTabNumber = 1;	}
	if(iTabNumber > 5){ iTabNumber = 5;	}
	
	var tab_slogans = new Array();
	tab_slogans[1] = "Real-Time Information Solutions";
	tab_slogans[2] = "Accurate Data Anywhere, Anytime";
	tab_slogans[3] = "Process Engineering";
	tab_slogans[4] = "Intelligent Paperless Solutions";
	tab_slogans[5] = "Customer Driven Solutions";
	var sHeader = tab_slogans[iTabNumber];
	
	tabChange("tab"+iTabNumber);
	var section_header = sHeader;
	setInfo(section_header);
	
	if(iTabNumber < 5){
		loadVideoTab("ePort"+iTabNumber+"_vid");
	}
	else{
		loadSolutionsTab();
	}
	
	if(bLoadTab == true) {
		if(current_tab != iTabNumber){
			slideshow.pos(iTabNumber-1);
		}
		$("#WhatWeDo").click();
	}
	
	current_tab = iTabNumber;
	bLoadTab = true;
	
	canBlink  = false;
	
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		setTimeout('blinkButtonCheck()', 16000); // 16 seconds
	}
}

var setClass = 'tab_button';
var canBlink = false;

function blinkButtonCheck(){
	canBlink = true;
}

function blinkButton(){
	if(canBlink){
		if(setClass == 'tab_button'){
			setClass = 'tab_button_active';
		}
		else{
			if(setClass == 'tab_button_active'){
				setClass = 'tab_button';
			}
		}
		try{
			var oElement = document.getElementById("tab"+(current_tab+1));
			oElement.className = setClass;
		}
		catch(error){}
	}
	setTimeout('blinkButton()', 500);
}

function loadVideoTab(sVideoFile){
	
	var oElement = document.getElementById('movie_tab');
	var iVideoWidth = 760;
	var iVideoHeight = 240;
	
	if(myBrowser == 'Android' || myBrowser == 'iPhone'){
		iVideoWidth = 320;
		iVideoHeight = 101;
	}
	var data = '<div id="webkit_movie_wrapper">'
		+'<video id="webkit_movie_wrapper-video" poster="" width="'+iVideoWidth+'" height="'+iVideoHeight+'" autoplay="autoplay" src="video/'+sVideoFile+'.mp4" onended="blinkButtonCheck();" ></video></div>'
		+'<div id="firefox_movie_wrapper"></div>'
		+'<div id="ie_movie_wrapper">'
		+"	<!--[if lt IE 9]>"
		+ '<OBJECT ID="webkit_movie_wrapper-object" WIDTH="'+iVideoWidth+'" HEIGHT="'+iVideoHeight+'" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"'
		+ ' STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject"> '
		+	'<PARAM NAME="FileName" VALUE="video/'+sVideoFile+'.wmv">'
		+	'<PARAM name="ShowControls" VALUE="false">'
		+	'<param name="ShowStatusBar" value="false">'
		+	'<PARAM name="ShowDisplay" VALUE="false">'
		+	'<PARAM name="autostart" VALUE="true">'
		+	'<PARAM name="scale" VALUE="tofit">'
		+	'<PARAM name="windowlessVideo" VALUE="true">'
		+	'<EMBED id="webkit_movie_wrapper-embed" TYPE="application/x-mplayer2" SRC="video/'+sVideoFile+'.wmv" NAME="MediaPlayer"'
		+	'WIDTH="'+iVideoWidth+'" HEIGHT="'+iVideoHeight+'" ShowControls="0" ShowStatusBar="0" ShowDisplay="0" autostart="1" windowlessVideo="true" scale="tofit" > </EMBED>'
		+	'</OBJECT>'
		+"	<![endif]-->"
		+"</div>";
	
	oElement.innerHTML = data;
	
	crossBrowserVideo(sVideoFile);
	changeView(true); // Resets view after video creation
	
}

function crossBrowserVideo(sVideoFile){
	
	var iVideoWidth = 760;
	var iVideoHeight = 240;
	
	if(myBrowser == 'Android' || myBrowser == 'iPhone'){
		iVideoWidth = 320;
		iVideoHeight = 101;
	}
	
	//if browser is firefox, remove the webkit div
	// then put firefox video in the firefox div
	if($.browser.mozilla){
	  $('#webkit_movie_wrapper').remove();
	  
	  if(false){
		  $('#firefox_movie_wrapper').append("<video id='firefox_movie_wrapper-video' width='"+iVideoWidth+"' height='"+iVideoHeight+"' autoplay='autoplay' src='video/"+sVideoFile+".ogv' poster='your_pic.jpg' onended='blinkButtonCheck();' >");
	  }
	  else{
		  if(true){
			  // possible firefox flash video
			  // TODO figure out how to remove controls and replay button
			  $('#firefox_movie_wrapper').append('<object id="firefox_movie_wrapper-video" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+iVideoWidth+'px" height="'+(iVideoHeight+10)+'px" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0">'
			      	+'<param name="src" value="video/'+sVideoFile+'_controller.swf"/>'
			      	+'<param name="bgcolor" value="#1a1a1a"/>'
			      	+'<param name="quality" value="best"/>'
			      	+'<param name="allowScriptAccess" value="always"/>'
			      	+'<param name="allowFullScreen" value="true"/>'
			      	+'<param name="scale" value="exactfit"/>'
			      	+'<param name="wmode" value="transparent"/>'
			      	+'<param name="menu" value="false"/>'
			      	+'<param name="flashVars" value="showendscreen=false&controller=false&autostart=true#&thumb=FirstFrame.png&thumbscale=45&color=0x000000,0x000000"/>'
			      	+'<embed menu="false" wmode="transparent" id="firefox_movie_wrapper-embed" name="firefox_movie_wrapper-video" src="video/'+sVideoFile+'_controller.swf" width="'+iVideoWidth+'px" height="'+(iVideoHeight+10)+'px" bgcolor="#1a1a1a" quality="best" allowScriptAccess="always" allowFullScreen="true" scale="exactfit" flashVars="showendscreen=false&controller=false&autostart=true&thumb=FirstFrame.png&thumbscale=45&color=0x000000,0x000000" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>'
			      	+'</object>');
		  }
		  else{
			  // jw player
			  $('#firefox_movie_wrapper').append(''
				      	+'<div id="mediaplayer">JW Player goes here</div>'
				      	+'<script type="text/javascript" src="js/jwplayer.js"></script>'
				      	+'<script type="text/javascript">'
				      	+'	jwplayer("mediaplayer").setup({'
				      	+'		flashplayer: "video/player.swf",'
				      	+'		file: "video/'+sVideoFile+'.mp4",'
				      	+'		image: "preview.jpg",'
				      	+'		width: 760,'
				      	+'		height: 240,'
				      	+'		events: {onComplete: function() { blinkButtonCheck();}}'
				      	+'	});'
				      	+'</script>'
				      	+'');
		  }
	  }
	  
	}
	else{
		// remove firefox wrapper if not using
		$('#firefox_movie_wrapper').remove();
	}
	
	//grab version of browser visiting in the page
	//just grab it's version number,
	//cause we're looking for ie9
	var ieVersion = $.browser.version;
	
	//if browser is IE and less than IE9
	//that means it is incompatible with
	//html5 video
	//if so remove the webkit & ff movies
	if ($.browser.msie && ieVersion < 9 ) {
	    $('#webkit_movie_wrapper').remove();
	    $('#firefox_movie_wrapper').remove();
	}
	else{
		//otherwise, remove the ie movie
		$('#ie_movie').remove();
	}
}

function renderInfoSlides(){
	slideshow=new TINY.slider.slide('slideshow',{
		id:'slider',
		auto:0,
		resume:false,
		vertical:false,
		navid:'pagination',
		activeclass:'current',
		position:0,
		rewind:false,
		elastic:true
	});			
}

function contact_us(text){
	if(text == undefined)	{ 	text = "";				}
	if(text == "")			{	text = "Contact Us";	}
	var full_text = "<span class='footer-link' onclick='$(\"#Contact\").click();' >"+text+"</span>";
	return full_text;
}

var scrollY = 0;
var scrollGo = false;
var scrollYMax = 0; // calculated
var scrollYMaxOffset = -150;
var current_folder_tab = 1;
var scrollYAmount = 0;
function current_f_tab(i){
	current_folder_tab = i;
}
function scrollUp(_oElement, e){
	var patt=/onmousedown/igm;
	var myTest = patt.test(_oElement.onmousedown);
	if(myTest && e.type == 'click'){
		// ignore

	} else if (myTest == false) {
		// click
		scrollGo = true;
		scrollY = 20;
		scrollYAmount = 120;
	} else {
		// mouse down
		scrollGo = true;
		if(myBrowser != 'Android' && myBrowser != 'iPhone' ){
			scrollY = 1;
			scrollYAmount = 9999;
		} else {
			scrollY = 20;
			scrollYAmount = 120;
		}
	}
}
function scrollDown(_oElement, e){
	var patt=/onmousedown/igm;
	var myTest = patt.test(_oElement.onmousedown);
	if(myTest && e.type == 'click'){
		// ignore
	} else if (myTest == false) {
		// click
		scrollGo = true;
		scrollY = -20;
		scrollYAmount = 120;
	} else {
		// mouse down
		scrollGo = true;
		if(myBrowser != 'Android' && myBrowser != 'iPhone' ){
			scrollY = -1;
			scrollYAmount = 9999;
		} else {
			scrollY = -20;
			scrollYAmount = 120;
		}
	}
}
function scrollStop(e){
	if(myBrowser != 'Android' && myBrowser != 'iPhone' ){
		scrollGo = false;
	}
}
function scrollInnerText(){

	if(scrollGo){
		try{
			if(scrollYAmount > 0){
				scrollYAmount -= Math.abs(scrollY);
			}
			else{
				scrollGo = false;
			}
			
			var oElement = document.getElementById('folder-inner-'+current_folder_tab);
			var element_width = oElement.offsetWidth;
			
			var h_check = $('#folder-inner-'+current_folder_tab).height();
			var h_check2 = $('#folder-inner-div-right').height();
			scrollYMax = (h_check - h_check2) - (h_check2 * 0.5);
			
			var innerTextY = $('#folder-inner-'+current_folder_tab).position().top;
			innerTextY = innerTextY + scrollY;
			var scrollOK = true;
			if(innerTextY < scrollYMaxOffset - scrollYMax){
				if(scrollY < 0){
					scrollOK = false;
				}
			}
			if(innerTextY > scrollYMaxOffset){
				if(scrollY > 0){
					scrollOK = false;
				}
			}
			if(scrollOK){	
				oElement.style.top = innerTextY + 'px';
			}
		}
		catch(error){}
	}
	setTimeout('scrollInnerText()', 5);
}

function loadSolutionsTab(){
	current_f_tab(1);
	
	innerTextY = 0;
	
	var oElement = document.getElementById('movie_tab');
	
	var title_A = "<h2>Supply Chain Management</h2>";
	var infotxA = "<span class='folder-highlight' >Supply Chain Management</span> (SCM) doesn't just  apply to shipping. Our extensive knowledge of shipping and logistics translates directly to situations where the need is to efficiently track physical assets. We build mobile solutions based on the real world not theory. Our ground based, mobile, real-time solution, <span class='folder-highlight' >Pass&Stow&trade;</span> manages the flow of high value items along complex supply chains. We manage operational process flow with easy to use mobile applications.<br><br>Our solutions have been in use for over a decade and are used by seaports, shipping lines, steel mills, oil refineries, US Navy warehouses and an off-shore US Navy base. Over 400 man-years of experience in logistics are built into <span class='folder-highlight' >Pass&Stow&trade;</span> and that is why it works.";
	var pic___A = "<center><img class='background_image' src='imgs/folder/chain2.png' alt='' ></center>";
	
	var title_B = "<h2>Security</h2>";
	var infotxB = "ePortPass&trade; is a revolution in identity verification. Who wants access to a location and are they allowed?  That's what you need to know when it comes to protecting your valuable people and assets. ePortPass&trade; solves the problem with the intelligent use of biometrics. We use palm vein scanning or iris scanning or facial recognition to provide positive, real-time identity verification in under two (2) seconds.  It isn't just about securing a perimeter, it's about the whole facility so we made it totally mobile so you can use it anywhere.<br><br>Link multiple locations together and easily integrate existing cameras and sensors into a common operating picture. We build tools to let you implement the policies and practices that make sense for you.  ePortPass&trade; is an affordable and common sense solution that is easy to use.";
	var pic___B = "<center><img class='background_image' src='imgs/folder/security.png' alt='' ></center>";
	
	var title_C = "<h2>Field Services</h2>";
	var infotxC = "Manual paper based processes are slow, expensive and inefficient. MobileLogic&trade; is a cloud based platform, tailored to the reality on the ground with sets of real-time field service tools which increase efficiency dramatically.<br><br>Our successful field service applications are mobile and empower the entire workforce by increasing speed, knowledge, accountability and accuracy. These tools give you control over and visibility into your operations. The result is customer satisfaction and increased profits.";
	var pic___C = "<center><img class='background_image' src='imgs/folder/fieldsvc.jpg' alt='' ></center>";
	
	var title_D = "<h2>Compliance</h2>";
	var infotxD = "Assets out of compliance cost money. In most industries compliance and certification monitoring is a time consuming paper based, inefficient and expensive process.<br><br>ePortation gives you tools to identify, in real-time, the status of any asset. If out of compliance with certification requirements or proper operational standards alerts are automatically generated.<br><br>Our platform allows the easy management of all assets requiring certification and compliance. From fire hoses to trucks to hospital equipment ePortation can do the heavy lifting so you can do the job. Contact us to learn more about MobileLogic&trade;.";
	var pic___D = "<center><img class='background_image' src='imgs/folder/alert_mobile.png' alt='' ></center>";
	
	var title_E = "<h2>Medical</h2>";
	var infotxE = "Hospitals are a complicated logistics environment. A host of interconnected elements have to be properly managed.<br><br>ePortation provides easy to use yet sophisticated on-demand, cloud based solutions to track patients or assets. We also verify and manage identity to reduce fraud, lawsuits and costs. All our products are secure and encrypted to the highest standards. ePortation tools increase overall efficiency, improve patient throughput and lead to big savings.";
	var pic___E = "<br><center><img class='background_image' src='imgs/folder/cadu.png' alt='' ></center>";
	
	var title_F = "<h2>Consulting</h2>";
	var infotxF = "Technology is developing at an unprecedented speed. You need to work with a company that understands the ropes. For over a decade ePortation has provided business process engineering consulting services that analyze, identify, and optimize process flows. We leverage the power of the cloud and combine the right hardware to design solutions that work.<br><br>For over a decade we have worked with and deployed multiple types of handheld devices, cameras, wireless, laser and satellite networks, biometrics, Smartphones and tablets. We know what works.<br><br>A solution should do at least one of two things, either save you money or make you money. ePortation does both.";
	var pic___F = "<center><img class='background_image' src='imgs/folder/ropes.png' alt='' ></center>";
	
	//------------------------------------------------
	
	var buttons_up_down = "<div class='folder-buttons' ><div class='folder-button-up' onMouseDown='scrollUp(this, event);' onClick='scrollUp(this, event);' onMouseUp='scrollStop(event);' onMouseOut='scrollStop(event);' ><img class='folder-arrow-img' src='imgs/folder/up_arrow.png' ></div><div class='folder-button-down' onmousedown='scrollDown(this, event);'  onClick='scrollDown(this, event);' onmouseup='scrollStop(event);' onMouseOut='scrollStop(event);' ><img class='folder-arrow-img' src='imgs/folder/down_arrow.png' ></div></div>";
	
	var info__A = "<div class='folder-inner-div-left' >"+pic___A+"</div><div id='folder-inner-div-right' class='folder-inner-div-right' >"+buttons_up_down+"<div id='folder-inner-1' class='folder-inner'><p>"+infotxA+"</p></div></div>";
	var info__B = "<div class='folder-inner-div-left' >"+pic___B+"</div><div id='folder-inner-div-right' class='folder-inner-div-right' >"+buttons_up_down+"<div id='folder-inner-2' class='folder-inner'><p>"+infotxB+"</p></div></div>";
	var info__C = "<div class='folder-inner-div-left' >"+pic___C+"</div><div id='folder-inner-div-right' class='folder-inner-div-right' >"+buttons_up_down+"<div id='folder-inner-3' class='folder-inner'><p>"+infotxC+"</p></div></div>";
	var info__D = "<div class='folder-inner-div-left' >"+pic___D+"</div><div id='folder-inner-div-right' class='folder-inner-div-right' >"+buttons_up_down+"<div id='folder-inner-4' class='folder-inner'><p>"+infotxD+"</p></div></div>";
	var info__E = "<div class='folder-inner-div-left' >"+pic___E+"</div><div id='folder-inner-div-right' class='folder-inner-div-right' >"+buttons_up_down+"<div id='folder-inner-5' class='folder-inner'><p>"+infotxE+"</p></div></div>";
	var info__F = "<div class='folder-inner-div-left' >"+pic___F+"</div><div id='folder-inner-div-right' class='folder-inner-div-right' >"+buttons_up_down+"<div id='folder-inner-6' class='folder-inner'><p>"+infotxF+"</p></div></div>";
	
	var data = 	''
				+'<div id="folder-wrapper">'
				+' <div id="folder-tabContainer">'
				+'  <div class="folder-tabs">'
				+'    <ul>'
				+'     <li id="folder-tabHeader_1" style="overflow: hidden;" ><center><img src="imgs/icons/icon1.png"></center></li>'
				+'     <li id="folder-tabHeader_2" style="overflow: hidden;" ><center><img src="imgs/icons/icon2.png"></center></li>'
				+'     <li id="folder-tabHeader_3" style="overflow: hidden;" ><center><img src="imgs/icons/icon3.png"></center></li>'
				+'     <li id="folder-tabHeader_4" style="overflow: hidden;" ><center><img src="imgs/icons/icon4.png"></center></li>'
				+'     <li id="folder-tabHeader_5" style="overflow: hidden;" ><center><img src="imgs/icons/icon5.png"></center></li>'
				+'     <li id="folder-tabHeader_6" style="overflow: hidden;" ><center><img src="imgs/icons/icon6.png"></center></li>'
				+'   </ul>'
				+'  </div>'
				+'  <div class="folder-tabscontent">'
				+'   <div class="folder-tabpage" id="folder-tabpage_1">'
				+ title_A
				+ info__A
				+'   </div>'
				+'   <div class="folder-tabpage" id="folder-tabpage_2">'
				+ title_B
				+ info__B
				+'   </div>'
				+'   <div class="folder-tabpage" id="folder-tabpage_3">'
				+ title_C
				+ info__C
				+'   </div>'
				+'   <div class="folder-tabpage" id="folder-tabpage_4">'
				+ title_D
				+ info__D
				+'   </div>'
				+'   <div class="folder-tabpage" id="folder-tabpage_5">'
				+ title_E
				+ info__E
				+'   </div>'
				+'   <div class="folder-tabpage" id="folder-tabpage_6">'
				+ title_F
				+ info__F
				+'   </div>'
				+'  </div>'
				+' </div>'
				+'</div>';
	
	oElement.innerHTML = data;
	
	initFolder();
}







