/***************** VRT *****************/

function clickingSubscribe(flag) {
	var emailAddr = document.news_letter_subscribe.em.value;
	var msg = checkFormat(emailAddr);
	if (msg) { 
		alert(msg);
		document.news_letter_subscribe.em.select();
		if (flag) return false;
	} else { 
		document.news_letter_subscribe.submit();
		if (flag) return true;
	}
}

function CheckOptOutStatus() {
	return clickingSubscribe(true);
}

function checkFormat(val) { 
	var msg = "";
	var emailFormat = /^\w+[\w|\.|\-]*\w+@\w+[\w|\.|\-]*\w+\.\w{2,3}$/; 
	if (val && !val.match(emailFormat)) { 
		return "The e-mail address entered is not in a proper format.\n"; 
	} else {
		return false;
	}
}

function myLogoutsubmit() {
	document.signoutform.submit() ;
}


/***************** utilities *****************/

function getLayer(layerID) {
	if (document.layers) {
		return document.layers[layerID];
	} else if (document.all) {
		return eval("document.all." + layerID + ".style");
	} else if (document.getElementById) {
		return document.getElementById(layerID).style;
	}
}

/* Print */

var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HE' + 'AD>\n<BODY>\n';
		
		var printReadyElem = document.getElementById("printReady");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			window.print();
			return;
		}
			
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		window.print();
	}
}



/************* new.js *************/

/* Code for News / Events Widget */

/* function go_to(url) {
   alert('Go to: '+url);
   window.location = url; 
} */

/* function click_tab(display_id) {
   if (display_id == 'news') {
      elt = document.getElementById('tab-news');
      elt.className = 'tab-active';
      elt = document.getElementById('tab-events');
      elt.className = 'tab-inactive';
      elt = document.getElementById('news');
      elt.style.display = 'block';
      elt = document.getElementById('events');
      elt.style.display = 'none';
   } else {
      elt = document.getElementById('tab-news');
      elt.className = 'tab-inactive';
      elt = document.getElementById('tab-events');
      elt.className = 'tab-active';
      elt = document.getElementById('news');
      elt.style.display = 'none';
      elt = document.getElementById('events');
      elt.style.display = 'block';
   }
   return void(0);
} */

function click_news() {
	  elt = document.getElementById('tab-news');
      elt.className = 'tab-active';
      elt = document.getElementById('tab-events');
      elt.className = 'tab-inactive';
      elt = document.getElementById('news');
      elt.style.display = 'block';
      elt = document.getElementById('events');
      elt.style.display = 'none';
   return void(0);
}

function click_events() {
	  elt = document.getElementById('tab-news');
      elt.className = 'tab-inactive';
      elt = document.getElementById('tab-events');
      elt.className = 'tab-active';
      elt = document.getElementById('news');
      elt.style.display = 'none';
      elt = document.getElementById('events');
      elt.style.display = 'block';
   return void(0);
}

/* function click_tab_events_events() {
   elt = document.getElementById('tab-news');
      elt.className = 'tab-inactive';
      elt = document.getElementById('tab-events');
      elt.className = 'tab-active';
      elt = document.getElementById('news');
      elt.style.display = 'none';
      elt = document.getElementById('events');
      elt.style.display = 'block';
	   return void(0);
} */


/* Code for dropdown menus */

function click_menu(e) {
   if (!e) var e = window.event;
   e.cancelBubble = true;
   if (e.stopPropagation) e.stopPropagation();



   var elt = this.getElementsByTagName('div')[1];
   if (elt.className == 'menu-hidden') {
      close_menus();
      elt.className = 'menu-visible';
      elt.innerHTML = elt.innerHTML+'';
      var divs = document.getElementsByTagName('div');
      for (var i = 0; i < divs.length; i++) {
         var e = divs[i];
         if (e.className == 'item') {
            e.onmouseover = highlight;
            e.onmouseout = restore;
            e.onclick = click;
         }
      }
   } else {
      elt.className = 'menu-hidden';
      var divs = document.getElementsByTagName('div');
      for (var i = 0; i < divs.length; i++) {
         var e = divs[i];
         if (e.className == 'item active') {
            e.className = 'item';
         }
      }
   }
}

