var sbcUI = new sbcUI();	
function sbcUI () {
	this.newWindowFocus = newWindowFocus;
	function newWindowFocus (url) {
		var newWindow = window.open(url, 'sbcNew',"status=yes,toolbar=yes,menubar=yes,location=yes,directories=yes,resizable=yes,scrollbars=yes");
		newWindow.focus();
		return false;
	}
}

var services = new services();
function services() {
    this.findPartner = findPartner;
    this.findEvents = findEvents; 
    
	function findPartner(type) {
		var zipInput = document.getElementById('zipInput');
		
		if (zipInput == undefined) {
		    zipInput = PartnerFinderCurrentInput;
	    } else {
	        if (zipInput.value == "")
	            zipInput = PartnerFinderCurrentInput;
	   } 
	        
		var partnerFinder = document.getElementById('partnerFinderBtn');
		
		validation.showStatus(partnerFinder,"Buscando...");
		if (type == undefined) type = "-1";//all partner types
		
		//location = '/smallbusiness/partner/vendorsearch.mspx?c=' + type + '&r=5&pc=' + zipInput.value;
		location = '/spain/empresas/SolutionFinder2/resultados.aspx?advanced=0&configName=Default&SFSite=sbc_es-ES&txtZip=' + zipInput.value;
	}
	
	function findEvents() {
	    var zipInput = document.getElementById('zipInput');
		var localEventsBtn = document.getElementById('localEventsBtn');
		
		validation.showStatus(localEventsBtn,"Buscando...");
		//location = '/smallbusiness/resources/connections/default.aspx?zip=' + zipInput.value + "#mapResults";
		location = '/smallbusiness/resources/connections/events.aspx?p=1&zip=' + zipInput.value;
	}
}

var validation = new validation();
var tipFadeTimeout = new Array();
var tipFadeColors = "#ffff99,#ffffc0,#ffffd9,#ffffe7";
var tipFadeInit = false;
var tipInitX, tipInitY, tipCurX, tipCurY;
var tipObjCur;
var tipObjCurSrcElement;
var tipFadeLast;

