/*
The SoftAd Group
Copyright (c) 2000-2004 The SoftAd Group, Inc.  All rights reserved
*/
// -------------------------------------------------------------------------------
// File name        : navigator.js
// -------------------------------------------------------------------------------
// Author           : Ken Wimberley
// Created on       : February 10, 2004
// 
// This file contains all client-side scripting functions required by the runtime 
// navigator tree object
// -------------------------------------------------------------------------------
// Last Updated     : Xiaoyun Wang
// Updated by       : February 17, 2004
// -------------------------------------------------------------------------------
// Copyright © 2004 The SoftAd Group, Inc.

function SiteTreeNodes(){
	this.id = new Array();
	this.value = new Array();
	this.addSiteTreeNode= addSiteTreeNode;
	this.getSiteTreeNodeID= getSiteTreeNodeID;
	this.getSiteTreeNodeValue= getSiteTreeNodeValue;
}	

function addSiteTreeNode(id, value){
	this.id[this.id.length] = id;
	this.value[this.value.length] = value;
}	

function getSiteTreeNodeID(value){
	var id;
	for (var i = 0; i < this.value.length; i++){
		if (this.value[i] == value)	{
			id = this.id[i];
			break;
		}
	}	
	return id;
}	

function getSiteTreeNodeValue(id){
	var value;
	for (var i = 0; i < this.id.length; i++){
		if (this.id[i] == id)	{
			value= this.value[i];
			break;
		}
	}	
	return value;
}	

var oSiteTreeNodes = new SiteTreeNodes();	
oSiteTreeNodes.addSiteTreeNode(0,0);	

function checkURLType(sURLString, sVanityURLString) {
	var sURLStr = sURLString.toLowerCase();
	var sVanityURL = sVanityURLString.toLowerCase() + '.';
	var sSubURLStr = '';
	if(sVanityURLString.length != 0){
		sSubURLStr = sURLStr.substring(0,sVanityURL.length) ;
		if(sSubURLStr == sVanityURL ){
			sURLString = sURLString.substring(sVanityURL.length) ;
		}
		sURLString = sVanityURLString+ "."+ sURLString + "/";
	}
	return "http://" +sURLString ;
}


function ClickEvent(key, obj) {
	if(key == 0){ // root node
		var SiteGroupURL =  document.getElementById('SiteGroupHref').value;
		if(SiteGroupURL != ''){
			document.location.href = SiteGroupURL ;
		}
	} else {
		var oNode=oSATree.getChild(key); 
		if(oNode.activate){ //not section node
			var sVanityHostId =  document.getElementById('VanityHostId').value;
			var sPath = sVanityHostId  +  oNode.nodeValue;
			//alert(sPath );
			document.location.href = sPath;
		}
	}
} 
