//note that there is something weird with localhost and this class.

BreadCrumbClass = function(){
	this.init();
}

BreadCrumbClass.prototype.init = function(){
	this.deliminator;
	this.separator;
	this.pageURL;
	this.crumbTrail;
	this.crumbString;
	this.domain = "";
	this.crumbArray = new Array();
}

BreadCrumbClass.prototype.getURL = function(){
	return(document.URL);
}

BreadCrumbClass.prototype.setCrumb = function(deliminator, separator){
	this.deliminator = deliminator;
	this.separator = separator;
	this.pageURL = this.getURL();
	this.crumbTrail = this.formatCrumb(this.pageURL, this.deliminator, this.separator);
	return(this.crumbTrail);
}

BreadCrumbClass.prototype.setModel = function(strings,links){
	var tempStringArray = strings;
	var tempLinkArray = Links;
	var tempSLArray;
	
}

BreadCrumbClass.prototype.formatCrumb = function(URL,deliminator,separator){
	var tempArray; //hold link text
	var tempArrayLink; //hold links
	var tempArrayLinkComb = new Array(); //combined links
	var tempDelim = new RegExp(deliminator, "g"); //create regular expression for search and replace
	var tempSepar = separator;
	var tempString = URL;
		tempString = tempString.toString();
		
				//clean up url
	//var stringLength = tempString.length
	var index = 0
	index = tempString.indexOf("/#&&/",0) //look to see if there is any goofy characters
	if(index > 0){ //if there is then remove everything after
		tempString = tempString.slice(index+4)
	}
	
	//stringLength = tempString.length
	index = 0
	index = tempString.indexOf("/Login",0) //look to see if there is a link to login
	if(index > 0){ //if there is then remove everything after
		tempString = tempString.slice(index+6)
	}
		
		
		if(tempString.substr(0,5) == "https"){
			this.domain = this.domain + tempString.substring(0,8);
			tempString = tempString.slice(8); //"https://"
		}else{
			this.domain = this.domain + tempString.substring(0,7);
			tempString = tempString.slice(7); //"http://"
			//alert(tempString);
		}
		if(tempString.substr(0,10) == "localhost:"){
			this.domain = this.domain + tempString.substring(0,15);
			tempString = tempString.slice(15); //"localhost:port/"
			//alert(this.domain);
			//alert(tempString);
		}else{
			//nothing
		}
		
	
	var tempStringLink = tempString;
	tempString = unescape(tempString); //firefox 3.1 sees the deliminator code as urlencoded. So if I am trying to replace a "-", it sees it as "%20D". All other browsers don't do this, but firefox 3.1 does. So, I use the unescape command to force firefox to decode the string.
		tempString = tempString.replace(tempDelim, tempSepar);
		tempArray = tempString.split("/");
		tempArrayLink = tempStringLink.split("/");
		var myregexp = /^[^?#]+\?([^#]+)/i; //regex to look for false positives where the url parameters look like a directory, Login.aspx?ReturnUrl=%2fSignUp.aspx
		//loup through the link (folder structure) and recreate it to build the tree structure
		for(count2 = 1; count2 < tempArrayLink.length; count2++){
			
			if (myregexp.test(tempArrayLink[count2])) {//conditional statement that uses regex to remove false positives
				// Successful match
				//alert(tempArrayLink[count2]);
				//tempArrayLink.splice(count2,1);
				//tempArray.splice(count2,1);
				//alert(tempArrayLink[count2]);
			} else {
				// Match attempt failed
			}

			if(count2 == 1){
				tempArrayLinkComb[count2] = tempArrayLink[count2];
				//alert(tempArrayLinkComb[count2]);
			}else{
				tempArrayLinkComb[count2] = tempArrayLinkComb[count2 - 1] + "/" + tempArrayLink[count2];
				//alert(tempArrayLinkComb[count2]);
			}
		}
		tempString = ""; //clear for reuse
		for(count = 0; count < tempArray.length-1; count++){
			if(count == 0){
				tempString = "<a href='" + "/" + "'>Home</a>";//don't need to use the first link in the array because it is just the root
			}else{
				//make sure http:// is on the link
				tempString = tempString + (" " + "<a class='arrow' href='" + "/" + tempArrayLinkComb[count] + "'>" + tempArray[count] + "</a>");
			}
			//alert(tempString);
		}
		//alert(tempString);
		//unescape decodes urlencoding
		return(unescape(tempString));
		
}


neccCrumb = new BreadCrumbClass();
//////////////call script//////////////////
/******************************************
<script type="text/JavaScript">document.write(neccCrumb.setCrumb("-"," "));</script>
******************************************/