function validation () {
    this.showTip = showTip;
    this.tipMouseOut = tipMouseOut; 
    this.tipMouseOn = tipMouseOn;  
    this.mouseMove = mouseMove; 
    this.hideTip = hideTip; 
    this.showStatus = showStatus;  
   
    this.checkZip = checkZip;
    this.checkIsDigit = checkIsDigit;
   
    function checkZip(input, passStatement, evt) {
        var valid = false; 
        var tipText =  "Por favor introduzca los 5 dígitos del C.P.";
        
        var e = (window.event) ? window.event : evt;
        
        if (!input.value.match(/^\d+$/) && input.value != "") {//assumes call from onkeydown event
            validation.showTip(input,tipText);
            valid = false;
        } else {
            if (input.value.length == 5) {
               validation.hideTip(input);
                 if (e) {
                    if (e.type == "click") eval(passStatement);
                    if (e.type == "keydown") if (e.keyCode == 13) eval(passStatement);
               } else {
                    eval(passStatement);
               }
               valid = (passStatement == "") ? true : false;
            } else {
                if (e) {
                    if (e.type == "click") {
                        validation.showTip(input,tipText);
                    }
                    if (e.type == "keydown") {
                        if (e.keyCode == 13) {
                            validation.showTip(input,tipText);
                        }
                    }
               } else { 
                    validation.showTip(input,tipText);
               }
                valid = false;
            }
        } 
       
       return valid;
    }
   
    function checkIsDigit(input,passStatement,tipText) {
        var digitsOnly = /^\d+$/; 
        var checkBool =  (input.value.match(digitsOnly) != null);
       if (checkBool) { 
            validation.hideTip(input);
            eval(passStatement);
       } else {
            validation.showTip(input,tipText);
       } 
        return checkBool; 
    }    
   
    function showStatus(obj, text) {
       validation.showTip(obj, "buscando...");
       if (obj)
       if (obj.style != undefined)
       obj.style.color = "#ccc";
       obj.style.cursor = "wait";
    }     
   
     this.setMouseMoveHandler = setMouseMoveHandler;
     
    function  setMouseMoveHandler() {
        if (browserUtility.getBrowser() == "ie") {
            document.onmousemove = validation.mouseMove;
       } else {
            window.captureEvents(Event.MOUSEMOVE);
	        window.onmousemove = validation.mouseMove;
	   } 
    }    
   
    this.cancelMouseMoveHandler = cancelMouseMoveHandler;
   
  function cancelMouseMoveHandler() {
       
       if (browserUtility.getBrowser() == "ie") {
            document.onmousemove = "void";
       } else {
            window.captureEvents(Event.MOUSEMOVE);
	        window.onmousemove = "void";
	   } 
	     tipInitX = "";
         tipInitY = "";
    }      
   
    function showTip(obj, text) {
        var objChange = (tipObjCurSrcElement = obj) ? false: true;
        tipObjCurSrcElement = obj; 
       
        var tip = document.createElement("span");
        tip.id = obj.id + "_tip"; 
        tip.className = "tip"; 
        
       var close =  '<div title="Hide Tip" class="tip_close" onclick="validation.hideTip(document.getElementById(\'' + obj.id + '\'));"/>'; 
       var closeChild = document.createElement("div");
        closeChild.innerHTML = close;
       
        if (text.style != undefined || text.className != undefined) {//if obj w/ html instead of just text
            
            if (text.style.width) tip.style.width = text.style.width;
            if (text.style.height) tip.style.height = text.style.height;
            
            if (text.style.position) {
                tip.style.position = text.style.position;
               if (text.style.left)  tip.style.left = text.style.left;
               if (text.style.top)  tip.style.top = text.style.top;
            }
            tip.innerHTML += text.innerHTML;
            var firstNode = xmlUtility.getFirstComplexChild(tip);
            firstNode.insertBefore(closeChild,firstNode.childNodes[0]);
            tip.style.display = 'block'; 
       } else {
            tip.innerHTML += close;
            tip.innerHTML += '<div class="tip_text">' + text + '</div>'; 
        } 
       
       
       
      
       var nextSibling = domNav.returnNextSibling(obj);
       if (nextSibling) {
            if (nextSibling.id != tip.id) {
                    obj.parentNode.insertBefore(tip,nextSibling);
            } else {
                    tip = document.getElementById(obj.id + "_tip");
                    tip.style.display = 'block'; 
            } 
      } else {
         obj.parentNode.appendChild(tip);
     } 
     
     tipObjCur = tip; 
     //setMouseMoveHandler();//sets global tipInitX, tipInitY, etc vars
   }    
  
    function mouseMove(e) {
        var x = (browserUtility.getBrowser() == "ie") ? (event.x - 40) : e.pageX;
        var y = (browserUtility.getBrowser() == "ie") ? (event.y + document.body.scrollTop): e.pageY; 
       if (tipInitX == undefined) {
            tipInitX = x;
            tipInitY = y;
       } else {
            tipCurX = x;
            tipCurY = y;
            
            
            var tipObjX =  tipObjCur.style.width;
            tipObjX = parseInt(tipObjX.replace("px",""));
            
            var tipObjCurSrcElementX  = tipObjCurSrcElement.style.width;
            tipObjCurSrcElementX = parseInt(tipObjCurSrcElementX.replace("px",""));
            //tipObjX += tipObjCurSrcElementX;
            
           var tipObjY =  tipObjCur.style.height;
            tipObjY = parseInt(tipObjY.replace("px",""));
            
            
            var outOfBoundsX = (tipCurX > (tipInitX + tipObjX + 5) || tipCurX < (tipInitX - 5)) ? true : false;
            var outOfBoundsY = (tipCurY > (tipInitY + tipObjY + 5) || tipCurY < (tipInitY - 5)) ? true : false;
            
            //window.status = " current: " + x + " bounds:  " + (tipInitX - 5) + " to " + (tipInitX + tipObjX + 5);
            
            if ((outOfBoundsX || outOfBoundsY) && tipFadeLast != "out") tipMouseOut(tipObjCur.id);
            if (!outOfBoundsX && !outOfBoundsY && tipFadeLast != "in") tipMouseOn(tipObjCur.id);
            
       }
     }   
  
    function tipMouseOut (id) {
        tipFadeLast = "out"; 
        clearFade();
        tipFade(id,true,250,250);
      }    
     
      function tipMouseOn (id) {
       tipFadeLast = "in"; 
       clearFade();
       tipFade(id,false,10,50);
     }   
     
     function tipFade(id,boolForward, fadeWait, fadeInterval) {
         var colorArray = (boolForward) ? tipFadeColors.split(",") : tipFadeColors.split(",").reverse();   
         var display = (boolForward) ? "none": "block";
         var setMouseHandler = (boolForward) ? "validation.cancelMouseMoveHandler()" : "validation.setMouseMoveHandler()"; 
         
          for (i=0;i<colorArray.length;i++) {
               tipFadeTimeout[i] = window.setTimeout("document.getElementById('" + id + "').style.backgroundColor = '" + colorArray[i] + "';",fadeWait);
               fadeWait += fadeInterval; 
          }
          tipFadeTimeout[i+1] = window.setTimeout("document.getElementById('" + id + "').style.display = '" + display + "';eval(" + setMouseHandler + ");",fadeWait +fadeInterval);
     }
     
     function clearFade() {
        for (i=0;i<tipFadeTimeout.length;i++) {
            if (tipFadeTimeout[i] != "") window.clearTimeout(tipFadeTimeout[i]);
        } 
     }
   
    function hideTip(obj) {
        var tip = document.getElementById(obj.id + "_tip"); 
        if (tip != undefined) tip.style.display = 'none'; 
    }      
   
         
}

