
	// Opens a pop-up when the function is called.
  	function openPopUp(url,navStatus,name,height,width) {
 		//Opens the popup window.
		var newwindow;
		newwindow=window.open(url,name,'height='+height+',width='+width+',scrollbars='+navStatus+',toolbar='+navStatus+',menubar='+navStatus+',status=yes');
	}

	function getXmlHttpRequestObject(){
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest(); //Not IE	
		} 
		else if(window.ActiveXObject) {		
			return new ActiveXObject("Microsoft.XMLHTTP"); //IE	
		}
		 else {		
			alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");
		}
	}

	function popup(url,navStatus,size) {
 			//Opens the popup window.
 		var height = 400;
 		var width = 450; 
 		if(size == "BIG"){
 			height = 600;
 			width = 450;
 		}
 		
 		if(url.indexOf('?' != -1)){
 			url = url.replace("?", "?popUp=true&");
 		}else{
 			url = url+"?popUp=true";
 		}
 		
 		var newwindow=window.open(url,'','height='+height+',width='+width
 								  +',scrollbars=yes'
 								  +',toolbar='+navStatus
 								  +', menubar='+navStatus
 								  +',status=no');
	}

 	//Populates the parameters to be passed for Page Tagging and returns in the form of a url.
 function getPageTaggingParameters(VsPageInfo){

	//Retrieving the Page Context. 	
 	var page = bea.wlp.disc.context.Page.findByLabel(VsPageInfo.pageLabel);
 	
 	//Retriving the LOB name from the Page Context.
	 var lob = VsPageInfo.lobId;

 	//Retriving the Portlets Information from Page Context
 	var placables = page.getPlaceables();

 	//Retriving the page's Layout Information.	
 	
 	if(page.getType() == 'Book'){
            page = page.getPage();
      }     
 	var layout = page.getLayout().getMarkupName();
 
 	var temp = 'capital_one_';
 	var index = layout.indexOf(temp);
 	if(index !=-1)
 	{
 		layout = layout.substring(index+temp.length);
 	}
 	else
 	{
 		layout = layout.toLowerCase();
 		temp = 'layout-';
 		index = layout.indexOf(temp);
 		if(index !=-1)
 		{
	 		layout = layout.substring(index+temp.length);
	 		
 		}	
 	}

	var randomnumber=Math.floor(Math.random()*111111);	

 	Pg_Tag_url = "?log=1"+
 				"&r="+randomnumber+
 				"&System=www"+
 				"&LOB="+lob+
 				"&TestCell="+VsPageInfo.testCell+
 				"&Segment="+VsPageInfo.segment+
 				"&Experience="+VsPageInfo.experience+
 				"&PageName="+VsPageInfo.pageViewName+
 				"&PageType="+VsPageInfo.pageType+
 				"&Layout="+	layout+
 				"&EventType=page";
 	
 	return 	Pg_Tag_url;		
 }
 
 //Populates the parameters to be passed for Page Tagging and returns in the form of a url.
 function getComponentTaggingParameters(VsPageInfo){
	
	//Retrieving the Page Context. 	
 	var page = bea.wlp.disc.context.Page.findByLabel(VsPageInfo.pageLabel);
 	
 	//Retriving the LOB name from the Page Context.
	 var lob = VsPageInfo.lobId;

 	//Retriving the Portlets Information from Page Context
 	var placables = page.getPlaceables();

 	//Retriving the page's Layout Information.	
 	
 	var temp = VsPageInfo.portlet;
 	var index = temp.indexOf('_');
 	
 	var portletLocation = temp.substring(0,index);
 	var portletTitle = temp.substring(index+1);

	var randomnumber=Math.floor(Math.random()*111111);
 	
 	Cmpt_Tag_url = "?log=1"+
				"&r="+randomnumber+	
 				"&LOB="+lob+
 				"&TestCell="+VsPageInfo.testCell+
 				"&PageName="+VsPageInfo.pageViewName+
 				"&Segment="+VsPageInfo.segment+
 				"&PortletLocation="+portletLocation+
 				"&ComponentName="+portletTitle+
 				"&EventType=component";
 	
 	if(VsPageInfo.strategy != 'null' && VsPageInfo.strategy!='')
 	{
 		Cmpt_Tag_url = Cmpt_Tag_url+"&ComponentStrategy="+VsPageInfo.strategy;
 	}
 	
 	if(VsPageInfo.cmptTestCell != 'null' && VsPageInfo.cmptTestCell!='')
 	{
 		Cmpt_Tag_url = Cmpt_Tag_url+"&ComponentTestCell="+VsPageInfo.cmptTestCell;
 	}
 	return 	Cmpt_Tag_url;	
 }
 
  //Retrieves the link Tagging parameters from request 
  function getLinkTaggingParameters(VsLinkInfo)
  {
		var link_Tag_url;
		if(VsLinkInfo.lobId != 'null' && VsLinkInfo.lobId !='')
		{
			
			link_Tag_url  = "&LOB="+ VsLinkInfo.lobId+
						    "&Segment="+	VsLinkInfo.Segment+
							"&TestCell="+ VsLinkInfo.TestCell+
							"&PageName="+ VsLinkInfo.PageName+
							"&EventType="+ VsLinkInfo.EventType+
							"&ComponentType="+ VsLinkInfo.ComponentType+
							"&ContentElement="+ VsLinkInfo.ContentElement+
							"&TargetPageName="+ VsLinkInfo.TargetPageName;
					
			if(VsLinkInfo.PortletLocation != 'null' && VsLinkInfo.PortletLocation!='')
			{
				link_Tag_url = link_Tag_url+"&PortletLocation="+VsLinkInfo.PortletLocation;
			}
			if(VsLinkInfo.ComponentName != 'null' && VsLinkInfo.ComponentName!='')
			{
				link_Tag_url = link_Tag_url+"&ComponentName="+ VsLinkInfo.ComponentName;
			}
			if(VsLinkInfo.ComponentStrategy != 'null' && VsLinkInfo.ComponentStrategy!='')
			{
				link_Tag_url = link_Tag_url+"&ComponentStrategy="+ VsLinkInfo.ComponentStrategy;
			}
			if(VsLinkInfo.ComponentTestCell != 'null' && VsLinkInfo.ComponentTestCell!='')
			{
				link_Tag_url = link_Tag_url+"&ComponentTestCell="+ VsLinkInfo.ComponentTestCell;
			}
			if(VsLinkInfo.TargetLOB != 'null' && VsLinkInfo.TargetLOB!='')
			{
				link_Tag_url = link_Tag_url+"&TargetLOB="+ VsLinkInfo.TargetLOB;
			}			
  		}
		return link_Tag_url;
	}
	
 
 //function to be called for tagging modal windows.
 function modalTagging(){
 	//Retrieving pageLabel,pageId,pageType from request.
	var Pg_Tag_url = null;
	var pgLbel = "${requestScope.pageDef_Label}";
	var pageId = "${requestScope.pageid}";
 	var pageType = "${requestScope.pageType}";
		
	//Making a call to the tagging javascript to tag the parameters for the pop-up window.	
	Pg_Tag_url = getPageTaggingParameters(pgLbel,pageId,pageType);
	Pg_Tag_url = "${pageContext.request.contextPath}"+Pg_Tag_url;
	
	//Making ajax call to hit the webserver.
	var xmlHttpReq = new bea.wlp.disc.io.XMLHttpRequest();
    xmlHttpReq.onreadystatechange = function() 
     {
        if (xmlHttpReq.readyState == 4) 
         {
         	if (xmlHttpReq.status == 200) {
          		var data = eval('(' + xmlHttpReq.responseText.toString() + ')');
	        	}
	        	else {
	    	    }
    	   	}
      	};
	    xmlHttpReq.open('GET', Pg_Tag_url, true);
      	xmlHttpReq.send(null);
 }
 
 // TO-DO
 function breakingOutOfFrames() {

      if (top.location != location) {
      top.location.href = document.location.href;
   }
}
 