function MenuBuilder(scheme,serverName,currentURL){
	var threshold = 1000;//document.body.offsetWidth;
	var usedWidth = 0;
	var groups = $('#nav').find('li.group-menu > a');
	var noofelements = groups.length;
	for(var z=0; noofelements > z; z++)
		usedWidth+= groups[z].offsetWidth;
	var paddingSpace = parseInt((threshold - usedWidth)/(noofelements));
	var totalgeneratedwidth = 0 ; // Make 0 if no L/R border, also above
	$(jQuery.grep(groups, function(n, i){
		return (i < (noofelements-1) );
    })).each(
		function(){
			$(this).width(parseInt($(this).width()+(paddingSpace)));
				totalgeneratedwidth+= $(this).width();
		}
	);
	$(groups[noofelements-1]).width(threshold - totalgeneratedwidth);
	$(groups).each(function(){ //height of main navigation links
		$(this).css("line-height", $("#nav").height()+"px");
	});
	$(function() {
		$('#nav').droppy()
	});
}
function QuickLinkBuilder(){
	var threshold = 1000;
	var usedWidth = 0;
	var groups = $('#quicklink').find('li.quick-link > a');
	var noofelements = groups.length;
	for(var z=0; noofelements > z; z++){
		usedWidth+= groups[z].offsetWidth;
	}
	var paddingSpace = parseInt((threshold - usedWidth - noofelements)/(noofelements));
	var totalgeneratedwidth = noofelements ; // Make 0 if no L/R border, also above
	$(jQuery.grep(groups, function(n, i){
		return (i < (noofelements-1) );
    })).each(
		function(){
			$(this).width(parseInt($(this).width()+(paddingSpace)));
				totalgeneratedwidth+= $(this).width();
		}
	);
	$(groups[noofelements-1]).width(threshold - totalgeneratedwidth);
	$(function() {
		$('#quicklink').droppy();
	});
}
$(document).ready(function(){
		var url_prefix = String(document.location)
                .replace(/^(https?:\/\/[^:\/]+).*$/, "$1")
                .replace(/^((site)?file:\/\/.+\/)[^\/]+$/, "$1")
                .replace(/(\\.)/g, "\\$1");
	  	var host_name = String(document.location)
                .replace(/^/, "X")
                .replace(/^X(https?|ftp):\/\/([^:\/]+).*$/, "$1")
                .replace(/^X.*$/, "")
                .replace(/(\\.)/g, "\\$1");
		/*
		 * Removes baseurl from 3rd Party Links ( Secure )
		 */
		if (host_name == "https") {
			var environment = (url_prefix.indexOf("https://devsecure") != -1)?"dev.":(url_prefix.indexOf("https://qasecure") != -1)?"qa.":(url_prefix.indexOf("https://secure1") != -1)?"www.izdemosite.com/":"www.";
			var obj = String(document.location).split("/");
			obj = String(obj[3]).split(".");
			var secure_host_name = (environment=="www.izdemosite.com/")? String(obj[1]):String(obj[1] + "." + obj[2]);
			$("#nav a").each(function(){
				$(this).attr("href", $(this).attr("href").replace("http://" + environment + secure_host_name + "http://", "http://"));
			});
		}
		/* 
		 * Remove baseurl from Demo 3rd Party Links (Non Secure)
		 */
		if(url_prefix == "http://www.izdemosite.com"){
			var demo_urls = String(document.location).split("/");
			var demo_host_name = demo_urls[3];
			$("#nav a").each(function(){
				$(this).attr("href", $(this).attr("href").replace("http://www.izdemosite.com/" + demo_host_name + "http://", "http://"));
			});
		}
	 
		
	
});