var browserUtility = new browserUtility();

function browserUtility() {
	this.getBrowser = getBrowser;
	this.addBookmark = addBookmark;
	this.setOpacity = setOpacity;
	this.removeIEOpacity = removeIEOpacity;
	
	function setOpacity (obj, imgSrc) {
	    if (getBrowser() == "ie") {
	        obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ imgSrc+"', sizingMethod='scale')";
	   } else {
	        obj.style.backgroundImage = "url('" + imgSrc + "')";
	   } 
	}
	
	function removeIEOpacity (obj) {
	    obj.style.filter = "";
	}
   
	
	function getBrowser () {
		var agent = navigator.userAgent.toLowerCase();
        var browser = (agent.indexOf('msie') >= 0) ? "ie" : "moz";
		return browser;
	}
	
	function addBookmark(obj, url, title) {
	   if (this.getBrowser() == "ie") {
	        window.external.AddFavorite(url,title);
	   } else {
	        window.sidebar.addPanel(title, url,"");
	   }
	}
}

var xmlUtility = new xmlUtility();
function xmlUtility () {
	var currentBrowser = browserUtility.getBrowser();
	var intFirstChildIndex = getChildIncrement();
	var xmlRequestObj; 
	
	this.getDocObj = getDocObj;
	this.getRequestObj = getRequestObj;
	this.getBrowser = browserUtility.getBrowser;
	this.getChildIncrement = getChildIncrement;
	this.getFirstComplexChild  = getFirstComplexChild;
	this.load = load;
	this.loadWebService = loadWebService;
	
	function getNode(parentNode,nodeName) {
        var node; 
        for (i=0;i<parentNode.childNodes.length;i++) {
            if (parentNode.childNodes[i].nodeName == nodeName) {node = parentNode.childNodes[i];break;};
       } 
       return node;
    }    
	
	function getFirstComplexChild(node) {
	    var child;
	    for (i=0;i<node.childNodes.length;i++) {
            if (node.childNodes[i].nodeType == 1) {
                child = node.childNodes[i];
                break;
            }
        }
       return child;  
    }
	
	function getDocObj () {
		var xmlDoc;
		if (currentBrowser == "ie") {
			xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
			intFirstChildIndex = 0;
		} else {
			xmlDoc = document.implementation.createDocument("", "xmlDoc", null);
			intFirstChildIndex = 1;
		}
		return xmlDoc;
	}
	
	function getChildIncrement () {
		var intChildIncrement;
		if (currentBrowser == "ie") {
			intChildIncrement = 0;
		} else {
			intChildIncrement = 1;
		}
		return intChildIncrement;
	}
	
	
	function load (URI) {
		var xmlDoc = this.getDocObj();
		xmlDoc.async=false;
		xmlDoc.load(URI);
		return xmlDoc;
	}
	
	this.getXml = getXml;
	
	function getXml(url, processStatement) {
	    var xmlData;
		xmlRequestObj = xmlUtility.getRequestObj();
		xmlRequestObj.onreadystatechange = processReqChange; 
		xmlRequestObj.open("GET", url, true);
	    xmlRequestObj.setRequestHeader("Content-Type", "text/xml");
		xmlRequestObj.send(null);
		
		function processReqChange () {
			if (xmlRequestObj.readyState == 4) {//XML fully loaded state
				xmlData = xmlRequestObj.responseXML;
				eval(processStatement);
			}
		}
	}
	
	this.getXHtml = getXHtml;
	
	function getXHtml(url, processStatement)
	{
	      var xmlData;
		xmlRequestObj = xmlUtility.getRequestObj();
		xmlRequestObj.onreadystatechange = processReqChange; 
		xmlRequestObj.open("GET", url, true);
	    xmlRequestObj.setRequestHeader("Content-Type", "text/html");
		xmlRequestObj.send(null);
		
		function processReqChange () {
			if (xmlRequestObj.readyState == 4) {//XML fully loaded state
				xmlData = xmlRequestObj.responseText;
				eval(processStatement);
			}
		}
	}
	
	this.getHtml = getHtml;
	function getHtml(documentElement) {
	    var baseNode = (documentElement.childNodes[0].nodeName != "xml") ? (documentElement.childNodes[0]) : (documentElement.childNodes[1]);
	    var html = getNodeAsTag(baseNode);
	    return html; 
    }    
  
  this.getNodeAsTag =  getNodeAsTag;
  
  function getNodeAsTag(node) {
    var tag = "";
    if (node.nodeName != undefined) {
        tag = "<" + node.nodeName; 
        tag +=  getAttributes(node) + ">";
       for (i=0;i<node.childNodes.length;i++) {
            tag += (node.childNodes[i].nodeType == 1) ? getNodeAsTag(node.childNodes[i]) : node.childNodes[i].nodeValue;
       } 
        tag += " </" + node.nodeName + ">";
    }  
   return tag;  
 }
    
   this.getAttributes = getAttributes;
  function getAttributes(node) {
    var returnAttributes = "";
    if (node.attributes != undefined) {
        for (i=0;i<node.attributes.length;i++) {
            if (node.attributes[i].nodeName != undefined) { 
                returnAttributes += " " + node.attributes[i].nodeName + '="' + node.attributes[i].nodeValue + '"';
            }
        } 
    }  
   return  returnAttributes;
  }
   
 
	function loadWebService (id, qVars, processStatement) {
		var xmlData;
		xmlRequestObj = xmlUtility.getRequestObj();
		xmlRequestObj.onreadystatechange = processReqChange; 
		xmlRequestObj.open("GET", '/smallbusiness/shared/webServiceProxy.aspx?id=' + id + qVars, true);
	    xmlRequestObj.setRequestHeader("Content-Type", "text/xml");
		xmlRequestObj.send(null);
		
		function processReqChange () {
			if (xmlRequestObj.readyState == 4) {//XML fully loaded state
				xmlData = xmlRequestObj.responseXML;
				eval(processStatement);
			}
		}
	}
	
	function getRequestObj () {
			var requestObj;
			if (window.XMLHttpRequest) {
				requestObj = new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				requestObj = new ActiveXObject("Microsoft.XMLHTTP");
			}
			return requestObj;
	}
}

