﻿// JScript File

//Appending Country query string for SEO    
    var CountryCode;
	
	$(document).ready(function() {
	
	//We can get the country code from the querystring
	if ($.jqURL.get('8109C') != undefined)
	 {
		 CountryCode = $.jqURL.get('8109C');               		 
//		 CountryCode = getParameter('8109C',$.jqURL.url());
	 }
	//We can't get it from the query string so let's try and get it from the referrer
	else
	 {
		if (!document.referrer) {
			return; //No good, we're out of here
		}
		else 
		{
			CountryCode = getParameter('8109C',document.referrer);			
			if (!CountryCode)
			{
				return; //No good, we're out of there
			}		
		}
	 }
		
		$("a[href]").each(function()
								   {
									   
									   //Determine starting character
								   		var startcharacter;
									    if (this.href.indexOf("?") < 0)
										{
											startcharacter = '?';
										}
										else
										{
											startcharacter = '&';
										}												
										if(this.href.toLowerCase().indexOf('javascript:') <0 && this.href.toLowerCase().indexOf('/#') <0 && this.href.toLowerCase().indexOf('8109c') <0 && CountryCode !='null')
										{										  
										  									  
									         this.href = this.href + startcharacter + '8109C=' + CountryCode;	
									         this.href = this.href.replace("/?","?");													        
									      
                                        }
                                       
								   });
	  
							  
	});

	
//Scipt For SEO implementation to get Query string value from a url
 function getParameter( parameterName , url ) {
	  var queryString = url.substring(1).toLowerCase();
	  //alert(queryString);
	  //if (queryString.length==0) {return "null";}
	  var parameters = new Array();
	  parameters = queryString.split('&');
	  for(var i = 0; i < parameters.length; i++) {
		//alert(parameters[i]);
		//alert(parameters[i].indexOf(parameterName));
		if (parameters[i].indexOf(parameterName.toLowerCase())>=0) {
		  //alert(parameters[i]);
		  var parameterValue = new Array();
		  parameterValue = parameters[i].split('=');
		  return parameterValue[1];
		}
	  }
	  return "null";
	}
//For SEO implementation specific to Left navigation
function addcountry()
{
var CountryCode;
	
	$(document).ready(function() {
	
	//We can get the country code from the querystring
	if ($.jqURL.get('8109C') != undefined)
	 {
		 CountryCode = $.jqURL.get('8109C');		 
//		 CountryCode = getParameter('8109C',$.jqURL.url());
	 }
	//We can't get it from the query string so let's try and get it from the referrer
	else
	 {
		if (!document.referrer) {
			return; //No good, we're out of here
		}
		else 
		{
			CountryCode = getParameter('8109C',document.referrer);			
			if (!CountryCode)
			{
				return; //No good, we're out of there
			}		
		}
	 }
		
		$("a[href]").each(function()
								   {
									   
									   //Determine starting character
								   		var startcharacter;
									    if (this.href.indexOf("?") < 0)
										{
											startcharacter = '?';
										}
										else
										{
											startcharacter = '&';
										}												
										if(this.href.toLowerCase().indexOf('javascript:') <0)
										{
									       this.href = this.href + startcharacter + '8109C=' + CountryCode;									
									       this.href = this.href.replace("/?","?");
                                        }
                                       
								   });
	  
							  
	});
}
// JScript File
function fixImages(){
        /*imageCollection=document.body.getElementsByTagName("IMG");
        for(i=0; i<imageCollection.length; i++){
               fixPngTransparency(imageCollection[i]);
        }*/
}

function fixPngTransparency(obj){	
	/*var imgSrc = obj.src;
           var img1 = imgSrc.replace(/%25/gi,"%");
            if(document.body.filters){
                pattern=/.png/gi;
                
                filterFix="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img1+"',sizingMethod='scale');";
                    if(obj.src.search(pattern)!=-1){
                        obj.style.width=obj.offsetWidth+"px";
                        obj.style.height=obj.offsetHeight+"px";
                        obj.style.filter=filterFix;
                        obj.src="/_LAYOUTS/1033/IMAGES/EmersonNetworkPower/blank.gif";
                    }
            }*/
        }




