/* NORMAL JAVASCRIPT FUNCTIONS */
function cm_bwcheck(){
	//In theory we should use object detection, but this script needs work-arounds for almost every browser...
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.ns47=(this.ns4 && (this.ver.search(/^4.7/))==0 )?1:0;
	this.ns7 = (this.agent.indexOf("netscape/7")>-1)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7//Use dom creation
  this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}


function RollNavImg(i, str) {
		oImg = document.getElementById(str);
		if(oImg!=null) {
			oImg.setAttribute("src", rollAImg[i].src)		
		}
}

function RollNavImgBack(i, str) {
		oImg = document.getElementById(str);
		if(oImg!=null) {
			oImg.setAttribute("src", rollImg[i].src)		
		}
}

function OpenPopUp(url)
{
	window.open(url,'popUp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable,copyhistory=yes,width=570,height=470,left=0, top=0,screenX=0,screenY=0');
}

function OpenPrintPopup(wFile,wWidth,wHeight,wScrolling)
{
    myWin = window.open(wFile, 'PrintWindow', 'width=' + wWidth + ',height=' + wHeight + ',resizable=1,scrollbars=' + wScrolling);
    if (myWin) {
        myWin.moveTo((screen.width / 2) - (wWidth / 2), (screen.height / 2) - (wHeight / 2));
        myWin.focus();
    }
}

function OpenDiashowPopup(wFile,wWidth,wHeight,wScrolling)
{
	myWin=window.open(wFile,'DiashowWindow','width='+wWidth+',height='+wHeight+',resizable=1,scrollbars='+wScrolling);
	if (myWin) {
	    myWin.moveTo((screen.width / 2) + (wWidth-50), (screen.height / 2) - (wHeight / 2));
	    myWin.focus();
	}
}

function SetStatus(msg)
{
	setTimeout('window.status = "'+msg+'"', 100);
}

/* move Items in Contact Form */

function move(src,dest,hidden,type)
{
	from = document.getElementById(src);
	to = document.getElementById(dest);
	store = document.getElementById(hidden);
	
	var p=0,q=0;
	var sel = new Array();
	var not = new Array();
	
	// divide items
	for (i=0;i<from.length;i++)
	{
		if(from[i].selected==true)
		{
			sel[p] = new Array();
			sel[p]['name'] = from[i].value;
			p++;
		} else {
			not[q] = new Array();
			not[q]['name'] = from[i].value;
			q++;
		}
	}
	
	// add selected
	for(i=0;i<to.length;i++)
	{
		sel[p] = new Array();
		sel[p]['name'] = to[i].text;
		p++;
	}
	
	// reorder selection
	sel = reOrder(sel,list_items);
	
	from.length=0;
	to.length=0;
	
	var tmp = new Array();
	
	for(i = 0; i<sel.length; i++)
	{
		insertItem(sel[i],to,i)
		if(type==1) {
			tmp[i] = sel[i]['name'];
		}
	}	
	for(i = 0; i<not.length; i++)
	{
		insertItem(not[i],from,i)
		if(type==0) {
			tmp[i] = not[i]['name'];
		}
	}
	
	store.value = tmp;
}

function reOrder(arr,list)
{
	for(i=0;i<arr.length;i++)
	{
		for(j=0;j<list.length;j++){
			if(arr[i]['name']==list[j]['name']){
				arr[i]['pos']=list[j]['pos'];
			}
		}
	}

	for(i=(arr.length-1);i>0;i--){
		for(k=0;k<i;k++){
			if(arr[k]['pos']>arr[k+1]['pos'])
			{
				tmp=arr[k];
				arr[k]=arr[k+1];
				arr[k+1]=tmp;
				}
			}
		}
	return arr;
}

function insertItem(val,list,pos)
{
	list[pos]=new Option();
	list[pos].text=val['name'];
	list[pos].value=val['name'];
}


function formCheck(val)
{
	if(document.forms[0].s.value==val)
		return false;
	
	return true;
}


function formFocus(val)
{
	if(document.forms[0].s.value==val)
		document.forms[0].s.value="";
}


function formBlur(val)
{
	if(document.forms[0].s.value=="")
		document.forms[0].s.value=val;
}

function setFlashHeight(divid, newH, timeout){
	o = document.getElementById(divid);
	
	if (!timeout) timeout = 0;
	if(o) {
		setTimeout('resizeFlash(o,'+newH+')',timeout);  
	}
}

function resizeFlash(div, newH)
{
	div.style.height = newH+"px";
}


