$(function() {
$( "table.striped" ).each(function() {
	$(this).find("tbody tr:odd").addClass("even");
});
if ($("a.checksum").length){
	$("a.checksum").cluetip({cluetipClass:'checksum',local:false,splitTitle:'|'});
}
if ($('a.sw_alert').length){
	$('a.sw_alert').cluetip({cluetipClass: 'orange', width:'250'});
}
if ($('div#softserv_header').length){
	$.get('http://www.juniper.net/shared/header-global-support.html', function(data) {
		$('div#softserv_header').html(data);
	});
}
if ($('div#softserv_footer').length){
	$.get('http://www.juniper.net/shared/footer20-support.html', function(data) {
		$('div#softserv_footer').html(data);
	});
}
var ctArray = [];

if(!Array.prototype.indexOf){
    Array.prototype.indexOf=function(obj,start){
        for(var i=(start||0),j=this.length;i<j;i++){
            if(this[i]==obj){return i;}
        }
        return -1;
    }
}

//creates plugin declarations based on classes of "ct_" found. e.g. ct_green_500 is a clue tip colored green 500px wide.
$("a[class^='ct_']").each(function () {
	var classList =$(this).attr('class').split(/\s+/);
	var myRel =$(this).attr('rel');
	var re = new RegExp("^#");
	var ctlocal = re.test(myRel);	
	for (i = 0; i < classList.length; i++) {
		var re = new RegExp("ct_*");
		var myClass = re.test(classList[i]);
		if (myClass == true ) {
			if (ctArray.indexOf(classList[i]) == -1) {		
				var myclass = classList[i].split("_");
				var ctclass = myclass[1];
				if(ctclass == "") {
					ctclass="default";
				}
				var ctwidth = myclass[2];
				$("a." + classList[i]).cluetip({cluetipClass: ctclass, width: ctwidth,local: ctlocal});	
				ctArray.push(classList[i]);
			}
		}
	}
});

//creates a popup icon when hovering over a link with a ct_* (wildcard) class.
$("a[class^='ct_']").hover(function () {
	$(this).append($('<span class="ctpop"><img alt="popup" height="9" width="14" src="../../../../../../../../support/assets/img/popup.gif" /></span>'));
}, 
function () {
	$(this).find("span.ctpop").remove();
});
//creates a lock icon when hovering over a link with a "lock" class.
$("a.lock").hover(function () {
	$(this).append($('<span class="ctpop">&nbsp;<img alt="lock" height="12" width="10" src="../../../../../../../../shared/img/global/icon-lock.gif" /></span>'));
}, 
function () {
	$(this).find("span.ctpop").remove();
});
//creates a pdf icon when hovering over a link with a "pdf_" class. Optionally the size is provided as part of the class, eg. <a class="pdf_85kB" href=".. then that size is shown
$("a[class^='pdf_']").hover(function () {
	var classList=$(this).attr('class').split(/\s+/);
	for (i = 0; i < classList.length; i++) {
	var re = new RegExp("pdf_*");
	var myClass = re.test(classList[i]);
	if (myClass == true ) {
		var myclass = classList[i].split("_");
		var pdfsize = myclass[1];
		$(this).append($('<span class="pdfpop"> <img alt="pdf" height="12" width="10" src="../../../../../../../../shared/img/global/icon-pdf.gif" /> ' + pdfsize + '</span>'));
	};
	};
},	
function () {
	$(this).find("span.pdfpop").remove();
});

function unique(arrayName){
	var newArray=new Array();
	label:for(var i=0; i<arrayName.length;i++ )
		{  
			for(var j=0; j<newArray.length;j++ )
			{
			if(newArray[j]==arrayName[i]) 
				continue label;
			}
			newArray[newArray.length] = arrayName[i];
		}
	return newArray;
}
			
/*
	$("#topCountryDrop").mouseover(function(){
    	showCountry();
    }).mouseout(function(){
    	hideCountry();		
    });
	
	$("ul.topCountryList li").mouseover(function(){
    	$(this).removeClass().addClass("over");
    }).mouseout(function(){
    	$(this).removeClass().addClass("out");		
    });
	
$("ul.topCountryList li a").click(function() {
	var l=$(this).attr("href").split("/");
	var cl = l.length;
	var location= "http://www.juniper.net/"+ l[cl-3]+"/"+l[cl-2]+"/";
	var	j_options = { path: 'http://www.juniper.net/', expires: 365};
	setCookie("countryCookie", location, j_options );
});
*/
});

function WriteEa (first, second, third, subject) {
		var display, ema, ea;
		
		//if no subject is present
		if (subject == null){
			ema = first + second + third + '\&\#64\;' + 'juniper' + '\&\#46\;' + 'net';
			display = ema;
		}
		
		else{
			display = first + second + third + '\&\#64\;' + 'juniper' + '\&\#46\;' + 'net' //text to display
			ema = first + second + third + '\&\#64\;' + 'juniper' + '\&\#46\;' + 'net' + '@subject=' + subject //actual go-to link
		}		
		
		ea = '<a href=\"ma' + 'ilto:' + ema + '"' + '>' + display + '</a>' //writes href code and displays
		
		document.write (ea);
}