var domNav = new domNav();
function domNav() {
	this.toggleChildrenDisplay = toggleChildrenDisplay;
	this.toggleNextObjDisplay = toggleNextObjDisplay;
	this.returnNextSibling = returnNextSibling;
	this.hideChildren = hideChildren;
	this.showChildren = showChildren;
	this.show = show;
	this.showGroupItem = showGroupItem;
	this.showOneChild = showOneChild;
	
	function showOneChild(parentID, childIndex) {
	    var parent = document.getElementById(parentID);
	    var child;
	   //alert(childIndex);
	    for (i=0;i<parent.childNodes.length;i++) {
	        child = parent.childNodes[i];
	        
	        if (child.nodeType == 1) {
	            if (child.style != undefined) child.style.display = (i==childIndex) ? "block" : "none";
	        }  
	   } 
	}
	
	function showGroupItem(groupIdPrefix, itemIdSuffix) {
	    var divs = document.getElementsByTagName("div"); 
	    var iDiv; 
	   
	    for (i=0;i<divs.length;i++) {
	        if (divs[i].id != undefined) {
	            if (divs[i].id == groupIdPrefix + itemIdSuffix) {
	             divs[i].style.display = 'block';//show selected
	           } else {
	                if (divs[i].id.indexOf(groupIdPrefix) >= 0) divs[i].style.display = 'none';//hide all others
	           } 
	        } 
	    }  
	    
	}
	
	function show(obj) {
	    if (obj) {
	        if (obj.style) {
	            obj.style.display = "block";
	        }
	   } 
	}
	
	function returnNextSibling (curObj) {
		var bodyChild;
		var parent = (curObj.parentNode.childNodes != undefined) ? curObj.parentNode : curObj.parentNode.parentNode;
		for (i=0;i<parent.childNodes.length;i++) {
			bodyChild = parent.childNodes.item(i);
			if (bodyChild == curObj) {
				var nextObj = parent.childNodes[i+1];
				return nextObj;
			}
		}
	}
	
	function hideChildren(parentObj) {
		if (parentObj) {
			if (parentObj.childNodes) {
				var childObj;
				for (i=0;i<parentObj.childNodes.length;i++) {
					childObj = parentObj.childNodes.item(i);
					if (childObj.style) {
							childObj.style.display = 'none';
					}
				}
			}
		}
	}
	
    function showChildren(parentObj) {
		if (parentObj) {
			if (parentObj.childNodes) {
				var childObj;
				for (i=0;i<parentObj.childNodes.length;i++) {
					childObj = parentObj.childNodes.item(i);
					if (childObj.style) {
							childObj.style.display = 'block';
					}
				}
			}
		}
	}
	
	function toggleChildrenDisplay(parentObj) {
		if (parentObj) {
			if (parentObj.childNodes) {
				var childObj;
				for (i=0;i<parentObj.childNodes.length;i++) {
					childObj = parentObj.childNodes.item(i);
					if (childObj.style) {
						if (childObj.style.display == "none") {
							childObj.style.display = 'block';
						} else {
							childObj.style.display = 'none';
						}
					}
				}
			}
		}
	}
	
	function toggleNextObjDisplay(curObj) {
		var bodyChild;
		
		for (i=0;i<curObj.parentNode.childNodes.length;i++) {
			bodyChild = curObj.parentNode.childNodes.item(i);
			if (bodyChild == curObj) {
				var nextObj = curObj.parentNode.childNodes.item(i+1);
				if (nextObj.style) {
					if (nextObj.style.display == "none") {
						nextObj.style.display = 'block';
					} else {
						nextObj.style.display = 'none';
					}
				}
			}
		}
	}
}