function click_multi_single_menu(e) {
   if (!e) var e = window.event;
   		e.cancelBubble = true;
   if (e.stopPropagation) e.stopPropagation();
   var elt = this.getElementsByTagName('div')[1];
   if (elt.className == 'menu-hidden') {
      close_menus();
      elt.className = 'menu-visible';
      elt.innerHTML = elt.innerHTML + '';
      var divs = document.getElementsByTagName('div');
      for (var i = 0; i < divs.length; i++) {
         var e = divs[i];
         if (e.className == 'item') {
            e.onmouseover = highlight;
            e.onmouseout = restore;
            e.onclick = click_multiSingle;
         }
      }
   } else {
      elt.className = 'menu-hidden';
      var divs = document.getElementsByTagName('div');
      for (var i = 0; i < divs.length; i++) {
         var e = divs[i];
         if (e.className == 'item active') {
            e.className = 'item';
         }
      }
   }
}

function close_menus() {
   var divs = document.getElementsByTagName('div');
   for (var i = 0; i < divs.length; i++) {
      var e = divs[i];   
      if (e.className == 'menu-visible') {
         e.className = 'menu-hidden';
      }
   }

}

function highlight() {   
   this.className = 'item active';
}

function restore() {
   this.className = 'item'; 
}

function click() {
   var value = this.getAttribute('value');
   var elt = this.parentNode.parentNode;
   var head = elt.getElementsByTagName('div')[0];
   head.innerHTML = this.innerHTML.substring(0,35);
   if (this.parentNode.getAttribute('onChange') != '') {
      eval(this.parentNode.getAttribute('onChange'));
   }
}

 function click_multiSingle() {

	var layers = document.getElementsByTagName('div');
	
	 for (var i = 0; i < layers.length; i++) {

      element = layers[i];
	  elementLocator = element + i;
      if (element.className == 'pulldown-singleselect' && element !== this.parentNode.parentNode) {
			 elementChildNodes = element.childNodes;

                         for (var j = 0; j < elementChildNodes.length; j++) {
                            var c = elementChildNodes[j];
                            if (c.className == 'head-singleselect') {
                              c.innerHTML = element.title;
                            }
                         }
      }
	} 


	var mySelection;

   var elt = this.parentNode.parentNode;

   var value = this.getAttribute('value');

   var input = elt.getElementsByTagName('input');
   input[0].value = value;
   var head = elt.getElementsByTagName('div')[0];
   

	   head.innerHTML = this.innerHTML.substring(0,40);


   if (this.parentNode.getAttribute('onChange') != '') {
      mySelection = eval(this.parentNode.getAttribute('onChange'));
   }
}


function setup_menu() {
   var divs = document.getElementsByTagName('div');
   for (var i = 0; i < divs.length; i++) {
      elt = divs[i];
      if (elt.className == 'pulldown') {
         elt.onclick = click_menu;
		
      } else if (elt.className == 'pulldown-singleselect') {
		  elt.onclick = click_multi_single_menu;
	  }
   }   
   var opt = document.getElementById('options');
   if (opt) {
   opt.onclick = function () {
      var o = document.getElementById('optional');
      if (o.className == 'optional-hidden') {
         o.className = 'optional-visible';
         this.innerHTML = 'Hide Options';
      } else {
         o.className = 'optional-hidden';
         this.innerHTML = 'Show Options';
      }
    }
  }
}

/* Active Buttons */

function hover_button(button, on) {
   if (on) {
      button.className = 'button-arrow-lg hover'
   } else {
      button.className = 'button-arrow-lg'
   }
}

function click_button(button) {
   button.className = 'button-arrow-lg active'
}



/* Subscribe Panel */

function toggle_subscribe() {
   var button = document.getElementById('subscribe-button');
   var menu = document.getElementById('subscribe-menu-container');

   if (button.className == '') { button.className = 'active'} else { button.className = ''}
   if (menu.className == '') { menu.className = 'active'} else { menu.className = ''}
}

/************ browser detection ************/
// USE BROWSER-SPECIFIC CSS
var ns4 = false;
if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) > 4) {
	document.writeln("<link rel='stylesheet' href='/relaunch/WWW_WinNS6.css' type='text/css'>");
}

/************ nav_new.js ************/

/* utilities */

function curl(fileName)
{
	var globalPath = "/downloads/";
	str = "<a href='" + globalPath + 
		fileName +
	 "' class='link'>" + fileName + "</a>";
	return(str);
}

function imagePathAwards(fileName, path)
{
	var globalPath = "/images/";
	if (fileName.length > 0)
		str = "<img border='0' src='" + globalPath + path + "/" +
			fileName + "' width='134' height='80'>";
	else 
		str = "";
	return(str);
}

function imagePath(fileName, path)
{
	var globalPath = "/images/";
	if (fileName.length > 0)
		str = "<img border='0' src='" + globalPath + path + "/" +
			fileName + "'>";
	else 
		str = "";
	return(str);
}

