// JavaScript Document
// JavaScript Document
// JavaScript Document
//cookie method//
// main variable//
var s=s_gi(s_account);

function setNetappSimpleCookie(name,eventName)
{
	var cookieVal;
	var cookieName;
	var expireDate = new Date ();
	var year = expireDate.getYear();
	if (year < 1000)
	{
		year = year + 1900;
	}
	expireDate.setYear(year + 5);
	
	if (eventName == "" || eventName == null || eventName == undefined || !(eventName))
	{
		eventName = "unknown";
	}
	cookieName = "netappClix_" + name;
	
	if((getCookie(cookieName) != '') && (getCookie(cookieName)))
	{
		cookieVal = getCookie(cookieName);
		cookieVal++;
		setCookie(cookieName,cookieVal,expireDate);
	}
	else
	{
		setCookie(cookieName,1,expireDate);
		cookieVal = 1;
	}
	
	returnEventVal = eventName + " -QX- " + cookieVal;
	return returnEventVal;
}

//
var videoName = ""
var rm_prop13 = ""
var prop13 = ""
var prop14 = ""
var prop18 = ""
var eVar7 = ""
var event5 = ""
var eventVal=""
var eventValArray=""
var videoType = ""
var originalURL = String(document.location)
var featureContentConversionStepsArray = ["#1 Featured Content Window","#2 Registration Page","#3 Registration Confirmation","#4 Download Page","#5 item downloaded"];

var featureContentArraySteps = ["Featured Content window page","Registration page","Registration confirmation screen","Download Page","Download Complete"]



/* This method is used for the Data collection from Forms  submitOmnitureForms([Array of form values],[Form Even],[Redirect URL])*/

