var	fileseparator = ".";
	
function getFileExtension(filename)
{
	var fileindex = filename.lastIndexOf(fileseparator);
	if (fileindex > 0)
	{
		return filename.substr(fileindex,filename.length).toLowerCase();
	}
	else
	{
		return "";
	}
}
	
function loadFileOnFly(filename)
{
	// load file based on the extension
	switch(getFileExtension(filename))
	{
		case ".css":
		    var	fileref=document.createElement("link");
		  		fileref.setAttribute("rel", "stylesheet");
		  		fileref.setAttribute("type", "text/css");
		  		fileref.setAttribute("href", filename);
		break;
		case ".js":
			var	fileref=document.createElement('script');
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", filename);
		break;
		default:
	}
	if (typeof fileref!="undefined")
		document.getElementsByTagName("head")[0].appendChild(fileref);
}

function parseUrl(data) {
    var e=/((http|ftp|file):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?/;

    if (data.match(e)) {
        return  {
        		url: RegExp['$&'],
                protocol: RegExp.$2,
                host:RegExp.$3,
                path:RegExp.$4,
                file:RegExp.$6,
                hash:RegExp.$7};
    }
    else {
        return  {url:"", protocol:"",host:"",path:"",file:"",hash:""};
    }
}

function xtractFile(data){
    var m = data.match(/(.*)[\/\\]([^\/\\]+\.\w+)$/);
    return {path: m[1], file: m[2]}
}

function modCssUrl(data)
{	
	var datamod = data;
	if (data.length > 0)
	{
			datamod = datamod.replace("url(\"","");
			datamod = datamod.replace("\")","");
	}
	return datamod;
}

function extractUrl(data)
{
	if (data.length > 0)
	{
		return parseUrl(modCssUrl(data));
	}else return  {url:"", protocol:"",host:"",path:"",file:"",hash:""};
}

function extractPath(data)
{
	if (data.length > 0)
	{
		return xtractFile(modCssUrl(data));
	}else return { path:"", file:"" };
}

function reloadBgDir(imagesdir)
{
	if ((typeof jQuery != 'undefined') && (imagesdir != ""))
	{
		$('div').each(function(index) {
//			 $(this).css("background-image","");
		});
	}
}

function addScrollBar(divId) {
	//test for flexiscrollbar
//	$("#" + divId).css("overflow", "auto");
    $("." + divId).each(function(index){
    		var newDiv = divId + index;
    			$(this).attr("id", newDiv);
    			$(this).css("overflow", "auto");
    			fleXenv.fleXcrollMain(newDiv);
    	});
}

function reloadNewsPopup(dhref,outercontainer)
{
	//test for dialogui or impromptu
	if (typeof jQuery != 'undefined')
	{
            $("a[href='" + dhref + "']").each(function() {
            	var tagx = this;
                $(tagx).attr("href",thref);
	            $(tagx).click(function(){
	            	var	newstext = $("div[name='" + this.name +"']").html();
	            	if (newstext=="" || newstext == null)
	            	{
	            		$("div").each(function() {	/* IE Hack not loading news content */
	            			if (this.name == tagx.name){
	            					newstext = $(this).html();
							}
	            		});
		            	newstext = (newstext=="" || newstext == null? nonews:newstext);
	            	}
					var zIndex = $(outercontainer).css("z-index");

					function promptClosed(v,m,f){
						$(outercontainer).css("z-index",zIndex);
					}
					
	            	$(outercontainer).css("z-index","-1");		/* IE Hack ... z-index */
					$.prompt(newstext,{	buttons:{Close:false},callback: promptClosed });
            	});
        	});
     }
}

var thref 		= "#topref"
var nonews 		= "News not Loaded";

if (typeof jQuery != 'undefined') 
{
	//outerclass 
	$(window).resize(function(){
		    $(outerClass).css({
		        position:'absolute',
		        left: 	($(window).width() - $('.outerFrame').outerWidth())/2
		    });
	});
}
else
{	// not loaded
	//loadFileOnFly("css/"+"jscrollpane.css");
	//loadFileOnFly("scripts/"+"jquery.min.js");
	//loadFileOnFly("scripts/"+"jscrollpane.min.js");
}

