
// Redirection code (if necessary)

if (readCookie("replaceHome") && location.pathname == "/")
{
	location.href = readCookie("replaceHome") + location.search;
}



// Navigation Preloading and Image-Swap functions
function preloadImages(imgArray)
{
	var imgPath = "images/";

	for (n=0; n < imgArray.length; n++)
	{
		eval("var img" + n + " = new Image();");
		eval("img" + n + ".src = '" + imgPath + imgArray[n] + "';");
	}
}


var primaryImgRolloverArray = new Array(
	// navigation
	"common/header/nav_home2_over.gif",
	//"common/header/nav_home_over.gif",
	"common/header/nav_what_over.gif",
	"common/header/nav_why_over.gif",
	"common/header/nav_how_over.gif",
	"common/header/nav_features_over.gif",
	"common/header/nav_packages_over.gif",
	//"common/header/nav_freetrial_over.gif",
	//"common/header/nav_pricing_over.gif",
	"common/header/nav_partners_over.gif",
	"common/header/nav_support_over.gif",

	// tell a friend
	"common/footer/btn_tellafriend_over.gif",

	// home promo buttons
	"home/freetrial_btn_over.gif",
	//"home/buy_btn_over.gif",
	"home/try_btn_over.gif",
	"home/demo_btn_over.gif",
	"common/btn_LearnMore_over.gif",
	"common/btn_SeeMoreExamples_over.gif"
);


var secondaryImgRolloverArray = new Array(
	"common/btn_HowDoesItWork_over.gif",
	"common/btn_ReadEntireCaseStudy_over.gif",
	"common/btn_ReadMore_over.gif",
	"common/btn_SignUpNow_over.gif",
	"common/btn_SignUpToday_over.gif",
	"common/btn_TryNow_over.gif",
	"common/btn_ViewDemoMovie_over.gif",
	"common/btn_ViewPricing_over.gif",

	"special/detailedpricing_freetrial_over.gif"
);

function submitForm()
{
	document.form1.submit();
}


function swapSrc(who, what) { who.src = what; }
function swapBg(who, what)	{ who.style.backgroundImage = "url(" + what + ")"; }


// navigation highlight
function hiliteNav(item) 
{
	var btn = document.getElementById(item);
	
	if (btn)
	{
		btn.src = btn.src.substring(0, btn.src.length - 4) + "_over.gif";
		btn.onmouseover = new Function();
		btn.onmouseout  = new Function();
	}
}


// warn users about small resolution
var screenW = screen.width;
var screenH	= screen.height;

// universal JS centered window-opening function 
function windowOpen(url, winName, width, height, peripherals)
{
	// adjust for window sizes that are larger than the user's screen:	
	if (width > (screenW - 50)) 	width = screenW - 50;
	if (height > (screenH - 50))	height = screenH - 50;

	// determine x,y for centered window
	var winLeft	= ((screenW - width) / 2) - 16;
	var winTop	= (screenH - height) / 2;

	// open it (peripherals may include resizable, scrollbars, menubar, toolbar, etc)
	var win = window.open(url, winName, "width=" + width + ",height=" + height + ",left=" + winLeft + ",top=" + winTop + (peripherals ? "," + peripherals : ""));
	win.focus();
	
	return false;
}




// String Truncation Code

function truncate(text,chars) {

	if (text.length <= chars) {
		
		document.write(text); 
	
	} else {
	
		var newText = text.substring(0,chars);
		
		var breakSpot = /[ \.\?\!\;\,\:]/;
		
		// make sure there is at least one breakspot, if not return as is plus elipses
		if (newText.match(breakSpot) == null) {
			document.write(newText += "&#0133;");
			return;
		}

		// find the first break character from the end
		while (newText.charAt(newText.length-1).match(breakSpot) == null) {
			newText = newText.substring(0,newText.length-1);
		}
		
		// find the first real character from the new end
		while (newText.charAt(newText.length-1).match(breakSpot) != null) {
			newText = newText.substring(0,newText.length-1);
		}

		document.write(newText += "&#0133;");
		
	}
}



function trimWhitespace(s)
{
	while (s.charAt(0) == " ")
	{
		s = s.substring(1);
	}
	
	while (s.charAt(s.length - 1) == " ")
	{
		s = s.substring(0, s.length - 1);
	}
	
	return s;
}


