// JavaScript Document
//redirects user to www subdomain for site to keep user consistent temp fix for now. this is due to subdomain cookie issue that needs to be resolved.
var pathName=location.href;
var pos = pathName.search("http://www.");
if(pos < 0)
{
	pathName = pathName.replace("http://", "http://www.");
	window.location = pathName;
}

$(document).ready(function(){
	//position the search form
	var windowWidth = $(window).width();
	if(windowWidth < 1005)
	{
		windowWidth = 1004;	
	}
	var spacingWidth = Math.round((windowWidth - 1004)/2);
	
	var leftP = spacingWidth+670;
	$("#frmSearch").css({'left':leftP+'px'});	
	var leftCloud = spacingWidth+608;
	$("#icnCloud").css({'position':'absolute', 'top':'316px', 'left':leftCloud+'px'});
	//incase the user resizes the window. reposition the search form
	$(window).resize(function(){
		windowWidth = $(window).width();
		if(windowWidth < 1005)
		{
			windowWidth = 1004;	
		}
		spacingWidth = Math.round((windowWidth - 1004)/2);
		leftP = spacingWidth+670;
		$("#frmSearch").css({'left':leftP+'px'});	
		leftCloud = spacingWidth+608;
		//position the cloud
		$("#icnCloud").css({'position':'absolute', 'top':'316px', 'left':leftCloud+'px'});
	});
	
	
	
	//START make any class eqHeight the same height
	var columnHeight=0;
	var totalPadding=0;
	var currentHeight=0;
	
	$(".eqHeight").each(function(){
		currentHeight = $(this).height();
		//totalPadding = parseInt($(this).css("padding-top").replace("px", ""));
		//totalPadding += parseInt($(this).css("padding-bottom").replace("px", ""));
		//currentHeight += totalPadding;
		if(columnHeight < currentHeight)
		{
			columnHeight=currentHeight;	
		}
	});
	$(".eqHeight").css({'height':columnHeight});
	//END make any class eqHeight the same height
	
	
	//make the logo div a link
	$("#logo").click(function(){
		window.location = "http://salestransactor.com/index.php";
	});
	

	//set the nav tab to highlight based on the current page
	var pathName=$(location).attr('href'); 
	pathName = pathName.replace(/(.*)\//i, "");
	pathName = pathName.replace(/\.php(.*)/i, ".php");
	switch(pathName)
	{
		case("index.php"):
			$("#topNav a[href='index.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;
		
		case("compumatcher.php"):
			$("#topNav a[href='compumatcher.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;
		
		case("contactleads.php"):
			$("#topNav a[href='contactleads.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;
		
		case("networkofbusiness.php"):
			$("#topNav a[href='networkofbusiness.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;
		
		case("about.php"):
			$("#topNav a[href='about.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;
		
		case("contactus.php"):
			$("#topNav a[href='contactus.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;
		
		case("preRegister.php"):
			$("#topNav a[href='preRegister.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;
		
		case("register.php"):
			$("#topNav a[href='preRegister.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;
		
		default:
			$("#topNav a[href='index.php']").css({'background-color':'#c4e0eb', 'color':'#292e35'});
		break;	
	}
	
	/*when country drop down changes the regions show up in div#region */
	$("#country").change(function(){
		var catid = $(this).val();
		var htmlmarkup = $("#region"+catid).html();
		$("#region").html(htmlmarkup);
	});

});

function removeZeroVal(name)
{
	$(name).remove();	
}