function submitOmnitureForms(formdata,eventName,url)
{
	var eventVal = setNetappCookie(eventName);
	
	var eventValArray = eventVal.split(" -QX- ");
	
	var s=s_gi(s_account)
	
	s.linkTrackVars="eVar15,eVar16,eVar17,eVar18,eVar19,events";
	s.linkTrackEvents="event5";
	// Create a regular expression to search all +s in the string
	var lsRegExp = /\+/g;
	
	for(var i=0; i<formdata.length; i++)
	{
	       
               //alert(formdata[i])
		if(formdata[i] != undefined && formdata[i] != "")
		{
			
                        // Return the decoded string
			//alert(unescape(formdata[i].replace(lsRegExp, " ")))
                        s['eVar'+(15+i)] = unescape(formdata[i].replace(lsRegExp, " ")); 
			
		}
		else
		{
			s['eVar'+(15+i)] = ""
		}
	}
	//alert(s.eVar16+"   "+s)
	if (String(document.location).indexOf("forms/ad_reg.html") >= 0)
	{
		s.eVar7="Campaign_Content_Registration";
	}
	else
	{
		s.eVar7=eventValArray[0];
	}
	s.eVar8=eventValArray[0] + " - " + eventValArray[1];
	s.eVar9="+1";
	s.events = 'event5'
	s.tl(this,"o",eventValArray[0]);
	
	
        if(url != undefined && url!="")
        {
	document.location = url;
        } 
}
function submitOmniture(fTechStrat,fDnldURL,fEventName)
{
	if (fEventName != "" && fEventName != null && fEventName != undefined)
	{
	}
	else if((fEventName.indexOf("SEM-") >= 0 || fEventName == 'Contentent_Registration' ||fEventName == 'Content_Registration' ) && ( fTechStrat =="" && fDnldURL == "" ))
	{
		return;
	}
	else
	{
		fEventName = "";
	}
	if(fEventName == "chat_initiated")
	{
		fEventName  =  'chat_link_initiated'
	}
	
	
	var s=s_gi(s_account)
	s.linkTrackVars="prop6,prop11,prop14,prop15,prop17,prop19,eVar7,prop7,prop8,eVar8,eVar9,events";
	s.linkTrackEvents="event5";
	
	if(fEventName == "Spot Light Tracking")
	{
		//fEventName = "SpotLight Tracking"
	}
	else
	{
	var lsRegExp = /\+/g;
	fEventName = unescape(fEventName.replace(lsRegExp, " ")); 
	eventVal = setNetappCookie(fEventName);
	eventValArray = eventVal.split(" -QX- ");
	}
	 if(fTechStrat.split(" ")[0] == "Spotlight")
	{
		// do nothing 
	}
	else
	{
		s.prop14=eventValArray[0];
	    s.prop15=eventValArray[0] + " - " + eventValArray[1];
	}
	
	if(fEventName == "chat_link_initiated")
	{
			s.prop17 = "Chat Link Tracking"
	}
	if (fDnldURL != "" && fDnldURL != null && fDnldURL != undefined)
	{
		if(fDnldURL.indexOf("?")>0)
		{
			fDnldURL = fDnldURL.split("?")[0];
		}
		fDnldURL = unescape(fDnldURL.replace(lsRegExp, " ")); 
	}
	else
	{
		fDnldURL="";
	}
	
	if (fTechStrat != "" && fTechStrat != null && fTechStrat != undefined && !fTechStrat.split(" ")[0] == "Spotlight")
	{
		//fTechStrat = unescape(fTechStrat.replace(lsRegExp, " ")); 
		s.prop6=fTechStrat;
		s.prop11= fTechStrat + ":" +  unescape(fDnldURL.replace(lsRegExp, " ")); 
		s.prop4=fDnldURL;
	}
	else
	{
		s.prop6="";
		fDnldURL = unescape(fDnldURL.replace(lsRegExp, " ")); 
		s.prop11=fDnldURL;
		s.prop4="";
	}
	if (fDnldURL.indexOf("forms/ad_reg.html") >= 0)
	{
		s.eVar7="Campaign_Content_Registration";
	}
	else if(fTechStrat.split(" ")[0] == "Spotlight")
	{
	/*
	
	SpotLight Tracking 
	Prop7 = Pagename of spotlight location | "Spotlight" #  (ex:  us:index | Spotlight 1  or us:products:index | Spotlight 3 ) 
	Prop8 = Pagename of ad location | "Spotlight" # | Description (ex: us:index | Spotlight 1 | Netapp Dedupes EMC Storage) 
	Prop19 = Description | Destination URL (ex: Netapp Dedupes EMC Storage | us/company/news/news-rel-20080730) 
	
	fTechStrat == spotlight placement ex:Spotlight 1
	fDnldURL   == spotlight URL ex:  us/company/news/news-rel-20080730
	fEventName == spotLight Description ex: Netapp Dedupes EMC Storage
	
	*/
	
	fDnldURL = unescape(fDnldURL.replace(lsRegExp, " ")); 
	fTechStrat = unescape(fTechStrat.replace(lsRegExp, " ")); 
	s.prop7 = s.pageName+"|"+fTechStrat
	s.prop8 = s.pageName+"|"+fEventName
	s.prop19 = fEventName+"|"+fDnldURL
	
	}
	else
	{
		s.eVar7=eventValArray[0];
	}
	if(fTechStrat.toLowerCase().indexOf("spotlight") > 0)
	{
		//do nothing
	}
	else{
	s.eVar8=eventValArray[0] + " - " + eventValArray[1];
	s.eVar9="+1";
	s.events="event5";
	}
	
	s.tl(this,"o",eventValArray[0]);
}

function trackRichMediaContentForOmniture(param,type)
{
	//alert("param  :"+param)
        var s=s_gi(s_account)
	switch(type.toLowerCase())
	{
		case ("videostart"):
		videoName = param+"|video_start"
                videoType = "video_start"
		break;
		case("videopause"):
		videoName = param+"|video_pause"
videoType = "video_pause"
		break;
		case ("videostop"):
		videoName = param+"|video_stop"
videoType = "video_stop"
		break;
		case ("videocomplete"):
		videoName = param+"|video_complete"
videoType = "video_complete"
		break;
		case ("prop13"):
		rm_prop13 = s.pageName+"|"+param;
		default:
		videoName = param;
	}
	(rm_prop13 != undefined && rm_prop13 != "") ? prop13 = rm_prop13 : prop13 = "";
	(videoName != undefined && videoName != "") ? prop18 = videoName : prop18 = "";
	(videoName != undefined && videoName != "") ? eVar7 = videoName.split("|")[1] : eVar7 = "";
	(videoName != undefined && videoName != "") ? event5 = videoName : event5 = "";
	//(videoName != undefined && videoName != "") ? prop14 = videoName.split("|")[1] : prop14 = "";
	
	//alert(prop13+" : "+prop14+" : "+eVar7+" : "+event5+" : "+ prop18)
	var eventprop = "Flash Module Tracking"
	//(prop14 !="") ? eventprop = prop14 : eventprop = prop13
	eventVal = setNetappCookie(eventprop);
	eventValArray = eventVal.split(" -QX- ");
	s.linkTrackVars="prop13,prop14,prop18,eVar7,eVar8,eVar9,events";
	s.linkTrackEvents="event5";
	//s.prop14 = prop14;
	s.prop13 = prop13;
	//alert(prop13)
	if(videoType != "")
	{
		s.prop18 = prop13+"|"+videoType;
	}
	else{
		s.prop18 = "";
	}
	
	
	s.eVar7 = eVar7;
	s.events="event5";
	s.eVar8=eventValArray[0] + " - " + eventValArray[1];
	//s.eVar9="+1";
	s.tl(this,"o",eventValArray[0]);
}
// Technical Vs Strategic Logic
var ftechVar = "";
try {
	ftechVar = document.getElementById("ftechstrat").value;
	if(ftechVar != "")
		s.prop6 = ftechVar; 
	else
		s.prop6='NA';
}
catch(err) {
		s.prop6='NA';
}
// end of Logic