function trimFormWhitespace(thisForm)
{
	for (f=0; f < thisForm.elements.length; f++)
	{
		if (thisForm.elements[f].type == "text" || thisForm.elements[f].type == "textarea")
		{
			thisForm.elements[f].value = trimWhitespace(thisForm.elements[f].value);
		}
	}
}


function getFlashMovieObject(movieName)
{
	if (window.document[movieName]) 
	{
		return window.document[movieName];
	}

	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
		{
			return document.embeds[movieName]; 
		}
	}
	else 
	{
		return document.getElementById(movieName);
	}
}


function VHSS_DoFSCommand() {}


function sendLinkEvent(accnt,lnkname,type){
		
	if (typeof(s_account)=="undefined" || typeof(s_gs)=="undefined") return;
	accnt=accnt?accnt:s_account;	
	s_linkType=type?type:"o";
	s_lnk=true;
	s_linkName=lnkname?lnkname:s_linkName?s_linkName:"Flash Link Event";
	void(s_gs(accnt))
}



/*
function fifty50() 
{
	var link1 = "packages";
	var link2 = "detailedpricing";
	
	if (readCookie('packagePath') == 'Packages')
	{
		window.setTimeout('location.href="' + link1 + '"', 100);
	} 
	else if (readCookie('packagePath') == 'Pricing')
	{
		window.setTimeout('location.href="' + link2 + '"', 100);
	}
	else if (Math.random() < 0.5)
	{
		setCookie('packagePath', 'Store', moment1);
		window.setTimeout('location.href="' + link1 + '"', 100);
	}
	else
	{
		setCookie('packagePath', 'Pricing', moment1);
		window.setTimeout('location.href="' + link2 + '"', 100);
	}
}

function fifty50_Special(link1, link2) 
{
	if (readCookie('SpecialPromo') == 'link1')
	{
		window.setTimeout('window.open("' + link1 + '","SpecialPromo")', 100);
	} 
	else if (readCookie('SpecialPromo') == 'link2')
	{
		window.setTimeout('window.open("' + link2 + '","SpecialPromo")', 100);
	}
	else if (Math.random() < 0.5)
	{
		setCookie('SpecialPromo', 'link1', moment1, '/', location.hostname);
		window.setTimeout('window.open("' + link1 + '","SpecialPromo")', 100);
	}
	else
	{
		setCookie('SpecialPromo', 'link2', moment1, '/', location.hostname);
		window.setTimeout('window.open("' + link2 + '","SpecialPromo")', 100);
	}
}
*/


function directParentFromPopup(sUrl) 
{
	if (window.opener) 
		window.opener.location.href = sUrl;
	else
		window.open(sUrl, 'noParent');
	
	window.setTimeout('self.close()', 100);
}




// CSS quirks

document.write('<sty' + 'le type="text/css">');

if (document.all)	// IE-specific styles
{
	//alert(navigator.appVersion);
	
	if (navigator.appVersion.indexOf('MSIE 7') != -1)			// IE 7
	{
		document.write('DIV#menuTierA INPUT, DIV#menuTierA BUTTON { width: 165px; }');
		document.write('DIV#menuTierA BUTTON#menu_detailedpricing { width: 175px; }');
		document.write('DIV#menuTierA BUTTON#menu_whatcan, DIV#menuTierA BUTTON#menu_faq, DIV#menuTierA BUTTON#menu_thirdparty { width: 200px; }');
		document.write('DIV#menuTierA BUTTON#menu_documentation { width: 220px; }');
	} 
	else 														// IE 6 and below
	{
		document.write('DIV#menuTierA INPUT, DIV#menuTierA BUTTON { width: 22%; overflow: visible; }');		
	}
}
else if (navigator.platform.indexOf("Mac") != -1)				// Mac-specific
{
	document.write('TEXTAREA { width: 100%; }');	
	
	var u = navigator.userAgent.toLowerCase();
	
	if (u.indexOf('safari 85') != -1 || u.indexOf('safari 100') != -1 || u.indexOf('safari 125') != -1 || u.indexOf('safari 312') != -1 || 
		u.indexOf('safari/85') != -1 || u.indexOf('safari/100') != -1 || u.indexOf('safari/125') != -1 || u.indexOf('safari/312') != -1)
	{
		// this is Safari 1.x
		document.write('DIV#menuTierA INPUT, DIV#menuTierA BUTTON { display: inline; position:relative; top: -5px;  } ');	
	}
}
else
{
	document.write('TABLE#tblHeader_ContactSales TD.text { padding-bottom:1px;}');
}

document.write('</sty' + 'le>');

