function embed(tagvalue)
{
	document.write(tagvalue);
}

// Creates the standard http call for Ajax functions
function getHTTPObject() 
{
	var xmlhttp;
	
	/*@cc_on
	
		@if (@_jscript_version >= 5)
		
		try {
		
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		
		} catch (e) {
		
		try {
		
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
		} catch (E) {
		
		xmlhttp = false;
		
		}
		
		}
		
		@else
		
		xmlhttp = false;
	
	@end @*/
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
	{
		try 
		{
			xmlhttp = new XMLHttpRequest();
		} 
		catch (e) 
		{
			xmlhttp = false;
		}
	}
	
	return xmlhttp;
}

var http = getHTTPObject(); // We create the HTTP Object

// capture the mouse location
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;

function getMouseXY(e) 
{
	if (IE) 
	{ // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else 
	{  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	return true;
}

function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}

//the two functions below let you find the x,y coordinates of any html element, you just 
//need to pass in the object.
function findPosX(obj)
{
  var curleft = 0;
  if(obj.offsetParent)
      while(1) 
      {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}

function findPosY(obj)
{
  var curtop = 0;
  if(obj.offsetParent)
      while(1)
      {
        curtop += obj.offsetTop;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}


function ReplaceNumbers(sw_root)
{
	// check if span exists on the page
	var SpansTest = getElementsByClassName("callus", "span")
	if (SpansTest.length==0)
	return false;
 
	// get the session id from the cookie
	SessionCookie = ReadCookie("SWSESSIONID");
	var url = "/"+sw_root + "/swchannel/GetVSNumbers.asp?SWSESSIONID=" +SessionCookie +"&ms=" + new Date().getTime();						
	
    var xmlhttp=false; //declare the httpxml and create object with browser sensitivity;	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	
	xmlhttp.open("GET", url, true);
		
	 xmlhttp.onreadystatechange  = function()
			{ 
			     if(xmlhttp.readyState  == 4)
			     {
			          if(xmlhttp.status  == 200) 
			             changeSpansNumbers(xmlhttp.responseText);
			     }
			}; 

	//alert(url);
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
    	  xmlhttp.send(''); // Firefox
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
    	  xmlhttp.send(null); // IE (6 and 7)
	 }
	}
	
}

function changeSpansNumbers(NumberDisplay) 
{
	
	if (NumberDisplay.length>0)
	{
		var Spans = getElementsByClassName("callus", "span")
		for(var i = 0; i < Spans.length; i++) 
		{
		   
		      Spans[i].innerHTML = NumberDisplay;
		}
	}
}

   
    
/*
	Developed by Robert Nyman, http://www.robertnyman.com
	Code/licensing: http://code.google.com/p/getelementsbyclassname/
*/	
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
}function extractCookieValue(val) {
  if ((endOfCookie = document.cookie.indexOf(";", val)) == -1) {
     endOfCookie = document.cookie.length;
  }
  return unescape(document.cookie.substring(val,endOfCookie));
}
function ReadCookie(cookiename) {
  var numOfCookies = document.cookie.length;
  var nameOfCookie = cookiename + "=";
  var cookieLen = nameOfCookie.length;
  
  var x = 0;
  while (x <= numOfCookies) {
        var y = (x + cookieLen);                
        if (document.cookie.substring(x, y) == nameOfCookie)
           return (extractCookieValue(y));
           x = document.cookie.indexOf(" ", x) + 1;
           if (x == 0){
              break;
           }
  }
  return (null);
}