function imagePathRight(fileName, path)
{
	var globalPath = "/images/";
	if (fileName.length > 0)
		str = "<img align='right' border='0' src='" + globalPath + path + "/" +
			fileName + "'>";
	else 
		str = "";
	return(str);
}
function imagePathReseller(fileName, path, link)
{
	var globalPath = "/images/";


	if (fileName.length > 0)
		str = "<img width='80' height='60' border='0' hspace='3' vspace='0' src='" + globalPath + path + "/" +
			fileName + "'>";
	else 
		str = "";

	if (link.length > 0)
	{
		str = "<a href='" + link + "'>" + str + "</a>";
	}

	return(str);
}


function imagePathSmall(fileName, path)
{
	var globalPath = "/images/";
	if (fileName.length > 0)
		str = "<img width='58' border='0' hspace='3' vspace='0' src='" + globalPath + path + "/" +
			fileName + "'>";
	else 
		str = "";
	return(str);
}

function externalPath(path, title)
{
	str = "<a href=" +  path + " class='linkmodule'>" + title + "</a><span class='link'>&nbsp;&gt;</span>";
	return(str);
}
function urlimagePath(path, title)
{
	str = "<a href=" +  path + " target='_blank'>" + title + "</a>";
	return(str);
}

function downloadPath(fileName, title, path)
{
	return downloadPathForHtdocs(fileName, title, path);
}

function downloadPath2(fileName, title, path, style)
{
	return 	downloadPathForHtdocs(fileName, title, path, style);
}

function downloadPathForTrialSoftware(fileName, title, path,protocol)
{	var globalPath;

	if(protocol == 'http')
	{		   
		globalPath = "http://eval.veritas.com/downloads/";
	}	
	else		
	{	
		globalPath = "ftp://eval.veritas.com/downloads/";
	}	
	str = "<a href='" + globalPath +  path + "/" + fileName + "' class='linkmodule'>" + title + "</a>";	
	
	return(str);
}

function downloadPathForHtdocs(fileName, title, path, style)
{
	if (style)
	{}
	else
	{	
		style = 'link';
	}

	var foundSlash,str;
	foundSlash = fileName.indexOf('/');
	if (foundSlash == -1)
	{
		var downloadPath = "http://eval.veritas.com/downloads/";
		str = "<a href='" + downloadPath +  path + "/" + fileName 
		+ "' class='" + style + "'>" + title + "</a>";
		return(str);

	}
	else
	{
		var foundHtdocs;
		foundHtdocs = fileName.indexOf('htdocs');
	
		if (foundHtdocs == -1)
		{
			var foundPath,pathWithSlashes;
			pathWithSlashes = '/' + path + '/';
			foundPath = fileName.indexOf(pathWithSlashes);
			if(foundPath == -1 && path)
			{
				str = "<a  href='http://eval.veritas.com/downloads/" 
				+ path + "/" + fileName +
				 "' class='" + style + "'>" + title + "</a>";
			}
			else
			{
				str = "<a  href='http://eval.veritas.com/" 
				+ fileName + "' class='" + style + "'>" + title + "</a>";
				
			}
			return(str);
		}
		else
		{	
			fileName = fileName.replace('/htdocs/','http://eval.veritas.com/');
			str = "<a  href='" + fileName +
			 "' class='" + style + "'>" + title + "</a>";
			return(str);
		}
	}
}
function productdownloadPath(fileName, title, path)
{
	return downloadPathForHtdocs(fileName, title, path, 'linkmodule');
}

function validateList(item) {
	var arr = item.split(" ");
	var count = 0;
	for(i=0;i<arr.length;i++){
		if(arr[i] != ""){
			count++;
		}
	}
	if(count != 0){
		document.write("<span class='link'><li type='square'><span class='bodytext'>" + item + "</span></li></span>");
	}
}

function validateList1(item) {

	if(item.length > 0){
		document.write("<span class='link'><li type='square'><span class='bodytext'>" + item + "</span></li></span>");
	}
}

function validateTop(item) {
	if (item.length > 0)
		document.write("<span class='link'><li type='square'>");
}

function validateBottom(item) {
	if (item.length > 0)
		document.write("</span></li></span>");
}

	// parse out special symbols' hex values
