if(typeof(xFunctions)=="undefined") xFunctions={};

	xFunctions.el=function(id) 
	{
		var newobj=(document.all) ? document.all[id] : document.getElementById(id);
		return(newobj);
	}
	el=function(id) { return(xFunctions.el(id)); }

    xFunctions.getFlashObject = function(movieName) 
    {
	    if (window.document[movieName]) 
	    {
		    return window.document[movieName];
	    }
	    if (navigator.appName.indexOf("Microsoft Internet")==-1)
	    {
		    if (document.embeds && document.embeds[movieName])
		    return document.embeds[movieName]; 
	    }
	    else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	    {
		    return document.getElementById(movieName);
	    }
    }

    xFunctions.setCookie = function( name, value, expires, path, domain, secure ) 
    {
        if(typeof(expires)=="undefined") expires="";
        if(typeof(path)=="undefined") path="/";
        if(typeof(domain)=="undefined") domain="";
        if(typeof(secure)=="undefined") secure="";
        // set time, it's in milliseconds
        var today = new Date();
        today.setTime( today.getTime() );

        /*
        if the expires variable is set, make the correct 
        expires time, the current script below will set 
        it for x number of days, to make it for hours, 
        delete * 24, for minutes, delete * 60 * 24
        */
        if ( expires )
        {
        expires = expires * 1000 * 60 * 60 * 24;
        }
        var expires_date = new Date( today.getTime() + (expires) );

        document.cookie = name + "=" +escape( value ) +
        ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
        ( ( path ) ? ";path=" + path : "" ) + 
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ( ( secure ) ? ";secure" : "" );
    }
	
    xFunctions.getCookie = function(name)
    {        
        var start = document.cookie.indexOf( name + "=" );
        var len = start + name.length + 1;
        if ( ( !start ) &&
        ( name != document.cookie.substring( 0, name.length ) ) )
        {
        return null;
        }
        if ( start == -1 ) return null;
        var end = document.cookie.indexOf( ";", len );
        if ( end == -1 ) end = document.cookie.length;
        return unescape( document.cookie.substring( len, end ) );
    }
    	

	xFunctions.fixEmptyNodes = function() 
	{
		var element = document.getElementsByTagName('*');
		for(var j=0;j<element.length;j++){
			for (var i=0; i< element[j].childNodes.length; i++) 
			{
				var node = element[j].childNodes[i];
				if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 
				element[j].remove(node);
			}
		}
	}
	
	xFunctions.getPageUrl = function(trgt,removeAnchor) 
	{	    
	    if ( typeof(trgt)=="undefined" ) trgt="document";
	    if ( typeof(removeAnchor)=="undefined" ) removeAnchor=false;
	    var post=eval(trgt+".location.search").toString();
	    if ( removeAnchor ) 
	    {
	        var poundindex=post.indexOf("#");
	        if ( poundindex != -1 ) post = post.substring(0,poundindex);
	    }
	    return (post);
	}
	
	xFunctions.trimright = function(val,rightval) 
	{
		var x = val.substring(val.length - rightval.length,val.length);
		if ( x == rightval ) 
		{
			return val.substring(0,val.length - rightval.length);
		} else {
			return val;
		}
	}	

    xFunctions.capitalize = function(instring){
		var rv = "";
		var iTemp = instring.length;
		if(iTemp==0){
			return"";
		}
		var UcaseNext = false;
		rv += instring.charAt(0).toUpperCase();
		for(var iCounter=1;iCounter < iTemp;iCounter++){
			rv+= (UcaseNext) ? instring.charAt(iCounter).toUpperCase() : instring.charAt(iCounter).toLowerCase();;
			//}
			//else{
			//	rv += instring.charAt(iCounter).toLowerCase();
			//}
			var iChar = instring.charCodeAt(iCounter);
			UcaseNext= (iChar == 32 || iChar == 45 || iChar == 47 ) ? true : false;
//				UcaseNext = true;
//			}
//			else{
//				UcaseNext = false
//			}
		}
		return rv;
	}

xFunctions.adjustvalidators = function() {
    if (typeof(Page_Validators)!="undefined") {
        for (i=0; i<Page_Validators.length; i++) {
            var obj=Page_Validators[i];
            obj.errormessage=obj.errormessage.replace("<img src=\'","<img src=\'"+root);
            obj.innerHTML=obj.errormessage;                
            obj.errormessage=obj.errormessage.replace("<img src=\"","<img src=\""+root);
            obj.innerHTML=obj.errormessage;
        }
    }
}

	
xFunctions.required = function() {
	document.write("<font class='asterisk'>*</font>&nbsp;");
}	


xFunctions.noImage = function(imagesize) 
{
    if (typeof(imagesize)=="undefined") imagesize="search";
    shtml_small="<table width=75 cellpadding=0 cellspacing=0><tr><td><div class=listing_noimage_small>Image Not Available<br /><div></td></tr></table>";
    shtml_other="<table width=300 cellpadding=0 cellspacing=0><tr><td><div class=listing_noimage>Image Not Available<br /><div></td></tr></table>";
    return ( imagesize.toString().toLowerCase() == "small" ) ? shtml_small : shtml_other;    
}

xFunctions.noNewListingImage = function(imagesize) {
    if (typeof(imagesize)=="undefined") imagesize="search";
    shtml_small="<table width=75 cellpadding=0 cellspacing=0><tr><td><div class=listing_newlistingimage_small>New Listing<br />Images Coming Soon!</div></td></tr></table>";
    shtml_other="<table width=300 cellpadding=0 cellspacing=0><tr><td><div class=listing_newlistingimage>New Listing<br />Images Coming Soon!</div></td></tr></table>";
    return ( imagesize.toString().toLowerCase() == "small" ) ? shtml_small : shtml_other;    
}


	
	
/* Dynamic Remote Procedure Call */
xFunctions.rpc=function(IFrameObj,URL,IFrameId,iFrameProperties) {
  if (!document.createElement) {return true};
  var IFrameDoc;
 // var URL = 'server.html';
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // addToCartRPC() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id',IFrameId);      
		  tempIFrame.style.border='0px';
		  tempIFrame.style.width='0px';
	      tempIFrame.style.height='0px';
	  if ( typeof(IFrameCssClass) != "undefined" ) {
		  tempIFrame.style.className=IFrameCssClass;
      }
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames[IFrameId];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="'+IFrameId+'" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';      
      iframeHTML+='" ';
      if ( typeof(IFrameCssClass) != "undefined" ) {
		  iframeHTML+=' class="'+IFrameCssClass+'" ';
      } 
      iframeHTML+='><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById(IFrameId);
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('rpc(IFrameObj,URL,IFrameId)',10);
    return false;
  }
  
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
	IFrameDoc.location.replace(URL);
	return false;
}
/* END Remote Procedure Call */