//Utility
var IsIE = (navigator.userAgent.toString().toLowerCase().indexOf("msie") >=0) ? true : false;

var EventUtility = new EventUtility();
function EventUtility()
{
    this.AddEventHandler = AddEventHandler;
    this.RemoveEventHandler = RemoveEventHandler;
    this.AddGroupEventHandler = AddGroupEventHandler;
    this.GetEventSourceObject = GetEventSourceObject;
    
     function AddEventHandler(obj,eventName, eventHandler)
  {
  
    if (IsIE) {
        obj.attachEvent(eventName,eventHandler);
    } else {
        obj.addEventListener(eventName.replace("on",""),eventHandler,false);
      } 
  
   }
   
  function RemoveEventHandler(obj,eventName, eventHandler)
  {
    if (IsIE) {
        obj.detachEvent(eventName,eventHandler);
    } else {
        obj.removeEventListener(eventName.replace("on",""),eventHandler,false);
      } 
   } 
   
   function AddGroupEventHandler(memberArray,eventName,eventHandler)
   {
        var member;
        for (var i=0;i<memberArray.length;i++)
        {
            member = memberArray[i];
            AddEventHandler(member,eventName,eventHandler);
        }
   }
  
function GetEventSourceObject(e)
{
  var obj;
  if (IsIE) {
    obj = window.event.srcElement;
  } else {
      obj = e.target;
      while(obj.nodeType == 3)
	    obj = obj.parentNode;
  }
   return obj;
} 

}  

