//JavaScript Document
//Custom Script for Trac Inc.
//Programming by Michael Willis @ butlerworldwide.com
//micwillis@gmail.com

//----------------------------+
// [ Tract Inc Custom Corners ]
//----------------------------+

  window.onload = function()
  {
      settings = {
          tl: { radius: 15 },
          tr: { radius: 15 },
          bl: { radius: 15 },
          br: { radius: 15 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }
	  settings2 = {
          tl: { radius: 15 },
          tr: { radius: 15 },
          bl: { radius: 15 },
          br: { radius: 15 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }
	  settings3 = {
          tl: { radius: 0 },
          tr: { radius: 0 },
          bl: { radius: 10 },
          br: { radius: 10 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }
	  settings4 = {
          tl: { radius: 15 },
          tr: { radius: 15 },
          bl: { radius: 15 },
          br: { radius: 15 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }
	  settings5 = {
          tl: false,
          tr: false,
          bl: { radius: 9 },
          br: { radius: 9 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }
	  
	  settings6 = {
          tl: { radius: 9 },
          tr: { radius: 9 },
          bl: false,
          br: false,
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }
      var myBoxObject = new curvyCorners(settings, "side_menu");
      myBoxObject.applyCornersToAll();
	  
	  var myBoxObject2 = new curvyCorners(settings2, "side_program");
      myBoxObject2.applyCornersToAll();
	  
	  var myBoxObject3 = new curvyCorners(settings3, "tab");
      myBoxObject3.applyCornersToAll();
	  
	  var myBoxObject4 = new curvyCorners(settings4, "custom");
      myBoxObject4.applyCornersToAll();
	  
	  var myBoxObject5 = new curvyCorners(settings5, "tab_container");
      myBoxObject5.applyCornersToAll();
	  
	  var myBoxObject6 = new curvyCorners(settings6, "custom_small");
      myBoxObject6.applyCornersToAll();
  }


//----------------------+
// [Tract Inc Slideshow ]
//----------------------+

	//Preload Image Function
	jQuery.preloadImages = function()
	{
	  for(var i = 0; i<arguments.length; i++)
	  {
		jQuery("<img>").attr("src", arguments[i]);
	  }
	}

	$(document).ready(function() {
	//init				   
	var cur_num = 0;
	var tabLink1, tabLink2, tabLink3;
	var app_array_text = [ 
	//Applet Array TEXT
	//Each of the following lines contain a page of the html text on the homepage applet. Use H2 tags for title and <p> tags for the paragraph.
	"<h2>Right of Way</h2><p>Years of experience in all types of Right of Way (ROW) work has earned TRACT a strong reputation in the industry.  Our agents are state certified and well trained not only in ROW acquisition but also routing, title and condemnation procedures.  So whether your needs are simple tie-in to full blown gathering system, TRACT has the skilled experts to deliver your product from point A to point B.<br/><br/><a href='index.php?act=services'>Learn More!</a></p>",
	
	"<h2>Lease Negotiation</h2><p>With nationwide leasing experience, TRACT has the knowledge and expertise to handle the needs of large clients with a broad base as well as the infrastructure to support smaller operations coast to coast.  From lease take-offs to total project management, TRACT is equipped to deliver according to your requirements - no matter the location or the timeframe.<br/><br/><a href='index.php?act=services'>Learn More!</a></p>",

"<h2>Surface Damages</h2><p>Whether small disputes, pad site damages or condemnations, TRACT is well versed in the art of balancing client needs with land owner demands.  TRACT is dedicated to negotiating and resolving disputes with their client's best interest in mind.<br/><br/><a href='index.php?act=services'>Learn More!</a></p>",

"<h2>GIS Mapping</h2><p>GIS technology has become an essential planning and decision making tool for any industry that utilizes geographic data.  Through a strategic partnership, TRACT and Dynamic Mapping have provided Geographic Information Systems (GIS) mapping services, offering support and consultation to its clients.<br/><br/><a href='index.php?act=services'>Learn More!</a> </p>",

"<h2>Title research</h2><p>TRACT's process for title, staking and permitting, and survey packets has set the standard that is now used by many former and current clients.  Our skilled researchers have the background and know-how to provide surface, mineral and full patented title that you can rely on.<br/><br/><a href='index.php?act=services'>Learn More!</a></p>"
	 ];
	
	var app_array_img = [
	//Applet Array IMAGES
	//Each of the following lines contain a page of the html images on the homepage applet. Use <img> tags for the image use single quotes (') for the src.
	"images/app_row.jpg",
	"images/app_lease.jpg",
	"images/app_damage.jpg",
	"images/app_gis.jpg",
	"images/app_title.jpg"
	 ];

	$.preloadImages(app_array_img[0],app_array_img[1],app_array_img[2],app_array_img[3],app_array_img[4]);
	
	//Tab Function to Calculate Tab Changes
	function printTabs()
	{
		//Testing Prev
		if (cur_num == 0)
			var prev = app_array_text.length-1;
		if (cur_num == 1)
			var prev = 0;
		if (cur_num!=0 && cur_num !=1)
			var prev = cur_num-1;
		
		//Testing Next
		if (cur_num == app_array_text.length-1)
			var next = 0;
		else
			var next = cur_num+1;

		//Tab1
		var tab1 = new Array();
		tab1 = app_array_text[prev].split('</h2>');
		$("#applet_tab1").text(tab1[0].substring(4));
		//Tab2
		var tab2 = new Array();
		tab2 = app_array_text[cur_num].split('</h2>');
		$("#applet_tab2").text(tab2[0].substring(4));
		//Tab3
		var tab3 = new Array();
		tab3 = app_array_text[next].split('</h2>');
		$("#applet_tab3").text(tab3[0].substring(4));
		
		tabLink1=prev;
		tabLink3=next;
		return tabLink1, tabLink3;
	}
	
	//Data Function to Calculate Text and Images
	function printData()
	{
		$("#applet_txt").fadeOut("fast", function(){$("#applet_txt").empty().html(app_array_text[cur_num]).fadeIn('slow')});
		$("#applet_img").fadeOut("fast", function(){$("#applet_img").empty().html("<img src='"+app_array_img[cur_num]+"'>").fadeIn('slow')});
	}
	
	//Load First Data Set
	printData(); //Load Data
	printTabs(); //Load Tabs
	
	//Next Button Function for Timer Call
	function nextButton()
	{
				
		if(cur_num == app_array_text.length-2){
			printTabs();
			printData();
		}
		if (cur_num == app_array_text.length-1){
			cur_num = 0;
			printTabs();
			printData();
		}
		else{
			cur_num++;
			printTabs();
			printData();
			}
	}
	
	setInterval(nextButton, 15000);
	
	//Next Button
		$('#applet_button_next').click(function() {
			nextButton();
		});
		
	 //Previous Button
		$('#applet_button_prev').click(function() {
		
		if(cur_num <= 0){
			printTabs();
			printData();
		}
		if (cur_num == 0){
			cur_num = app_array_text.length-1;
			printTabs();
			printData();
		}
		else{
			cur_num--;
			printTabs();	
			printData();
			}
		});
	
	//Prev Tab
	$('#applet_tab1').click(function() {
		cur_num = tabLink1;
			printTabs();	
			printData();	
	});
	
	//Next Tab
		$('#applet_tab3').click(function() {
		cur_num = tabLink3;
			printTabs();	
			printData();	
	});
		
	//End	
	});
