var popupStatus = 0;
var resultsText = "";
var playQuoteNext = false;
var isCompareTop2 = false;
var queryString = "";
var comparePrintContent = "";
var applicant_name = "";
var applicant_email = "";
var sendemail = "";
var currentTable = '';
		
	function loadPopup()
	{
		if(popupStatus == 0)
		{
			var windowWidth = document.documentElement.clientWidth;
			var windowHeight = document.documentElement.clientHeight;
			var popupHeight = $('#popupQuote').height();
			var popupWidth = $('#popupQuote').width();
		
			$('#backgroundPopup').css({
				'opacity': '0.5'
			});
			$('#backgroundPopup').fadeIn('slow');
			$('#popupQuote').css(
			{
				'position': 'absolute',
				'top': 		'85px',
				'left':		'800px'
			});
			$('#popupQuote').animate(
			{
				'opacity': 'toggle',
				'left': windowWidth / 2 - popupWidth / 2 - 30,
				'filter': ''
			},'slow');
			popupStatus = 1;
		}
	}
		
	function disablePopup()
	{
		if(popupStatus==1)
		{
			$('#backgroundPopup').fadeOut('slow');
			$('#popupQuote').animate(
			{
				'opacity': 'toggle',
				'left': '1000px',
				'filter': ''
			},'slow');
			popupStatus = 0;
			isCompareTop2 = false;
		}
	}
	
	function closeResults()
	{
		$('#popupResults').customFadeOut('slow');
		$('#backgroundPopup').fadeOut('slow');
		popupStatus = 0;
		isCompareTop2 = false;
	}
		
	function centerPopup()
	{
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $('#popupQuote').height();
		var popupWidth = $('#popupQuote').width();
		
		$('#imgloading').css(
		{
			'position': 'absolute',
			'top': 		'390px',
			'left':		windowWidth / 2 + 239
		});
		
		$('#backgroundPopup').css({ 'height': windowHeight});
	}
	
	function showResults()
	{

		//$('head').append('<link rel="stylesheet" href="'+hostname+'/Quote/style.css" type="text/css">');
		//$('head').append('<link rel="stylesheet" href="../Quote/jq.css" type="text/css">');	

		var windowWidth = document.documentElement.clientWidth;
		var popupWidth = $('#popupResults').width();
		
		$('#popupResults').css(
		{
			'position': 'absolute',
			'top': 		'60px',
			'left':		'1000px'
		});
		//$('#popupResults').customFadeIn('slow');
		
		//$('#popupQuote').customFadeOut('slow');
		$('#popupQuote').animate(
		{
			'opacity': 'toggle', 
			'left': '-600px',
			'filter': ''
		},'slow');
		$('#popupResults').animate(
		{
			'opacity': 'toggle',
			'left': windowWidth / 2 - popupWidth / 2 - 40,
			'filter': ''
		},'slow');
	}
	
	function printCompare()
	{
		var disp_setting='toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes, width=900, height=850, left=100, top=25'; 
	  
	  	var docprint=window.open('','',disp_setting); 
	   	docprint.document.open(); 
	   	docprint.document.write('<html><head><title>Compare Plans</title><link rel="stylesheet" href="'+hostname+'/Quote/print.css" type="text/css">'); 
	   	docprint.document.write('</head><body><center>');
		if (bloglogo != '')
			docprint.document.write('<img src="' + bloglogo + '" id="logo"/>');
		else
			docprint.document.write('<h1>' + blogname + '<h1>');
		docprint.document.write('<br /><h1>Compare plans</h1><input style="float: right;" type="submit" name="Print" value="Print" onclick="window.print()">');//<body onLoad="self.print()"><center>');
		
		docprint.document.write(comparePrintContent);
	   	docprint.document.write('</center></body></html>');
	   	docprint.document.close();
	   	docprint.focus();
	}	
	
	function printQuote(plan_scope)
	{
		//window.alert(resultsText);
		var disp_setting='toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes, width=900, height=850, left=100, top=25'; 
	  
	  	var docprint=window.open('','',disp_setting); 
	   	docprint.document.open(); 
	   	docprint.document.write('<html><head><title>Available Plans</title><link rel="stylesheet" href="'+hostname+'/Quote/print.css" type="text/css">'); 
	   	docprint.document.write('</head><body><center>');
		
		if (bloglogo != '')
			docprint.document.write('<img src="' + bloglogo + '" id="logo"/>');
		else
			docprint.document.write('<h1>' + blogname + '</h1>');
		docprint.document.write('<h1>' + plan_scope + ' plans</h1><input type="submit" name="Print" value="Print" onclick="window.print()">');//<body onLoad="self.print()"><center>');
		
		var print_content = document.getElementById("divPrintHeader").innerHTML;
		if (plan_scope == 'Recommended')
			print_content += document.getElementById("divPrintRecommended").innerHTML;
		else
			print_content += document.getElementById("divPrintAll").innerHTML;
	   	docprint.document.write(print_content);
	   	docprint.document.write('</center></body></html>');  
	   	docprint.document.close(); 
	   	docprint.focus(); 
	}
	
	function backToQuote()
	{
		var windowWidth = document.documentElement.clientWidth;
		var popupWidth = $('#popupQuote').width();
		
		$('#popupResults').animate(
		{
			'opacity': 'toggle',
			'left': '1000px',
			'filter': ''
		},'slow');
		
		/*$('#popupQuote').css(
		{
			'position': 'absolute',
			'top': 		'170px',
			'left':		'800px'
		});*/
		$('#popupQuote').animate(
		{
			'opacity': 'toggle',
			'left': windowWidth / 2 - popupWidth / 2 - 30,
			'filter': ''
		},'slow');		
	}
	
	function backToResults()
	{
		if (isCompareTop2 == true)
		{
			isCompareTop2 = false;
			backToQuote();
		}
		else
		{
			document.getElementById("popupResultsTitle").innerHTML = "Step 2: Select Plan.";
			document.getElementById("quoteResultsDiv").innerHTML = resultsText;
			
			$("#myTable").tablesorter({ 
				headers: { 
					4: { 
						sorter:'grades' 
					} 
				} 
			});
			$("#myTable1").tablesorter({ 
				headers: { 
					4: { 
						sorter:'grades' 
					} 
				} 
			}); 
		}
	}
	
	function getQuotes(quoteType)
	{		
		var error = validateForm();
				//console.log('1');
		if (quoteType=='quick' && error!="")
			return;
		if (quoteType!='quick' && error!="")
		{
			window.alert(error);
			return;
		}
		
		applicant_name = document.getElementById("applicant_name").value;
		applicant_email = document.getElementById("applicant_email").value;
		
		var popupQuoteNextLive = function ()
		{
			if (playQuoteNext)
			{
				$('#popupQuoteNext').animate({'left': '642px', 'filter': ''})
				.animate({'left': '637px', 'filter': ''},popupQuoteNextLive);
			}
		}
		if (quoteType=='quick' && !playQuoteNext)
		{
			playQuoteNext = true;
			popupQuoteNextLive();
		}
		if (quoteType != 'quick' && playQuoteNext)
			playQuoteNext = false;
		
		var applicant_g = document.forms["quotewizard"]["applicant_g"].value;
		var applicant_a = document.forms["quotewizard"]["applicant_a"].value;
		var applicant_t = document.forms["quotewizard"]["applicant_t"].checked;

		var spouse_g = document.forms["quotewizard"]["spouse_g"].value;
		var spouse_a = document.forms["quotewizard"]["spouse_a"].value;
		var spouse_t = document.forms["quotewizard"]["spouse_t"].checked;

		var zipcode = document.forms["quotewizard"]["zipcode"].value;
		var date = document.forms["quotewizard"]["date"].value;
	
		var data = "zipcode=" + zipcode + "&date=" + date + "&applicant_a=" + applicant_a + "&applicant_g=" + applicant_g + "&applicant_t=" + applicant_t;
		
		if (applicant_name != '')
			data += "&applicant_name=" + applicant_name;

		if (applicant_email != '')
			data += "&applicant_email=" + applicant_email;
		
		if (spouse_a != '')
			data += "&spouse_a=" + spouse_a + "&spouse_g=" + spouse_g + "&spouse_t=" + spouse_t;
		
		data += "&blogname=" + blogname;
			
		for(j=1; j<nChildren; j++)
		{
			var child_g = document.forms["quotewizard"]["child"+j+"_g"].value;
			var child_a = document.forms["quotewizard"]["child"+j+"_a"].value;
			var child_t = document.forms["quotewizard"]["child"+j+"_t"].checked;
			if (child_a != '')
				data += "&child"+j+"_a=" + child_a + "&child"+j+"_g=" + child_g + "&child"+j+"_t=" + child_t;
		}
		
		if (sendemail != '') 
		{
			broker_email = document.getElementById("broker_email").value;
			broker_address = document.getElementById("broker_address").value;
			
			if (applicant_email == '')
			{
				sendemail=''; 
				window.alert('No email has been entered. Plese visit previous screen end enter email for the applicant.');
				return;
			}
			
			data += "&planstype=" + sendemail + "&broker_email=" + broker_email + "&broker_address=" + broker_address;
		}
		
		queryString = data;
		
		var xmlhttp = false;  // The variable that makes Ajax possible!
		try{// Opera 8.0+, Firefox, Safari
			xmlhttp = new XMLHttpRequest();
		}
		catch (e)
		{// Internet Explorer Browsers
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{// Something went wrong
					return false;
				}
			}
		}
		
		var url;
		
		if (quoteType == 'quick')
		{
			url = "../Quote/quickquote.php";
			xmlhttp.onreadystatechange  = function() 
			{
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					$('#imgloading').customFadeOut('fast');
					document.getElementById("quickQuoteDiv").innerHTML = xmlhttp.responseText;
					resultsText = xmlhttp.responseText;
				}
			}
		}
		else
		{
			url = "../Quote/quote.php";
			xmlhttp.onreadystatechange  = function()
			{
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					if (sendemail == '')
					{
						$('#imgloading').customFadeOut('fast');
						document.getElementById("quoteResultsDiv").innerHTML = xmlhttp.responseText;
						
						if (document.getElementById("tab-body:0").style.display == 'none')
							changeActiveTab(1);
						else
						{
							$("#myTable").tablesorter({ 
								headers: { 
									4: { 
										sorter:'grades' 
									} 
								} 
							});
						}
			
						$("#myTable1").tablesorter({ 
							headers: { 
								4: { 
									sorter:'grades' 
								} 
							} 
						}); 
	
				
						var applicant_title = "";
						if (applicant_name != '')
							applicant_title = " for " + applicant_name;
						document.getElementById("popupResultsTitle").innerHTML = "Step 2: Select Plan" + applicant_title + ".";
						resultsText = xmlhttp.responseText;
						showResults();
					}
					else
					{
						sendemail = '';
						window.alert('Email has been sent successfully.');
					}
				}
			}
		}
			
		xmlhttp.open("POST", url, true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.send(data);
		if (sendemail == '')
			$('#imgloading').customFadeIn('fast');
	}
	
	function findbroker()
	{
		var xmlhttp = false;  // The variable that makes Ajax possible!
		try{// Opera 8.0+, Firefox, Safari
			xmlhttp = new XMLHttpRequest();
		}
		catch (e)
		{// Internet Explorer Browsers
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{// Something went wrong
					return false;
				}
			}
		}
		var data = "zipcode=" + $('#brokerzipcode').val() + "&name=" + $('#brokername').val();
		xmlhttp.open("POST", "../Quote/locatebroker.php", false);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.send(data);
		document.getElementById("brokerListDiv").innerHTML = xmlhttp.responseText; 
	}
	
	function compareClick(table, query) 
	{
		var data = '';
		var data_extra = '';

		applicant_name = document.getElementById("applicant_name").value;
		applicant_email = document.getElementById("applicant_email").value;
		
		if (sendemail == '')
		{
			if(query != '')
				data = query;
			else
			{
				var plans = document.getElementById(table).getElementsByTagName('tr').length-1;
						
				var x="";
				
				if (table == 'myTable1')
					x=1;
					
				var index = 0;
				for(z=0; z<plans; z++)
				{
					if (document.getElementById("plan"+x+"_id_"+z).checked == true)
					{ 
						data += 'plan_id[' + index + ']=' + document.getElementById("plan"+x+"_id_"+z).value + "&";
						data_extra += '&plan_rate[' + index + ']=' + document.getElementById("plan"+x+"_rate_"+z).value;
						index++;
					}				
				}
				
				if (index > 4)
				{
					window.alert('You have selected more then 4 plans to compare. Please choose up to 4 plans');
					return;
				}
				else if (index == 0)
				{
					window.alert('You have not selected any plans to compare. Please choose up to 4 plans');
					return;
				}
			}
			
			data += data_extra;
		}
		
		if (applicant_name != '')
			data += "&applicant_name=" + applicant_name;
		if (applicant_email != '')
			data += "&applicant_email=" + applicant_email;
		
		data += "&date=" + document.forms["quotewizard"]["date"].value;
				
		data += '&blogname=' + blogname;
		
		if (sendemail != '')
		{
			broker_email = document.getElementById("broker_email").value;
			broker_address = document.getElementById("broker_address").value;
			
			if (applicant_email == '')
			{
				sendemail=''; 
				window.alert('No email has been entered. Plese visit previous screen end enter email for the applicant.');
				return;
			}
			
			data += "&broker_email=" + broker_email + "&broker_address=" + broker_address;
		}

		var xmlhttp = false;  // The variable that makes Ajax possible!
		try{// Opera 8.0+, Firefox, Safari
			xmlhttp = new XMLHttpRequest();
		}
		catch (e)
		{// Internet Explorer Browsers
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{// Something went wrong
					return false;
				}
			}
		}
		
		xmlhttp.open("POST", "../Quote/compare.php", false);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.send(data);
		
		if (sendemail == '')
		{
			if ( query != '')
			{
				isCompareTop2 = true;
				document.getElementById("popupResultsTitle").innerHTML = "Compare Top Plans";
				document.getElementById("quoteResultsDiv").innerHTML = xmlhttp.responseText;
				showResults();
			}
			else
			{
				document.getElementById("popupResultsTitle").innerHTML = "Compare Plans";
				//$('#popupResults').customFadeOut('fast', function(){
					document.getElementById("quoteResultsDiv").innerHTML = xmlhttp.responseText;
				//});
				//$('#popupResults').customFadeIn('fast');
			}
			comparePrintContent = xmlhttp.responseText;
		}
		if(query == '' && sendemail != '')
		{
			sendemail = '';
			window.alert('Email has been sent successfully.');
		}
}
	
	function preload(arrayOfImages) {
		$(arrayOfImages).each(function(){
			$('<img/>')[0].src = this;
			// Alternatively you could use:
			// (new Image()).src = this;
		});
	}

	(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		if(jQuery.browser.msie)
			$(this).show();
		else
			$(this).fadeIn(speed, callback);
	};
	
	$.fn.customFadeOut = function(speed, callback) {
		if(jQuery.browser.msie)
			$(this).hide();
		else
			$(this).fadeOut(speed, callback);
	};
	})(jQuery);
	 
	$(document).ready(function()
	{
		$('#button').click(function()
		{
			startPopup();
		});
		$('#button1').click(function()
		{
			startPopup();
		});
		$('#popupQuoteClose').click(function()
		{
			disablePopup();
		});
		$('#popupResultsClose').click(function()
		{
			closeResults();
		});
		$('#popupQuoteBack').click(function()
		{
			disablePopup();
		});
		$('#popupQuoteNext').click(function()
		{
			getQuotes();
		});
		$('#btnGetRates').click(function()
		{
			getQuotes();
		});
		
		var zipcode = getCookie('zipcode');
		if (zipcode)
			document.getElementById('zipcode').value = zipcode;

		//window.alert(window.location.href);
		//window.alert(window.location.href);
		
		var t;
		
		if (((window.location.href == 'http://' + window.location.host + '/') || (window.location.href == siteurl + '/')) && (quote_autostart != "0") )
		{
			var delay = 5000;
			
			if (quote_delay != "")
				delay = parseInt(quote_delay);
				
			t = setTimeout("startPopup()",delay);
		}

		$.tablesorter.defaults.widgets = ['zebra'];
		$.tablesorter.defaults.sortList = [[4,0]]; 
	  
			// add parser through the tablesorter addParser method 
		$.tablesorter.addParser({ 
			// set a unique id 
			id: 'grades', 
			is: function(s) { 
				// return false so this parser is not auto detected 
				return false; 
			}, 
			format: function(s) { 
				// format your data for normalization 
				return s.replace('$','').replace(',', ''); 
			}, 
			// set type, either numeric or text 
			type: 'numeric' 
		}); 

	});
	
	function startPopup()
	{
		centerPopup();
		loadPopup();
	}
	
	function setCookie(c_name,value,exdays)
	{
		var exdate=new Date();
		exdate.setDate(exdate.getDate() + exdays);
		var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
		document.cookie=c_name + "=" + c_value;
	}
	
	function getCookie(c_name)
	{
		var i,x,y,ARRcookies=document.cookie.split(";");
		for (i=0;i<ARRcookies.length;i++)
		{
		  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		  x=x.replace(/^\s+|\s+$/g,"");
		  if (x==c_name)
			{
			return unescape(y);
			}
		  }
	}
	
	function validateForm()
	{
		var alphaExp = /^[0-9a-zA-Z ,]*$/;
		var numberExp = /^[0-9]*$/;
		var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
		
		if(!document.getElementById("applicant_name").value.match(alphaExp))
			return "Please enter correct Applicant's name (letters and numbers only).";

		if (document.getElementById("applicant_email").value != '')
			if(!document.getElementById("applicant_email").value.match(emailExp))
				return "Please entre correct Applicant's email.";
		
		var x=document.forms["quotewizard"]["applicant_g"].value;
		var zipcode = document.forms["quotewizard"]["zipcode"].value;
		var age = document.forms["quotewizard"]["applicant_a"].value;
		
		setCookie('zipcode', zipcode, 365);
		
		if (x==null || x=="" || x=="--")
		  	return "Fill out the Applicants Gender";	
		else if(age==null || age=="")
			return "Applicant Age is  required";
		else if(zipcode==null || zipcode=="")
			return "Zipcode is  required";
			
		if (!age.match(numberExp))
			return "Please enter correct applicant's age";
			
		if (document.forms["quotewizard"]["spouse_a"].value != '')
		{
			if (!document.forms["quotewizard"]["spouse_a"].value.match(numberExp))
				return "Please enter correct spouse's age";
			if (document.forms["quotewizard"]["spouse_g"].value == '')
				return "Please enter spouse's gender";
		}
			
		for(j=1; j<nChildren; j++)
			if (document.forms["quotewizard"]["child"+j+"_a"].value != '')
			{
				if (!document.forms["quotewizard"]["child"+j+"_a"].value.match(numberExp))
					return "Child #" + j + " has incorrect age. Please try again.";
				if (document.forms["quotewizard"]["child"+j+"_g"].value == '')
					return "Please enter child #" + j + " gender.";
			}
			
		return "";
	}

	function textvalue()
 	{
 		//var valueData = top.location.href;
		//alert('valueData');
		//var video_id = top.location.search.split('zipcode=')[1];
		//video_id = video_id.substring(0, ampersandPosition);
		
		//document.getElementById('zipcode').value = video_id;
	}

	var nChildren = 3;
	function addRow()
	{
		//if (!document.getElementsByTagName) return;
		//window.alert(document.getElementById("infoBody"));
        tabBody=document.getElementsByTagName("tbody").item(1);
        row=document.createElement("TR");
        cell1 = document.createElement("TD");
        cell2 = document.createElement("TD");
        //cell2 = document.createElement("TD");
		cell3 = document.createElement("TD");
		cell4 = document.createElement("TD");
        textnode1=document.createTextNode("Child");
		var element = document.createElement("select");
		element.setAttribute("name", "child"+nChildren+"_g");		
		element.setAttribute("id", "child"+nChildren+"_g");
		element.setAttribute("onchange", "getQuotes('quick')");
		
		var option2 = document.createElement("option");
	
		option2.text = "--";
		option2.value = "--";
		// document.getElementsByName("Child").add(option2)		
	   	try
		{
			element.add(option2,null); 
		}
		catch(error)
		{
			element.add(option2); 
		}
		var option = document.createElement("option");
    	option.text = "Male";
		option.value = "M";
		try
		{
			element.add(option,null); 
		}
		catch(error)
		{
			element.add(option); 
		}
		var option1 = document.createElement("option");
		option1.text = "Female";
		option1.value = "F";
		try
		{
			element.add(option1,null); 
		}
		catch(error)
		{
			element.add(option1); 
		} 
	
		var sec = document.createElement("input");
		sec.setAttribute("type", "text");
		sec.setAttribute("value", "");
		sec.setAttribute("size", "3");
		sec.setAttribute("name", "child"+nChildren+"_a");
		sec.setAttribute("onkeyup", "getQuotes('quick')");
		
		var three = document.createElement("input");
		three.setAttribute("type", "checkbox");
		three.setAttribute("value", "2");
		three.setAttribute("size", "3");
		three.setAttribute("name", "child"+nChildren+"_t");
		three.setAttribute("onchange", "getQuotes('quick')");
		
        cell1.appendChild(textnode1);
        cell2.appendChild(element);
		cell3.appendChild(sec);
		cell4.appendChild(three);
        row.appendChild(cell1);
        row.appendChild(cell2);
		row.appendChild(cell3);
		row.appendChild(cell4);
        tabBody.appendChild(row);

        oFormObject = document.forms['quotewizard'];
        oFormElement = oFormObject.elements["child"];
        oFormObject.elements["child"].value = nChildren;

		nChildren++;
		if (nChildren>6)
			document.getElementById('addChild').style.display = 'none';
	}
	
	var tabCount = 2; //number of tabs //
	var hostname = "http://"+window.location.hostname;
 
