///////////////////////////////////////////
// Script loading - dont modify this part. 
//                  It has functions that
//                  allow the caller to 
//                  load Webphone code into
//                  a webpage
///////////////////////////////////////////////
function addServerScript(doc, scriptname){
	var config = new Object();
	setCustomSoftphoneConfig(config);
	
	addScript(doc, scriptname, config.sphPath);
}

function addScript(doc, scriptname, serverPath){
	doc.write( '<scr'+'ipt language="javascript" type="text/javascript" src="'+serverPath+'/'+scriptname+'"></scr'+'ipt>');
}

function addServerStyleSheet(doc, stylesheetname){
	var config = new Object();
	setCustomSoftphoneConfig(config);
	
	addStyleSheet(doc, stylesheetname, config.sphPath+"/defaultstyles");
}

function addWebphonCustomStyleTag(doc){
	doc.write("<sty"+"le type='text/css' id='webphoneCustomStyles'></st"+"yle>");
}

function addStyleSheet(doc, stylesheetname, serverPath){
	doc.write( '<li'+'nk rel="stylesheet" type="text/css" media="screen" href="'+serverPath+'/'+stylesheetname+'"></li'+'nk>');
}


function detectAndChangeLanguage(fname, ext){
	try{
		if(fname == null)fname = 'index-';
		if(ext == null)ext = 'html';
						
		varPath = '';
						
		if (navigator.appName == 'Netscape')
			var language = navigator.language;
		else
			var language = navigator.browserLanguage;
							
		if (language.indexOf('en') > -1)
			varPath = 'en';
		else if (language.indexOf('fr') > -1)
			varPath = 'fr';
		else if (language.indexOf('de') > -1)
			varPath = 'en';
		else
			varPath = 'en';
							
		document.location.href = fname+varPath+'.'+ext;
	} catch(e){}
}


var doc = window.document;
var config = new Object();
setCustomSoftphoneConfig(config);
		
addServerScript(doc, "defaultconfig.js");
addServerScript(doc, "createuser.js");
addServerScript(doc, "startup.js");
addServerScript(doc, "constructSoftphone.js");
addScript(doc, "defaultconfig.js", config.webInterfacePath);
addScript(doc, "webinterfaceconfig.js", "http://"+config.sphClientServerHost+"/"+config.sphClientServerPath+config.sphClientLang+"/");