function constExpression(x) {
	return x;
}

function simplifyCSSExpression() {
	try {
		var ss,sl, rs, rl;
		ss = document.styleSheets;
		sl = ss.length
	
		for (var i = 0; i < sl; i++) {
			simplifyCSSBlock(ss[i]);
		}
	}
	catch (exc) {
		alert("Got an error while processing css. The page should still work but might be a bit slower");
		throw exc;
	}
}

function simplifyCSSBlock(ss) {
	var rs, rl;
	
	for (var i = 0; i < ss.imports.length; i++)
		simplifyCSSBlock(ss.imports[i]);
	
	if (ss.cssText.indexOf("expression(constExpression(") == -1)
		return;

	rs = ss.rules;
	rl = rs.length;
	for (var j = 0; j < rl; j++)
		simplifyCSSRule(rs[j]);
	
}

function simplifyCSSRule(r) {
	var str = r.style.cssText;
	var str2 = str;
	var lastStr;
	do {
		lastStr = str2;
		str2 = simplifyCSSRuleHelper(lastStr);
	} while (str2 != lastStr)

	if (str2 != str)
		r.style.cssText = str2;
}

function simplifyCSSRuleHelper(str) {
	var i, i2;
	i = str.indexOf("expression(constExpression(");
	if (i == -1) return str;
	i2 = str.indexOf("))", i);
	var hd = str.substring(0, i);
	var tl = str.substring(i2 + 2);
	var exp = str.substring(i + 27, i2);
	var val = eval(exp)
	return hd + val + tl;
}

/*if (/msie/i.test(navigator.userAgent) && window.attachEvent != null) {
	window.attachEvent("onload", function () {
		simplifyCSSExpression();
	});
}*/
function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}
function tamingselect(ts_selectclass)
{
	if(!document.getElementById && !document.createTextNode){return;}
	
// Classes for the link and the visible dropdown
	//var ts_selectclass='turnintodropdown'; 	// class to identify selects
	var ts_listclass='turnintoselect';		// class to identify ULs
	
	var ts_boxclass='dropcontainer'; 		// parent element
	var ts_triggeron='activetrigger'; 		// class for the active trigger link
	var ts_triggeroff='trigger';			// class for the inactive trigger link
	var ts_dropdownclosed='dropdownhidden'; // closed dropdown
	var ts_dropdownopen='dropdownvisible';	// open dropdown
/*
	Turn all selects into DOM dropdowns
*/
	var count=0;
	var toreplace=new Array();
	var sels=document.getElementsByTagName('select');
	for(var i=0;i<sels.length;i++){
		if (ts_check(sels[i],ts_selectclass))
		{
			var hiddenfield=document.createElement('input');
			hiddenfield.name=sels[i].name;
			hiddenfield.type='hidden';
			hiddenfield.id=sels[i].id;
			hiddenfield.value=sels[i].options[0].value;
			sels[i].parentNode.insertBefore(hiddenfield,sels[i])
			var trigger=document.createElement('a');
			ts_addclass(trigger,ts_triggeroff);
			trigger.href='#';
			trigger.onclick=function(){
				ts_swapclass(this,ts_triggeroff,ts_triggeron)
				ts_swapclass(this.parentNode.getElementsByTagName('ul')[0],ts_dropdownclosed,ts_dropdownopen);
				return false;
			}
			trigger.appendChild(document.createTextNode(sels[i].options[0].text));
			trigger.appendChild(document.createElement("p"));
			sels[i].parentNode.insertBefore(trigger,sels[i]);
			var replaceUL=document.createElement('ul');
			for(var j=0;j<sels[i].getElementsByTagName('option').length;j++)
			{
				var newli=document.createElement('li');
				var newa=document.createElement('a');
				var currOption	=  sels[i].getElementsByTagName('option')[j];
				newli.v= currOption.value;
				newli.elm=hiddenfield;
				newli.istrigger=trigger;
				newli.displayValue = currOption.text;
				newa.href='#';
				newa.appendChild(document.createTextNode(currOption.text));
				newli.onclick=function(){ 
					this.elm.value=this.v;
					this.elm.displayValue=this.displayValue;
					ts_swapclass(this.istrigger,ts_triggeron,ts_triggeroff);
					ts_swapclass(this.parentNode,ts_dropdownopen,ts_dropdownclosed)
					this.istrigger.firstChild.nodeValue=this.firstChild.firstChild.nodeValue;
					return false;
				}
				newli.appendChild(newa);
				replaceUL.appendChild(newli);
			}
			ts_addclass(replaceUL,ts_dropdownclosed);
			var div=document.createElement('div');
			div.appendChild(replaceUL);
			ts_addclass(div,ts_boxclass);
			sels[i].parentNode.insertBefore(div,sels[i])
			toreplace[count]=sels[i];
			count++;
		}
	}
	
/*
	Turn all ULs with the class defined above into dropdown navigations
*/	

	var uls=document.getElementsByTagName('ul');
	for(var i=0;i<uls.length;i++)
	{
		if(ts_check(uls[i],ts_listclass))
		{
			var newform=document.createElement('form');
			var newselect=document.createElement('select');
			for(j=0;j<uls[i].getElementsByTagName('a').length;j++)
			{
				var newopt=document.createElement('option');
				newopt.value=uls[i].getElementsByTagName('a')[j].href;	
				newopt.appendChild(document.createTextNode(uls[i].getElementsByTagName('a')[j].innerHTML));	
				newselect.appendChild(newopt);
			}
			newselect.onchange=function()
			{
				window.location=this.options[this.selectedIndex].value;
			}
			newform.appendChild(newselect);
			uls[i].parentNode.insertBefore(newform,uls[i]);
			toreplace[count]=uls[i];
			count++;
		}
	}
	for(i=0;i<count;i++){
		toreplace[i].parentNode.removeChild(toreplace[i]);
	}
	
}
function ts_check(o,c){
	 	return new RegExp('\\b'+c+'\\b').test(o.className);
	}
	function ts_swapclass(o,c1,c2)
	{
		var cn=o.className
		o.className=!ts_check(o,c1)?cn.replace(c2,c1):cn.replace(c1,c2);
	}
	function ts_addclass(o,c)
	{
		if(!ts_check(o,c)){o.className+=o.className==''?c:' '+c;}
	}