function fixImages1(){
        imageCollection=document.body.getElementsByTagName("IMG");
        for(i=0; i<imageCollection.length; i++){
               fixPngTransparency1(imageCollection[i]);
        }
}

function fixPngTransparency1(obj){
            if(document.body.filters){
                pattern=/.png/gi;
                
                filterFix="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+obj.src+"',sizingMethod='scale');";
                    if(obj.src.search(pattern)!=-1){
                        obj.style.width=obj.offsetWidth+"px";
                        obj.style.height=obj.offsetHeight+"px";
                        obj.style.filter=filterFix;
                        obj.src="/_LAYOUTS/1033/IMAGES/EmersonNetworkPower/blank.gif";
                    }
            }
        }


// Function to show and hide the layers
function showhide(id,val){
if (val==0) document.getElementById(id).style.display = 'none';
    var browser=navigator.appName
    version=parseFloat(navigator.appVersion);
    if (browser == "Microsoft Internet Explorer"){
        if (val==1) document.getElementById(id).style.display = 'block';
    }else if(browser == "Netscape" && (version >=4.7)){
       if (val==1) document.getElementById(id).style.display = 'block';
    }
}


function storyshowhide(id,img)
    {
		var cnt = document.getElementById('count').value;
		var ImageClientId=document.getElementById('ImageClientId').value;
		
			for(var i=0; i<cnt; i++)
			{
				if(id=='div'+i)
				{
					document.getElementById(id).style.display='block';
					if(document.getElementById(ImageClientId)!=null)
					{
						document.getElementById(ImageClientId).src = img;
						document.getElementById(ImageClientId).style.display="";
					}           
				}
				else
				{
					document.getElementById('div'+i).style.display="none";
				}
			}		         
    }
    
    function RemoveSpacing()
       {
        var divArray = document.getElementById("ctl00_cphEnterpriseBody_RichImageField1__ControlWrapper_RichImageField");
        if(divArray!=null)
        {
        var divArrayelmt = divArray.innerHTML;
        var empty = "";
        var arrVal = divArrayelmt.split(">")
        for(i=0;i<arrVal.length-1;i++)
        {
           if(arrVal[i] != "&nbsp;")
           {
               empty = empty + arrVal[i] + ">";
           }
        }
        divArray.innerHTML = empty;
        }
       }
   function ShowContentAreaContact()
        {
            if(document.getElementById('ContentArea_ContactUs')!=null)
            {
                document.getElementById('ContentArea_ContactUs').style.display="block";
            }
        }
function HideDownloadLink()
{


if(document.getElementById("rightLinkDwnlds")!=null)
{

if(document.getElementById("productdownloadtabcount")!=null )
                                                document.getElementById("rightLinkDwnlds").style.display="inline";
                else
                document.getElementById("rightLinkDwnlds").style.display="none";
}
if(document.getElementById("productdownloadcurrenttab")!=null)
{
if(document.getElementById("productdownloadcurrenttab").value!="")
tabNP(document.getElementById("productdownloadcurrenttab").value,document.getElementById("productdownloadtabcount").value);


}
}



//Tooltip for Image WP
var offsetxpoint=20 //Customize x offset of tooltip
var offsetypoint=0 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? 

document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement 

: document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if(!(typeof thetext=="undefined"||thetext==""))
{
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : 

window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : 

window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : 

window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? 

ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : 

window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

function queryString(variable) 
{ 
var query = window.location.search.substring(1); 
var vars = query.split("&"); 
for (var i=0;i<vars.length;i++) 
{ 
var pair = vars[i].split("="); 
if (pair[0] == variable) 
{ 
return pair[1]; 
} 
} 
} 