function stringReplaceSup(str){
	var rExp_line = /\&amp\;\#8212\;/gi;
	var rExp_sup = /\&lt\;sup\&gt\;TM\&lt\;\/sup\&gt\;/gi;
	var rExp_tm = /\&amp\;\#8482\;/gi;
	var rExp_tm2 = /\&\#8482\;/gi;
	var rExp_rest = /\&amp\;\#174\;/gi;
	var rExp_copy = /\&amp\;\#169\;/gi;
	var rExp_pipe = /\/\;/gi;
	var rExp_italics_open = /\&lt\;I\&gt\;/gi;
	var rExp_italics_close = /\&lt\;\/I\&gt\;/gi;
	var rExp_quote = /\&quot\;/gi;
	var rExp_open = /\&lt\;/gi;
	var rExp_close = /\&gt\;/gi;
	var rExp_br = /\&lt\;BR\&gt\;/gi;
	str = str.replace(rExp_line, '&#8212;');
	str = str.replace(rExp_sup, '');
	str = str.replace(rExp_tm, '&#8482;');
	str = str.replace(rExp_tm2, '&#8482;');
	str = str.replace(rExp_rest, '&#174;');
	str = str.replace(rExp_copy, '&#169;');
	str = str.replace(rExp_pipe, '&#174;');
	str = str.replace(rExp_italics_open, '<i>');
	str = str.replace(rExp_italics_close, '</i>');
	str = str.replace(rExp_quote, '`');
	str = str.replace(rExp_open, '<');
	str = str.replace(rExp_close, '>');
	str = str.replace(rExp_br, '<br>');
	return str;
}

function stringParseSup(str){
	var rExp_sup = /\&lt\;sup\&gt\;TM\&lt\;\/sup\&gt\;/gi;
	var rExp_tm = /\&amp\;\#8482\;/gi;
	var rExp_br = /\&lt\;BR\&gt\;/gi;
	var rExp_tm2 = /\&\#8482\;/gi;
	var rExp_rest = /\&amp\;\#174\;/gi;
	var rExp_copy = /\&amp\;\#169\;/gi;
	var rExp_italics_open = /\&lt\;I\&gt\;/gi;
	var rExp_italics_close = /\&lt\;\/I\&gt\;/gi;
	var rExp_time = /\&\#8211\;/gi;
	str = str.replace(rExp_sup, '');
	str = str.replace(rExp_tm, '');
	str = str.replace(rExp_br, '<br>');
	str = str.replace(rExp_tm2, '');
	str = str.replace(rExp_rest, '');
	str = str.replace(rExp_copy, '');
	str = str.replace(rExp_copy, '');
	str = str.replace(rExp_italics_open, '');
	str = str.replace(rExp_italics_close, '');
	str = str.replace('<I>', '');
	str = str.replace('</I>', '');
	str = str.replace('<i>', '');
	str = str.replace('</i>', '');
	str = str.replace(rExp_time, '');
	return str;
}

	// slice strings longer than 30 characters, append "..."
function stringParseLength(str, limit){
	str = str.slice(0, limit);
	if(str.length > 29)
		str += "...";
	return str;
}

function stringParseLengthWithCompleteWords(str, limit){


	str = str.replace("\"",'\'');

	var originalString = str;
	var lastIndexOfTruncatedString;	

	originalStringArr = str.match(/(\w+)/g)

	truncatedString =  originalString.slice(0, limit);
	truncatedStringArr = truncatedString.match(/(\w+)/g);
	
	lastIndexOfTruncatedString = (truncatedStringArr.length -1);
	
		if(truncatedStringArr[lastIndexOfTruncatedString].length < originalStringArr[lastIndexOfTruncatedString].length)
		{
				truncatedString = originalString.slice(0, limit - truncatedStringArr[lastIndexOfTruncatedString].length);
		}else
		{
			truncatedString = originalString.slice(0, limit);		
		}

	if(truncatedString.length > 29)
		truncatedString += "...";
	return truncatedString;
}

function stringParseLengthBuy(str, limit){
	str = str.slice(0, limit);
	return str;
}
function stringParseLengthDate(str, limit){
	str = str.slice(0, limit);
	if(str.length > 10)
		str += "";
	return str;
}

function stringParseLengthModule(str, limit){
	str = str.slice(0, limit);
	if(str.length > 16)
		str += "...";
	return str;
}

function stringParseLengthModule2(str, limit){
	str = str.slice(0, limit);
	if(str.length > 10)
		str += "..";
	return str;
}

function is(test, backup){
	if(!test) return backup;
	else return test;
}

function isNull(test, backup){
	if(!test) return backup;
	else return test + "<br>";
}

function getTimeStampFormatted(str){
	arr1 = str.split(" ");
	arr2 = arr1[0].split("-");
	month = getEnglishMonth(arr2[1]);
	day = arr2[2];
	year = arr2[0];
	return month + " " + day + ", " + year;
}