var ClassUtility = new ClassUtility();
function ClassUtility()
{
    this.GetMembers = GetMembers;
    this.GetChildMember = GetChildMember;
    this.AddClass = AddClass;
    
    this.RemoveClass = RemoveClass;
    this.RemoveClassFromGroup = RemoveClassFromGroup;
    
    function AddClass(obj, className)
    {
      /*
        if (obj.className != undefined)
        {
            var currentClasses = obj.className.toString().split(" ");
            currentClasses.push(className);
        }
        */
        //obj.className = currentClasses.toString().replace(","," ");
        
        obj.className = obj.className.toString() + " " + className;
        //alert(obj.className);
    }
    
    function RemoveClass(obj, className)
    {
       obj.className = obj.className.toString().replace(className,"");
    }
    
     function RemoveClassFromGroup(memberArray, className)
    {
       for (var i=0;i<memberArray.length;i++)
       {
            RemoveClass(memberArray[i],className);
       }
    }
    
    function GetMembers(className, tagName)
    {
        var memberArray = new Array();
        var elements = document.getElementsByTagName(tagName);
        var element;
        
        for (var i=0;i<elements.length;i++)
        {
           element = elements[i];
           
           if (element.className != undefined)
           {
                if (element.className.toString().indexOf(className) >= 0)
                    memberArray.push(element);
           } 
        }
        
        
        return memberArray;
    }
   
    this.GetDescendantMembers = GetDescendantMembers; 
      function GetDescendantMembers(className, tagName, parentObj)
    {
        var memberArray = new Array();
        var elements = parentObj.getElementsByTagName(tagName);
        var element;
        
        for (var i=0;i<elements.length;i++)
        {
           element = elements[i];
           
           if (element.className != undefined)
           {
                if (element.className.toString().indexOf(className) >= 0)
                    memberArray.push(element);
           } 
        }
        
        
        return memberArray;
    }  
    
    function GetChildMember(parentObj, className)
    {
        var member;
        var elements = parentObj.childNodes;
        var element;
        
        for (var i=0;i<elements.length;i++)
        {
           element = elements[i];
           
           if (element.className != undefined)
           {
                if (element.className.toString().indexOf(className) >= 0)
                    member = element;
           } 
        }
        
        
        return member;
    }
    
    function GetGroupChildMembers(parentObjArray,className)
    {
        
    
    }
    
    function GetChildMembers(parentObj, className)
    {
        var memberArray = new Array();
        var elements = parentObj.childNodes;
        var element;
        
        for (var i=0;i<elements.length;i++)
        {
           element = elements[i];
           
           if (element.className != undefined)
           {
                if (element.className.toString().indexOf(className) >= 0)
                    memberArray.push(element);
           } 
        }
        
        
        return memberArray;
    }

}


//End Utility