function shadowButton1(ts_selectclass,blnHover){
	if(!document.getElementById && !document.createTextNode){return;}
	var ts_triggeroff='btn';			// class for the inactive trigger link
	
	var count=0;
	
	var sels=document.getElementsByTagName('a');
	for(var i=0;i<sels.length;i++){
			
		if (ts_check(sels[i],ts_selectclass))
		{
			
			var trigger=sels[i];
			
			ts_swapclass(trigger,ts_selectclass,ts_triggeroff);
			trigger.href=trigger.href;
			
			var div;
			var mainDiv;
			
			div	= document.createElement("div");
			ts_addclass(div, "btn-common btnMiddle");
			
			
			var prevNode ;
			prevNode = null;
			
			for(var j=trigger.childNodes.length-1;j>=0;j--)
			{
				var n = trigger.childNodes[j];
				
				
				trigger.removeChild(n);
				if ( prevNode ) 
					div.insertBefore( n, prevNode);
				else
					div.appendChild(n);
				prevNode = n;
			}
			mainDiv = div;
			
			div	= document.createElement("div");
			ts_addclass(div, "btn-common btn_abs btnLeft");
			trigger.appendChild(div);
			
			trigger.appendChild(mainDiv);
			
			div	= document.createElement("div");
			ts_addclass(div, "btn-common btn_abs btnRight");
			trigger.appendChild(div);
			
			if(!(blnHover==false)){
				div	= document.createElement("div");
				ts_addclass(div, "imgHover");
				trigger.hoverElement= div;
				trigger.appendChild(div);
				trigger.onmouseover=function(){
					this.hoverElement.style.visibility = 'visible';
				}
				trigger.onmouseout=function(){
					this.hoverElement.style.visibility = 'hidden';
				}
			}
		}
	}
}
function shadowButton(ts_selectclass,blnHover)
{
	if(!document.getElementById && !document.createTextNode){return;}
	
// Classes for the link and the visible dropdown
	//var ts_selectclass='turnintodropdown'; 	// class to identify selects
	var ts_listclass='turnintoselect';		// class to identify ULs
	
	var ts_boxclass='dropcontainer'; 		// parent element
	var ts_triggeron='activetrigger'; 		// class for the active trigger link
	var ts_triggeroff='btnJob';			// class for the inactive trigger link
	var ts_dropdownclosed='dropdownhidden'; // closed dropdown
	var ts_dropdownopen='dropdownvisible';	// open dropdown
/*
	Turn all selects into DOM dropdowns
*/
	var count=0;
	var toreplace=new Array();
	var sels=document.getElementsByTagName('a');
	for(var i=0;i<sels.length;i++){
			
		if (ts_check(sels[i],ts_selectclass))
		{
			
			var trigger=sels[i];
			
			ts_swapclass(trigger,ts_selectclass,ts_triggeroff);
			trigger.href=trigger.href;
			/*trigger.onclick=function(){
				ts_swapclass(this,ts_triggeroff,ts_triggeron)
				ts_swapclass(this.parentNode.getElementsByTagName('ul')[0],ts_dropdownclosed,ts_dropdownopen);
				return false;
			}*/
			var div;
			var mainDiv;
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJobMiddle");
			
			
			var prevNode ;
			prevNode = null;
			
			for(var j=trigger.childNodes.length-1;j>=0;j--)
			{
				var n = trigger.childNodes[j];
				
				
				trigger.removeChild(n);
				if ( prevNode ) 
					div.insertBefore( n, prevNode);
				else
					div.appendChild(n);
				prevNode = n;
			}
			mainDiv = div;
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJob-common btnJob_abs btnJobTL");
			trigger.appendChild(div);
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJob-common btnJob_abs btnJobTM");
			trigger.appendChild(div);
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJob-common btnJob_abs btnJobTR");
			trigger.appendChild(div);
			
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJob-common btnJob_abs btnJobRM");
			trigger.appendChild(div);
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJob-common btnJobBottom_abs btnJobBR");
			trigger.appendChild(div);
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJobBottom_abs btnJobBM");
			trigger.appendChild(div);
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJob-common btnJobBottom_abs btnJobBL");
			trigger.appendChild(div);
			
			div	= document.createElement("div");
			ts_addclass(div, "btnJob-common btnJob_abs btnJobLM");
			trigger.appendChild(div);
			if(!(blnHover==false)){
				div	= document.createElement("div");
				ts_addclass(div, "imgHover");
				trigger.hoverElement= div;
				trigger.appendChild(div);
				
				if ( !trigger.onclick ){
					trigger.onclick=function(){
						document.location.href = this.href;
					}
				}
				div.onclick = trigger.onclick;
				trigger.onmouseover=function(){
					this.hoverElement.style.visibility = 'visible';
				}
				trigger.onmouseout=function(){
					this.hoverElement.style.visibility = 'hidden';
				}
		
		
			}
			trigger.appendChild(mainDiv);
			
		}
	}
	
	function ts_check(o,c)
	{
	 	return new RegExp('\\b'+c+'\\b').test(o.className);
	}
	function ts_swapclass(o,c1,c2)
	{
		var cn=o.className
		o.className=!ts_check(o,c1)?cn.replace(c2,c1):cn.replace(c1,c2);
	}
	function ts_addclass(o,c)
	{
		if(!ts_check(o,c)){o.className+=o.className==''?c:' '+c;}
	}
}
function AjaxRequest(params){
	if (!params) params={};
	this.onerror=params.onerror;
	this.onsuccess=params.onsuccess;
	this.url	= params.url;
	var xmlHttp;
	try{
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	}catch (e){
	  // Internet Explorer
	  try{
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	  catch (e){
	    try{
	      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }catch (e){
	      //alert("Your browser does not support AJAX!");
	      return false;
	    }
	  }
	}
	var obj	= this;
	xmlHttp.onreadystatechange=function(){
    	if(xmlHttp.readyState==4){
    		if ( xmlHttp.status <400){
    			if ( obj.onsuccess )try{ obj.onsuccess(xmlHttp)}catch(e){alert(e)};
    		}else{
    			if ( obj.onerror ) try{ obj.onerror(xmlHttp)}catch(e){alert(e)};
    		}
    		
      	}
    }
    this.xmlHttp = xmlHttp
  	
  	this.send=function(){
  		this.xmlHttp.open("GET",this.url,true);
  		this.xmlHttp.send(null);
  	}
  	
}