function getTimeStampYear(str){
	arr1 = str.split("-");
	year = arr1[0];
	return year;
}

function getEnglishMonth(str){
	var month;
	switch(str){
		case '01': month = "January"; break
		case '02': month = "February"; break
		case '03': month = "March"; break
		case '04': month = "April"; break
		case '05': month = "May"; break
		case '06': month = "June"; break
		case '07': month = "July"; break
		case '08': month = "August"; break
		case '09': month = "September"; break
		case '10': month = "October"; break
		case '11': month = "November"; break
		case '12': month = "December"; break
		default: month = "";
	}
	return month;
}

	var win = null;
	function NewWindow(mypage,myname,w,h,scroll){
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=true'
		win = window.open(mypage,myname,settings)
	}

function doDateFormat(startdate,enddate){

	if (startdate == enddate) 
	 var str = startdate;

	if (startdate != enddate) 
	 var str = startdate + " - " + enddate;
	return str;

}


function getEventDetails(eventCountry,eventCity,eventState)
{

	if(trim(eventCountry) == "United States" || trim(eventCountry) == "USA")
	{

		if(eventCity != null && eventCity != "")
			eventLocation = eventCity;


		if(eventState != null && eventState != "")
			eventLocation = eventLocation + ", " + eventState;

	}
	else if(trim(eventCountry) != "United States" || trim(eventCountry) != "USA")
	{

		if(eventCity != null && eventCity != "")
			eventLocation = eventCity;


		if(eventCountry != null && eventCountry!= "")
		{
			if(eventLocation != "")
				eventLocation += ", "  + eventCountry;
				else
				eventLocation = eventCountry;
		}	
	}
	return(eventLocation);

}

		// this function trims whitespaces
		function trim(str) 
		{
			while (1) 
			{
    				if (str.substring(0, 1) != " ")
		    		{
      				break;
      			}
		    		str = str.substring(1, str.length);
		  	}
		  	while (1) 
		  	{
	    		if (str.substring(str.length - 1, str.length) != " ")
      			{
      				break;
	      		}
    			str = str.substring(0, str.length - 1);
		  	}
		  		return str;
			}
		

function formURL(link,paraValue,paraName)
{
	var localLink;
	localLink = link.href;
	localLink = localLink + '&' + paraName + '=' + paraValue;
	link.href= localLink;
}

var newwindow = '';

function popitup(url)
{
	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,'saba_window');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
}

function percent(num,div)
{
	var result;
	result = (num/div)*100;
	result = Math.round(result);
	return result;
	
}