// active tab: you can replace the images and background images as well //	
	function activateTab(i) {
		//window.alert(document.getElementById( "tab-bg:"+i ));
		document.getElementById( "tab-left:"+i ).src=hostname+"/Quote/tools/tabmenu/tab-left_active.gif";
		document.getElementById( "tab-bg:"+i ).style.background="url("+hostname+"/Quote/tools/tabmenu/tab-bg_active.gif)";
		document.getElementById( "tab-right:"+i ).src=hostname+"/Quote/tools/tabmenu/tab-right_active.gif";
		document.getElementById( "tab-body:"+i ).style.display='block';
	}
	
// in-active tab: you can replace the images and background images as well //	
	function deactivateTab(i) {
		document.getElementById( "tab-left:"+i ).src=hostname+"/Quote/tools/tabmenu/tab-left_inactive.gif";
		document.getElementById( "tab-bg:"+i ).style.background="url("+hostname+"/Quote/tools/tabmenu/tab-bg_inactive.gif)";
		document.getElementById( "tab-right:"+i ).src=hostname+"/Quote/tools/tabmenu/tab-right_inactive.gif";
		document.getElementById( "tab-body:"+i ).style.display='none';
	}
	
// change of active tab: DO NOT edit this section //	
	function changeActiveTab(i) {
		for( j=0; j < tabCount; ++j ) {
			if( j==i ) {
				activateTab(j);
			} else {
				deactivateTab(j);
			}
		}
	}