function submitFeaturedContent(state,url)
{
    	var s=s_gi(s_account)
	var evar11 = readCookie("evar11")
	if(evar11 == null)
	{
		var urlpars = url.split("?")[1]
		//b=t&intcid=fc_18
		var tempArray = urlpars.split('&') 
		for( i=0; i< tempArray.length; i++ )
		{	
			if(tempArray[i].split("=")[0] == "intcid")
			{
				if(tempArray[i].split("=")[1].indexOf("_") > -1)
					{
						
						var eVar11 = tempArray[i].split("=")[1]
						if(eVar11.indexOf("_"))
						{
							createCookie("evar11",eVar11,30)	
							featuredCount = featuredCount+ "eVar11 ="+eVar11
							createCookie("featuredCount",featuredCount,30)
							evar11 = eVar11
						}						
					}	
					
					
			}
		}
	}
	else
	{
	var eVar11 = evar11
	}
	
	
	var pevent28 =""
	switch (state){
	
		case "featured content window" :
		//s.prop10 = "new";
		s.linkTrackEvents="event27,event28";
		s.linkTrackVars="prop14,prop15,eVar2,eVar7,eVar28,eVar8,eVar9,eVar11,events,eVar31,eVar30,eVar32";
		s.prop14 = "window clickthrough";
		s.prop15 = "featured content"
		s.eVar7=s.prop14
		s.eVar8=s.prop15
		s.eVar2 = "content registration"
		s.eVar11 = eVar11//findVar("intcid");
		s.eVar30=s.pageName
		featuredCount = featuredCount+ "_   featured content window" 
		createCookie("featuredCount",featuredCount,30)
		if(eVar11.indexOf("_") > -1)
		{
		featuredCount = featuredCount+ "_   Featured Content Registration" 
		createCookie("featuredCount",featuredCount,30)
		s.eVar31="Featured Content Registration"
		s.eVar32="#1 Featured Content Window"
		s.eVar28 = s.prop10
		pevent28 = ",event28"
		}
		s.events="event27"+pevent28
		
		
		break;
		
		case "download complete" :
		
		s.linkTrackVars="prop14,prop15,eVar2,eVar7,eVar28,eVar8,eVar9,eVar11,events,eVar31,eVar30,eVar32";
		s.linkTrackEvents="event28,event4,event5";
		
		//s.prop10 = "Download";
		s.prop15 = "pdf download"
		s.eVar2 = "content registration"
		s.eVar7=s.prop14
		s.eVar8=s.prop15
		s.eVar9 = ""
		s.eVar6 = url
		s.eVar11 = eVar11;
		featuredCount = featuredCount+ "_ content registration" 
		createCookie("featuredCount",featuredCount,30)
		//if(eVar11.indexOf("_") > -1)
		
		featuredCount = featuredCount+ "_ #5 item downloaded" 
		createCookie("featuredCount",featuredCount,30)
		s.eVar31 = "Featured Content Registration"
		s.eVar32 = "#5 item downloaded"
		s.eVar28 = s.prop10
		pevent28 = ",event28"
		
		s.evar26 = "userType"
		s.events= "event4,event5"+pevent28
		
		//alert('modefied code')
		
                break;
                  
		default :

		document.write("no data created");
		
		
		// dont track any data on clickthroughs
		
	}
}
	

//alert(s.prop10+"  :"+s.prop14+"  :"+s.prop15+"  :"+s.eVar9+"  : "+s.eVar23+"  :"+s.eVar24+"  : "+conversionStep+" : "+userType)

function updateContent(id,content)
{
	var item = document.getElementById(id)
	var econtent = item.innerHTML
	item.innerHTML = econtent+"<br />"+content
}