function popitup_encURL(url)
{

    var s = url;
    var lbound = s.substring(0,s.indexOf("description=")+12);
    var params = s.slice(s.indexOf("description=")+12,s.length);
    var theURL = lbound+escape(params);
   // link.href=theURL;


	if (!newwindow.closed && newwindow.location)
	{
		//newwindow.location.href = url;
		newwindow.location.href = theURL;
	}
	else
	{
		newwindow=window.open(theURL,'saba_window');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
}

function downloadPathForTrialSoftware_bews(fileName, title, path,protocol)
{	var globalPath;

	if(protocol == 'http')
	{		   
		globalPath = "http://download1.veritas.com/downloads/";
	}	
	else		
	{	
		globalPath = "http://download1.veritas.com/downloads/";
	}	
	str = "<a href='" + globalPath +  path + "/" + fileName + "' class='linkmodule'>" + title + "</a>";	
	
	return(str);
}

function veritasPopupShow(formName, popupName, target) {
	var popup = document[formName].elements[popupName];
	window.open(popup.options[popup.selectedIndex].value, target);
	popup.selectedIndex = 0;
}

function veritasOpenWin(URL, target, properties) {
	if(URL == '/hipbone/prelaunch.html')
	{
		URL = '/webchat/prelaunch.jsp';
	}
	window.open(URL, target, properties);
}


/************ detect_new.js ************/
<!-- 

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function worldWideRedirector() {
	return;
    var URL; 

    if (!document.countryNav)
    {
        URL = document.form.site.options[document.form.site.selectedIndex].value;        
    }
    else
    {
	URL = document.countryNav.country.options[document.countryNav.country.selectedIndex].value;
    }
    window.location.href = URL; 
  
}


// End -->



/************ global.js ************/
/////////////////////// FUNCTIONS FOR GLOBAL PAGES //////////////////////////
function getLanguageCode() {
	var path = location.href;
	//var pattern = /(\w+):\/\/([\w.:]+)\/(\w*)/;
	var pattern = /\/([a-z]{2})\/[A-Z]{2}\//;
	var new_path = path.match(pattern);

	if (new_path && new_path[1]) {
		return new_path[1];
	} else if (path.indexOf("lCode") >= 0) {
		pattern = /lCode\=(\w{2})/;
		new_path = path.match(pattern);
		return (new_path && new_path[1] && new_path[1].length == 2) ? new_path[1] : "en";
	} else if (path.indexOf("&ln=") >= 0 || path.indexOf("?ln=")) {
		pattern = /[\&\?]ln\=(\w{2})/;
		new_path = path.match(pattern);
		return (new_path && new_path[1] && new_path[1].length == 2) ? new_path[1] : "en";
	}
}

function getCountryCode() {
	var path = location.href;
	//var pattern = /(\w+):\/\/([\w.:]+)\/(\w*)\/(\w*)/;
	var pattern = /\/[a-z]{2}\/([A-Z]{2})\//;
	var new_path = path.match(pattern);

	if (new_path && new_path[1]) {
		return new_path[1];
	} else if (path.indexOf("cCode") >= 0) {
		pattern = /cCode\=(\w{2})/;
		new_path = path.match(pattern);
		return (new_path && new_path[1] && new_path[1].length == 2) ? new_path[1] : "US";
	} else if (path.indexOf("&ln=") >= 0 || path.indexOf("?ln=")) {
		pattern = /[\&\?]ln\=(\w{2})_(\w{2})/;
		new_path = path.match(pattern);
		return (new_path && new_path[2] && new_path[2].length == 2) ? new_path[2] : "US";
	}
}

function getImagePath() {
	if (getCountryCode() == "TW") {
		return "/" + getLanguageCode() + "/" + getCountryCode();
        } else if ((getLanguageCode() == "fr") && (getCountryCode() == "CA")) {
                return "/" + getLanguageCode() + "/" + getCountryCode();
	} else if (location.href.indexOf("/jp/") >= 0) {
		return "/ja";
	} else if (location.href.indexOf("/fi/") >= 0) {
		return "/en";
	} else if (location.href.indexOf("/uk/") >= 0) {
		return "/en";
	} else if (location.href.indexOf("/de/") >= 0) {
		return "/de";
	} else if (location.href.indexOf("/dk/") >= 0) {
		return "/da";
	} else if (location.href.indexOf("/fr/") >= 0) {
		return "/fr";
	} else if (location.href.indexOf("/no/") >= 0) {
		return "/no";
	} else if (location.href.indexOf("/pl/") >= 0) {
		return "/pl";
	} else if (location.href.indexOf("/tw/") >= 0) {
		return "/zh/TW";
	} else if (location.href.indexOf("/cn/") >= 0) {
		return "/zh";
	} else {
		return "/" + getLanguageCode();
	}
}

function preloadImages() {
  var d = document; 
  if (d.images) { 
		if (!d.MM_p) {
			d.MM_p=new Array();
		}
	var i,j=d.MM_p.length,a=preloadImages.arguments; 
	for (i=0; i<a.length; i++) {
		if (a[i].indexOf("#")!=0) { 
				d.MM_p[j] = new Image; 
				d.MM_p[j++].src = getImagePath() + a[i];
			}
		}
	}
}

function swapImg(obj, img) {
	obj.src = getImagePath() + img;
}

function navGo(path) {	
	// BUG FIX FOR ATG SESSION HANDLING (WHEN COOKIES ARE DISABLED)
	//alert(navigator.cookieEnabled);
	if (navigator.cookieEnabled == false || navigator.cookieEnabled == null) {
		//alert("COOKIES DISABLED");
		var sessionStr = "";
		var regex = /;\w*=\w*/;
		var sessionArr = location.href.match(regex);

		// BUILD THE SESSION STRING
		if (sessionArr) {
			sessionStr = sessionArr[0];
			//alert("MATCH: sessionStr = " + sessionStr);
		} else {
			//alert("document.sessionForm.sessionName.value = " + document.sessionForm.sessionName.value);
			var sessionName = document.sessionForm.sessionName.value;
			var sessionId = document.sessionForm.sessionId.value;
			if (sessionName && sessionId) {
				sessionStr = sessionName + sessionId;
				//alert("NO MATCH: sessionStr = " + sessionStr);
			} else {
				//alert("ERROR: NO MATCH: sessionStr = " + sessionStr);
			}
		}

		// APPEND SESSION STRING TO URL
		if (path.indexOf("?") >= 0) {
			var pArray = path.split("?");
			path = pArray[0] + sessionStr + "?" + pArray[1];
		} else {
			path += sessionStr;
		}

	} else {
		//alert("COOKIES ENABLED");
	}

	// extra lines of code are for static forms
	if (location.href.indexOf("/jp/") >= 0) {
		location = "/ja/JP" + path;
	} else if (location.href.indexOf("/hk/") >= 0) {
		location = "/en/HK" + path;
	} else if (location.href.indexOf("/de/") >= 0) {
		if (location.href.indexOf("/de/AT/") >= 0) {
			location = "/de/AT" + path;
		} else if (location.href.indexOf("/de/CH/") >= 0) {
			location = "/de/CH" + path;
		} else if (location.href.indexOf("/de/DE/") >= 0) {
			location = "/de/DE" + path;
		} else {
			location = "/de/DE" + path;
		}
	} else if (location.href.indexOf("/dk/") >= 0) {
		location = "/da/DK" + path;
	} else if (location.href.indexOf("/emea/") >= 0) {
		location = "/en/UK" + path;
	} else if (location.href.indexOf("/fi/") >= 0) {
		location = "/en/FI" + path;
	} else if (location.href.indexOf("/fr/") >= 0) {
                if (location.href.indexOf("/fr/CA/") >= 0) {
                        location = "/fr/CA" + path;
		} else {
			location = "/fr/FR" + path;
		}
	} else if (location.href.indexOf("/no/") >= 0) {
		location = "/no/NO" + path;
	} else if (location.href.indexOf("/pl/") >= 0) {
		location = "/pl/PL" + path;
	} else if (location.href.indexOf("/uk/") >= 0) {
		location = "/en/UK" + path;
	} else {
		// used for everything but the forms
		location = "/" + getLanguageCode() + "/" + getCountryCode() + path;
	}
	return false;
}

function initLayers() {
	showImages(getPageType());
	if (getPageType()) {
		showMenu(getPageType());
	}
}

function search() {
	document.seek1.lCode.value = getLanguageCode();
	document.seek1.cCode.value = getCountryCode();
	document.seek1.la.value = getLanguageCode();
	if ((location.href.indexOf("/jp/") >= 0) || (location.href.indexOf("/vsupport-jp/") >= 0)) {
		document.seek1.lCode.value = "ja";
		document.seek1.cCode.value = "JP";
		document.seek1.la.value = "ja";
	} 	
	document.seek1.action = "/servlet/search";
}

function advSearch() {
	if (getLanguageCode() == "en") {
		// GOOGLE SEARCH
		location = "/search/advanced_search.jsp?ln=" + getLocaleString();
	} else {
		// OLD SEARCH
		// extra lines of code are for static forms
		if (location.href.indexOf("/jp/") >= 0) {
			location = "/servlet/search?lCode=ja&cCode=JP&searchType=advanced";
		} else if (location.href.indexOf("/vsupport-jp/") >= 0) {
			location = "/servlet/search?lCode=ja&cCode=JP&searchType=advanced";
		} else if (location.href.indexOf("/hk/") >= 0) {
			location = "/servlet/search?lCode=en&cCode=HK&searchType=advanced";
		} else if (location.href.indexOf("/de/") >= 0) {
			if (location.href.indexOf("/de/AT/") >= 0) {
				location = "/servlet/search?lCode=de&cCode=AT&searchType=advanced";
			} else if (location.href.indexOf("/de/CH/") >= 0) {
				location = "/servlet/search?lCode=de&cCode=CH&searchType=advanced";
			} else {
				location = "/servlet/search?lCode=de&cCode=DE&searchType=advanced";
			}
		} else if (location.href.indexOf("/dk/") >= 0) {
			location = "/servlet/search?lCode=da&cCode=DK&searchType=advanced";
		} else if (location.href.indexOf("/emea/") >= 0) {
			location = "/servlet/search?lCode=en&cCode=UK&searchType=advanced";
		} else if (location.href.indexOf("/fi/") >= 0) {
			location = "/servlet/search?lCode=en&cCode=FI&searchType=advanced";
		} else if (location.href.indexOf("/fr/") >= 0) {
			location = "/servlet/search?lCode=fr&cCode=FR&searchType=advanced";
		} else if (location.href.indexOf("/no/") >= 0) {
			location = "/servlet/search?lCode=no&cCode=NO&searchType=advanced";
		} else if (location.href.indexOf("/pl/") >= 0) {
			location = "/servlet/search?lCode=pl&cCode=PL&searchType=advanced";
		} else if (location.href.indexOf("/uk/") >= 0) {
			location = "/servlet/search?lCode=en&cCode=UK&searchType=advanced";
		} else {
			location = "/servlet/search?lCode=" + getLanguageCode() + "&cCode=" + getCountryCode() + "&searchType=advanced";
		}
	}
}

function getLocaleString() {

	var locale_string;

        // extra lines of code are for static forms
        if (location.href.indexOf("/jp/") >= 0) {
                locale_string = "ja_JP";
        } else if (location.href.indexOf("/vsupport-jp/") >= 0) {
                locale_string = "ja_JP";
        } else if (location.href.indexOf("/hk/") >= 0) {
                locale_string = "en_HK";
        } else if (location.href.indexOf("/de/") >= 0) {
                if (location.href.indexOf("/de/AT/") >= 0) {
                        locale_string = "de_AT";
                } else if (location.href.indexOf("/de/CH/") >= 0) {
                        locale_string = "de_CH";
                } else if (location.href.indexOf("/de/DE/") >= 0) {
                        locale_string = "de_DE";
                } else {
                        locale_string = "de_DE";
                }
        } else if (location.href.indexOf("/dk/") >= 0) {
                locale_string = "da_DK";
        } else if (location.href.indexOf("/emea/") >= 0) {
                locale_string = "en_UK";
        } else if (location.href.indexOf("/fi/") >= 0) {
                locale_string = "en_FI";
        } else if (location.href.indexOf("/fr/") >= 0) {
                locale_string = "fr_FR";
        } else if (location.href.indexOf("/no/") >= 0) {
                locale_string = "no_NO";
        } else if (location.href.indexOf("/pl/") >= 0) {
                locale_string = "pl_PL";
        } else if (location.href.indexOf("/uk/") >= 0) {
                locale_string = "en_UK";
        } else {
		return (getLanguageCode() + "_" + getCountryCode());
	}
	return locale_string;
}


//used in worldwide page to set the user preference in a cookie
function setVeritasCookie(f) {
	// set cookie expiration date to two year from now
	var expDate = new Date();
	expDate.setFullYear(expDate.getFullYear()+2);
	var expDateString = expDate.toGMTString();
	var vrtsww_cookie = f.locale.value;
	if (vrtsww_cookie) {
		if (f.perm.checked) {
			document.cookie = "vrtsww=" + escape(vrtsww_cookie) + "; expires=" + expDateString + "; path=" + "";
		} else {
			f.permChecked.value = "no";
		}
		f.action = vrtsww_cookie;
		f.submit();
	}
}


/************ media.js ************/
var mediaPlayer;

function openMediaWindow(name, url, width, height, properties) {
	var left = (screen.availWidth - width) / 2; 
	var top = (screen.availHeight - height) / 2;
	if (height == screen.availHeight) {
		top = 0;
		height -= 60;
		width -= 10;
	}
	properties += (properties) ? "," : "";
	properties += "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",screenX=" + top + ",screenY=" + left;
	mediaPlayer = window.open(url, name, properties);
	mediaPlayer.focus();
}

function launchMedia(mediaId, mediaPlayer) {
	var width = "557";
	var height = "555";
	var	url = "/Products/media?c=mediachallenge&mediaId=" + mediaId + "&mediaPlayer=" + mediaPlayer;
	if (location.href.indexOf("http://go.veritas.com") >= 0) {
		url = "http://www.veritas.com" + url;
	}
	if (mediaPlayer == "E") {
		width = "770";
		height = "552";
	}
	openMediaWindow("popup", url, width, height, "location=0,toolbar=0,status=0,menubar=0,resizable=1");
}

function launchFlash(filePath) {
	if (filePath.indexOf("http") != 0) {
		filePath = "http://eval.veritas.com/mktginfo" + filePath;
	}
	openMediaWindow("flash", filePath, screen.availWidth, screen.availHeight, "location=0,toolbar=0,status=0,menubar=0,resizable=1");
}


/* *** Functions for Sub-Navigation added by Dennis Hart *** */

function showSubNav(thisitem) {
	var divname = "subnav"+thisitem;
	var thediv = document.getElementById(divname);
	if (thediv && thediv.style) {
		thediv.style.visibility = 'visible';
	}
}
	
function hideSubNav(thisitem) {
	var divname = "subnav"+thisitem;
	var thediv = document.getElementById(divname);
	if (thediv && thediv.style) {
		thediv.style.visibility = 'hidden';
	}
}
	
/* *** END Functions for Sub-Navigation added by Dennis Hart *** */