var fx = new fx();
function fx() {
    this.animate = animate; 
    function animate(obj, type, startPx, endPx, delay, speed, hideAndResetOnLast) {
       
       if (obj != undefined && obj.style != undefined) {
            var prop, value, op;
            switch (type) {
                case "up":
                    prop = "style.top";
                    op = "-";
                break; 
                case "down":
                    prop = "style.top";
                    op = "+";
                break;  
               case "left":
                    prop = "style.left";
                    op = "-";
                break;  
                case "right":
                    prop = "style.left";
                    op = "+";
                break;   
                case "background-up":
                    prop = "style.backgroundPositionY";
                    op = "-";
                break;  
                case "background-down":
                    prop = "style.backgroundPositionY";
                    op = "+";
                break;     
                 case "background-left":
                    prop = "style.backgroundPositionX";
                    op = "-";
                break;  
                case "background-right":
                    prop = "style.backgroundPositionX";
                    op = "+";
                break;    
                case "expandWidth":
                    prop = "style.width";
                    op = "+";
                    //changeStyle(obj.id, prop, '0px');//set height to 0 before transformation
                break;   
                case "shrinkWidth":
                    prop = "style.width";
                    op = "-";
                break;     
                case "expand":
                    prop = "style.height";
                    op = "+";
                    changeStyle(obj.id, prop, '0px');//set height to 0 before transformation
                break;   
                case "shrink":
                    prop = "style.height";
                    op = "-";
                break;    
                case "clip-right":
                  prop = "style.clip";
                    op = "-";
                break;  
                case "clip-left-hide":  
                    prop = "style.clip";
                    op = "+";
                break; 
                case "clip-left":
                  prop = "style.clip";
                    op = "+";
                break;  
                case "clip-right-hide":   
                    prop = "style.clip";
                    op = "+";
                break;
                case "fade-out":   
                    prop = "style.filter";
                    op = "-";
                break;   
                case "fade-in":   
                    prop = "style.filter";
                    op = "+";
                break;                 
            }
            //alert(obj.id);
            var inc = 0;
            var iter = (startPx > endPx) ? parseInt(((startPx - endPx)/5)) : parseInt(((endPx - startPx)/5));
            var id = obj.id;
            
            if(id.length == 0)
                return;
            
            
            var calc, cmd;
            for (var i=0;i<iter;i++) {
                if (op == "+") inc += 5;
                calc = eval("parseInt(startPx" + op +  inc + ")");
                
               if (type == "clip-right-hide") {
                    cmd = "fx.changeStyle('" + id + "','style.clip','rect(0px " + parseInt(startPx - inc) + "px 240px 0px)');";
               } else if (type == "clip-right") {
                    cmd = "fx.changeStyle('" + id + "','style.clip','rect(0px " + parseInt(startPx + inc) + "px 240px 0px)');";
               } else if (type == "clip-left") {
                    cmd = "fx.changeStyle('" + id + "','style.clip','rect(0px 535px 240px " + parseInt(endPx - inc) + "px)');";
               } else if (type == "clip-left-hide") {
                    cmd = "fx.changeStyle('" + id + "','style.clip','rect(0px 535px 240px " + parseInt(startPx + inc) + "px)');";
               } else if (type == "fade-out") {
                        cmd = "fx.changeStyle('" + id + "','style.filter','alpha(opacity=" + parseInt(startPx - inc) + ")');";
                        //alert(cmd);
               } else if (type == "fade-in") {
                    cmd = "fx.changeStyle('" + id + "','style.filter','alpha(opacity=" + parseInt(startPx + inc) + ")');";
                } else if (type == "background-up" && !IsIE) {
                    cmd = "fx.changeStyle('" + id + "','style.backgroundPosition','0px " + parseInt(startPx - inc) + "px');";     
                    //alert(cmd);
               } else {
                    cmd = "fx.changeStyle('" + id + "','" + prop + "','" + calc + "px');";
               }
                   
               if (i == 0)  cmd += "document.getElementById('" + id + "').style.display = 'block';"; 
               if (i == (iter-1) && hideAndResetOnLast)  {
                    cmd += "document.getElementById('" + id + "').style.display = 'none';";
                    switch (type) {
                        case "shrink":
                            cmd += "document.getElementById('" + id + "').style.height = '" + startPx + "px';";
                        break;  
                       case "down":
                            cmd += "document.getElementById('" + id + "').style.top = '" + parseInt(startPx+5) + "px';";
                        break;  
                    }
               }
               
                window.setTimeout(cmd,parseInt(delay + (inc*speed)));
                if (op == "-") inc += 5;
            }
            
       }
    }  
   
    this.changeStyle = changeStyle;   
    function changeStyle(id, prop, value) {
        
    
        if(id.length == 0)
            return;
        eval("if (document.getElementById('" + id + "') != null) {document.getElementById('" + id + "')." + prop + " = " + "'" + value + "';}");
    }    

}


var GeoInfo = new GeoInfo();
//EventUtility.AddEventHandler(window,"onload",GeoInfo.init);
function GeoInfo() 
{
   var _zip = null; 
    this.GetZip = function(){return _zip};
   
    
    var GeoInfoServiceUrl = "http://wwwppe/smallbusiness/GeoLocation_Zipcode/default.aspx"; 
    this.init = init;
    this.parseZip = parseZip; 
   
    function init()
    {
        if (GeoInfo.GetZip() == null)
        {
            xmlUtility.getXml(GeoInfoServiceUrl,"GeoInfo.parseZip(xmlData);");
        }
    }     
   
    function parseZip(xmlData)
    {
       if (xmlData.documentElement)
       {
            //sucessfull GeoInfo XML returned, otherwise GeoInfo was not determinable and an ErrorsXml node is the root
            if (xmlData.documentElement.nodeName == "GeoInfoXml")
            {
                var PostalCodeNode;
                
                for (var i=0;i<xmlData.documentElement.childNodes.length;i++)
               {
                    if (xmlData.documentElement.childNodes[i].nodeName == "PostalCode")
                    {
                       PostalCodeNodeValue =  xmlData.documentElement.childNodes[i].childNodes[0].nodeValue;
                        
                       //validation of all 5 digit value, i.e. actual zip 
                        if (PostalCodeNodeValue.match(/^\d+$/)  && PostalCodeNodeValue.length == 5)
                        {
                            _zip = PostalCodeNodeValue;//assign to private member, which is then exposed via public GeoInfo.Zip
                        }    
                    }
               } 
            }
            
       } 
        
    }     
}
