﻿// Copyright Active Discovery, Inc., 2005, 2006
// Needs to be saved and loaded as utf-8!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

// some changes by: dexterT
function xImage(src) {
window.onerror = function() { return true; }

	var myImage = new Image();
	myImage.style.position = "absolute";
	myImage.style.visibility = "hidden";
	myImage.style.backgroundImage = "url(images/loading.gif)";
	myImage.style.backgroundRepeat = "no-repeat";
	myImage.style.backgroundPosition = "center center";

	if(typeof(src) != "string") {
		alert("xImage: src required");
		return false;
	}

	myImage.src = src;

	if(myImage.readyState == "complete" || myImage.readyState == "loaded" || myImage.complete == true) {
		myImage.style.background = "";
		if ((browserInfo().browserShortName=="IE")&&(navigator.appVersion.indexOf("MSIE 7")<0)) {
			if(getFileType(src) == ".png") {
				myImage.div = document.createElement("div");
				myImage.div.pngSource = new Image();
				myImage.div.myPNG=true;
				myImage.div.mySrc=src;
				myImage.div.pngSource.src=src;
				myImage.div.pngSource.id=myUniqueId();
				myImage.div.pngSource.myParent=myImage;
				myImage.div.pngSource.style.visibility="hidden";
				myImage.orgWidth = myImage.div.pngSource.width;
				myImage.orgHeight = myImage.div.pngSource.heigth;
				myImage.style.height = myImage.div.pngSource.height;
				myImage.style.width = myImage.div.pngSource.width;
				//myImage.src = "images/empty.gif";
				document.body.appendChild(myImage.div.pngSource);
				if (myImage.div.pngSource.readyState=="complete") {
					temp="changePNG(\""+myImage.div.pngSource.id+"\")";
					window.setTimeout(temp,0);
				} else
					myImage.div.pngSource.onreadystatechange=changePNG;
				myImage.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+src+" sizingmethod=scale)";
				myImage.src = "images/empty.gif";
//				myImage.style.visibility = "visible";
				return myImage;
			} else
				return myImage;
		} else {
//			myImage.style.visibility = "visible";
			return myImage;
		}
	}

	myImage.http_request = null;
	
	if(window.XMLHttpRequest) // code for Mozilla, etc.
		myImage.http_request=new XMLHttpRequest();
	else if(window.ActiveXObject)// code for IE 
		myImage.http_request=new ActiveXObject("Microsoft.XMLHTTP");
			
	if(myImage.http_request!=null){
		myImage.http_request.open("GET", "serverAnswers.php?image="+src, true);
		myImage.http_request.onreadystatechange = function() {
			if(myImage.http_request.readyState==4){
				if(myImage.http_request.status==200){
					var response;
					response=myImage.http_request.responseText;
					indexName1 = eval(response.lastIndexOf("`"));
					indexName2 = eval(response.lastIndexOf("*"));
					indexName3 = eval(response.lastIndexOf(","));
					
					width = eval(response.substring(indexName2+1, indexName3));
					height = eval(response.substr(indexName3+1));
					src = response.substring(indexName1+1, indexName2);

					switch(getFileType(src)) {
						case ".png": {
							if ((browserInfo().browserShortName=="IE")&&(navigator.appVersion.indexOf("MSIE 7")<0)) { // No native support for IE6 and lower
								myImage.div = document.createElement("div");
								myImage.div.pngSource = new Image(width, height);
								myImage.div.myPNG=true;
								myImage.div.mySrc=src;
								myImage.div.pngSource.src=src;
								myImage.div.pngSource.id=myUniqueId();
								myImage.div.pngSource.myParent=myImage;
								myImage.div.pngSource.style.visibility="hidden";
								myImage.src = "images/empty.gif";
								myImage.orgWidth = width;
								myImage.orgHeight = height;
								myImage.style.width = myImage.div.pngSource.width;
								myImage.style.height = myImage.div.pngSource.height;
								myImage.style.background = "";
								document.body.appendChild(myImage.div.pngSource);
								if (myImage.div.pngSource.readyState=="complete") {
									temp="changePNG(\""+myImage.div.pngSource.id+"\")";
									window.setTimeout(temp,0);
								} else
									myImage.div.pngSource.onreadystatechange=changePNG;
								myImage.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+src+" sizingmethod=scale)";
							} else {
								myImage.orgWidth=width;
								myImage.orgHeight=height;
								myImage.style.background = "";
							}
							break;
						}
						case ".bmp":
						case ".jpg":
						case ".gif": {
							myImage.orgWidth=width;
							myImage.orgHeight=height;
							myImage.style.background = "";
							break;
						}
						//default:
						//	window.alert("Image type not supported");
						//	break;
					}//switch
//					myImage.style.visibility = "visible"
					resizeBasic();
				}//else
					//alert("Problem retrieving XML data");
			}
		}
		myImage.http_request.send(null);
	}else
		alert("Your browser does not support XMLHTTP.");
	return myImage;
}

function proper(s) {
        // returns a capitalized string from input string s
        // returns empty string if type of s is not string
        var retStr, l;

        if (typeof(s)!="string")
                return "";
        else {
                switch (s.length) {
                        case 0:
                                return "";
                        case 1: {
                                retStr=s;
                                return retStr.toUpperCase();
                        }
                        default: {
                                retStr=s.substr(0,1);
                                retStr=retStr.toUpperCase();
                                retStr=retStr+s.substr(1);
                                return retStr;
                        }
                }
        }
}


function createP(s) {	
	var retval;
	
	if (typeof(s)=="undefined")
		s="";
	retval=document.createElement("p");
	retval.innerHTML=s;
	return retval;
}

function getParam(param) {
	urlquery=location.href.split("?");
	window.alert(urlquery[1]);
}

function changePNG(id) { // only to be called in IE
	
	var sourceElement;
	
	if (typeof(id)=="string") {
		sourceElement=document.getElementById(id);
	}
	else {
		sourceElement=event.srcElement;
		if (sourceElement.readyState!="complete")
			return; // just wait for the next readyStateChange
	}
	// object is ready
	sourceElement.orgWidth=sourceElement.offsetWidth;
	sourceElement.orgHeight=sourceElement.offsetHeight;
	sourceElement.myParent.orgWidth=sourceElement.offsetWidth;
	sourceElement.myParent.orgHeight=sourceElement.offsetHeight;
	document.body.removeChild(sourceElement);
}

var ADDMsgWindow;
function message(str) {

// Displays a message in a new window, useful for debugging

	var p;

	if (typeof(ADDMsgWindow)!="object")
		ADDMsgWindow=window.open();
	p=ADDMsgWindow.document.createElement("p");
	p.innerHTML=str;
	ADDMsgWindow.document.body.appendChild(p);
}

function createDiv(position) { // creates an absolute positioning div element without margins etc.

	var myDiv;

	myDiv=document.createElement("div");
	if (typeof(position)!="string")
		myDiv.style.position="absolute";
	else {
		switch (position) {
			case "relative":
			case "absolute":
			case "static": {
				myDiv.style.position=position;
				break;
			}
			default: {
				window.alert("Positioning not allowed in createDiv");
				break;
			}
		} // switch
	} //else
	clearMargins(myDiv);
	return myDiv;
}

function createMailObject(obj){

// returns a form

var myForm, i, len;
			
	myForm=document.createElement("form");	//form
	myForm.style.position="absolute";
	myForm.method="Post";
	myForm.action="mailer1234.php";	
	myForm.onsubmit=submitForm;
	myForm.fieldLength=obj.fieldInfo.length;
	document.body.appendChild(myForm);
				
	myForm.recipient=document.createElement("input");//recipient
	myForm.recipient.type="hidden";
	myForm.recipient.name="recipient";
	myForm.recipient.id="recipient";
	myForm.recipient.value=obj.recipient;
	myForm.appendChild(myForm.recipient);
				
	myForm.subject=document.createElement("input");//subject
	myForm.subject.type="hidden";
	myForm.subject.name="subject";
	myForm.subject.id="subject";
	myForm.subject.value=obj.subject;
	myForm.appendChild(myForm.subject);
				
	myForm.sender=document.createElement("input");//sender
	myForm.sender.type="hidden";
	myForm.sender.name="sender";
	myForm.sender.id="sender";
	myForm.sender.value=obj.sender;
	myForm.appendChild(myForm.sender);
				
	myForm.title1=document.createElement("input");//title
	myForm.title1.type="hidden";
	myForm.title1.name="title";
	myForm.title1.id="title";
	myForm.title1.value=obj.title;
	myForm.appendChild(myForm.title1);
				
	myForm.redirect=document.createElement("input");//redirect page
	myForm.redirect.type="hidden";
	myForm.redirect.name="redirect";
	myForm.redirect.id="redirect";
	myForm.redirect.value=obj.redirect;
	myForm.appendChild(myForm.redirect);
				
	myForm.message=document.createElement("input");	//temporary container 
	myForm.message.type="hidden";
	myForm.message.name="message";
	myForm.message.id="message";
	myForm.message.value=""
	myForm.appendChild(myForm.message);
				
	myForm.mailTitle=document.createElement("p");
	myForm.mailTitle.innerHTML=obj.title;
	myForm.mailTitle.style.position="absolute";
	myForm.appendChild(myForm.mailTitle);
				
	len=obj.fieldInfo.length;						
	myForm.field= new Array();
	myForm.caption=new Array();
	myForm.hiddenField= new Array();
	for(i=0; i<len; i++){
		myForm.caption[i]=document.createElement("p");
		myForm.caption[i].innerHTML=obj.fieldInfo[i].caption;
		myForm.caption[i].style.position="absolute";				
		myForm.appendChild(myForm.caption[i]);
		clearMargins(myForm.caption[i]);
										
		myForm.field[i]=createInput(obj.fieldInfo[i]);
		myForm.field[i].style.position="absolute";
		clearMargins(myForm.field[i]);
		myForm.appendChild(myForm.field[i]);
				
	}
	myForm.bttSubmit=document.createElement("input");
	myForm.bttSubmit.type="submit";
	myForm.bttSubmit.style.position="absolute";
	if(typeof(obj.bttnCaption)=="undefined"){
		obj.bttnCaption="Submit";
	}
	myForm.bttSubmit.value=obj.bttnCaption;
	myForm.appendChild(myForm.bttSubmit);
				
	return myForm;
}


function createMailObject(obj, area){
var myForm, i, len;
			
	myForm=document.createElement("form");	//form
	myForm.style.position="absolute";
	myForm.method="Post";
	myForm.action="mailer1234.php";	
	myForm.onsubmit=submitForm;
	myForm.fieldLength=obj.fieldInfo.length;
	document.body.appendChild(myForm);
				
	myForm.recipient=document.createElement("input");//recipient
	myForm.recipient.type="hidden";
	myForm.recipient.name="recipient";
	myForm.recipient.id="recipient";
	myForm.recipient.value=obj.recipient;
	myForm.appendChild(myForm.recipient);
				
	myForm.subject=document.createElement("input");//subject
	myForm.subject.type="hidden";
	myForm.subject.name="subject";
	myForm.subject.id="subject";
	myForm.subject.value=obj.subject;
	myForm.appendChild(myForm.subject);
				
	myForm.sender=document.createElement("input");//sender
	myForm.sender.type="hidden";
	myForm.sender.name="sender";
	myForm.sender.id="sender";
	myForm.sender.value=obj.sender;
	myForm.appendChild(myForm.sender);
				
	myForm.title1=document.createElement("input");//title
	myForm.title1.type="hidden";
	myForm.title1.name="title";
	myForm.title1.id="title";
	myForm.title1.value=obj.title;
	myForm.appendChild(myForm.title1);
				
	myForm.redirect=document.createElement("input");//redirect page
	myForm.redirect.type="hidden";
	myForm.redirect.name="redirect";
	myForm.redirect.id="redirect";
	myForm.redirect.value=obj.redirect;
	myForm.appendChild(myForm.redirect);
				
	myForm.message=document.createElement("input");	//temporary container 
	myForm.message.type="hidden";
	myForm.message.name="message";
	myForm.message.id="message";
	myForm.message.value=""
	myForm.appendChild(myForm.message);
				
	myForm.mailTitle=document.createElement("p");
	myForm.mailTitle.innerHTML=obj.title;
	myForm.mailTitle.style.position="absolute";
	myForm.appendChild(myForm.mailTitle);
				
	len=obj.fieldInfo.length;						
	myForm.field= new Array();
	myForm.caption=new Array();
	myForm.hiddenField= new Array();
	for(i=0; i<len; i++){
		myForm.caption[i]=document.createElement("p");
		myForm.caption[i].innerHTML=obj.fieldInfo[i].caption;
		myForm.caption[i].style.position="absolute";				
		myForm.appendChild(myForm.caption[i]);
		clearMargins(myForm.caption[i]);
										
		myForm.field[i]=createInput(obj.fieldInfo[i]);
		myForm.field[i].style.position="absolute";
		clearMargins(myForm.field[i]);
		myForm.appendChild(myForm.field[i]);
				
	}
	myForm.bttSubmit=document.createElement("input");
	myForm.bttSubmit.type="submit";
	myForm.bttSubmit.style.position="absolute";
	if(typeof(obj.bttnCaption)=="undefined"){
		obj.bttnCaption="Submit";
	}
	myForm.bttSubmit.value=obj.bttnCaption;
	myForm.appendChild(myForm.bttSubmit);
	if(typeof(area)!="undefined"){
		myForm.area=document.createElement("textArea");
		myForm.area.style.position="absolute";
		myForm.appendChild(myForm.area);
	}						
	return myForm;
}

function createInput(obj, type){
	var txtBox;
	if(typeof(type)=="undefined"){
		type="text";
	}
	if(typeof(obj.value)=="undefined"){
		obj.value="";
	}
	txtBox=document.createElement("input");
	
	txtBox.name=obj.name;
	txtBox.id=obj.name;
	txtBox.value=obj.value;
	txtBox.type=type;

	return txtBox;
}
			
function submitForm() {
	var i, len, msg="";	
	len=this.fieldLength;
	//concatenate all the text
	for(i=0; i<len; i++){					
		msg=msg + this.caption[i].innerHTML+"  " +this.field[i].value+"\n";	
	}
	this.message.value=msg;				
	return true;
}
			
function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    //we have to return true if browser is Explorer for now
    if(navigator.appName!="Netscape"){
    		return true;
    }    
    if (navigator.plugins && navigator.plugins.length > 0) {
    
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {	
	    // loop through all desired names and check each against the current plugin name
	    	var numFound = 0;
	    	for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
		// if desired plugin name is found in either plugin name or description
				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
		    		(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    		numFound++;
		    //we have to return true if we found either of the agruments
		    		return true;
				}   
	    	}
		}
    }
    return false; //we didn't find any plug in 
} // detectPlugin

function detectMimetypes(str){
var i, x, minetypes, str1;
	
	if(browserSnipper()){
		return true;
	}
		
	x=navigator.mimeTypes.length;
	
	for(i=0; i<x ; i++){
		str1=navigator.mimeTypes[i].type;
		
		if(str1.indexOf(str)!=-1){
			return true;
		}
	}
	
	return false;
}

function getFileType(filename) {

	var index, s, fileExtension;

    s=filename;
    index=s.lastIndexOf(".");
        // We have the last "."
    if (index!=-1) {
		s=s.substr(index);
        return s.toLowerCase();
    }
    else
		return "unknown";
}

//start development for the sound
function playSound(){
//	alert(typeof(this.Play))
	if(typeof(this.Play)!="undefined"){
		this.Play();
	}						
}		

function stopSound(){
	if(typeof(this.Stop)!="undefined"){
		this.Stop();
	}			
}
		
function addParam(name, value){
		
	if(navigator.appName=="Netscape"){
		var param;
		param=document.createElement("param");
		param.name=name;
		param.value=value;
		this.appendChild(param);								
	}
	else{
		this.setAttribute(name, value);
	}
}

function addSound(source){

	var sound, isPlayer=false, obj;
	
	if(source=="" || typeof(source)=="undefined"){
		return null;
	}

	type=getFileType(source);
	switch (type){
		//check for the mime types for quick time only 
		case ".wma":{
				isPlayer=detectMimetypes("audio/x-wma")
		break;
		     	}
	       	case ".wav":{
	       			isPlayer=detectMimetypes("audio/x-wav");
	       	break;
	       		}
	       	case ".mp3":{
	       			isPlayer=detectMimetypes("audio/mpeg");
	       	break;
	       	     }
	       	case ".mid":
	       	case ".midi":{
	       			isPlayer=detectMimetypes("application/x-midi");
	       	break;
	       	     }
	       	     
	       	default:{
	       		alert("File type not Supported");
	       		return null;
	       	}
	}
	
	if(!isPlayer){		
		return null;
	}
	else{
		if(!browserSnipper()){
			//detect for windows media player
			winPlug=detectPlugin("Windows Media Player")
			if(winPlug){
				alert("You have Windows Media Player and QuickTime plug-in but we recommend to use the QuickTime");
			}			
			obj=document.createElement("object");
			obj.setAttribute("data", source);		
			obj.playMe=playSound;
			obj.stopMe=stopSound;
			obj.addParam=addParam;
			obj.loaded=false;
			obj.timer=0;
			mySound1234=obj;
			checkSoundLoad();	
		return obj;	
		}
		else{
			sound=document.createElement("embed");
			sound.src=source;
			sound.playMe=playSound;
			sound.stopMe=stopSound;
			sound.loaded=false;
			sound.timer=0;
			mySound1234=sound;			
			sound.addParam=addParam;
		checkSoundLoad();	
		}
	}
return sound;
}

function checkSoundLoad(){
	if(typeof(mySound1234.Play)=="function" || typeof(mySound1234.Play)=="unknown"){
		mySound1234.loaded=true;
		window.clearTimeout(mySound1234.timer);
	}
	else{
		window.setTimeout("checkSoundLoad()", 1000)				
	}
}
//end sound objectt

var myRegion12345; // The strange name so it won't be mixed with other variables, don't know if Jscript supports static within function

var br1352; // Same as above

function browserInfo() {

// returns info about the browser

var temp;

if (typeof(br1352)=="object") {
	return br1352;
}
else {
	temp=detectBrowser();
	br1352=new Object();
	br1352.browserName=temp.name;
	br1352.browserVersion=temp.version;
	br1352.platform=navigator.platform;
	br1352.userAgent=navigator.userAgent;
	br1352.systemLanguage=navigator.systemLanguage;
	br1352.userLanguage=navigator.userLanguage;
	// Now we set the shortName
	switch (br1352.browserName) {
		case "Microsoft Internet Explorer": {
			br1352.browserShortName="IE";
			break;
		}
		case "Opera": {
			br1352.browserShortName="Opera";
			break;
		}
		case "Netscape": {
			if (br1352.userAgent.indexOf("Firefox")>0)
				br1352.browserShortName="Firefox";
			else {
				if (br1352.userAgent.indexOf("Netscape")>0)
					br1352.browserShortName="Netscape";
				else
					br1352.browserShortName="Unknown";
			}
			break;
		}
		default: {
			br1352.browserShortName="Unknown";
			break;
		}
	}
	// Now we check for the flashVersion
	
	if (br1352.browserShortName=="IE") {
		flashVersion=VBGetSwfVer(1); // This needs to be included in the Functions file, for now it has to be in the index.html
	}
	else
		flashVersion=JSGetSwfVer();
	if (flashVersion!=-1) {
		br1352.flashSupport=true;
		br1352.flashVersion=flashVersion;
	}
	else
		br1352.flashSupport=false;		
	
	// return the object
	return br1352;
}
}

function detectBrowser(){

var browserInfo=new Object;
        var useragent = navigator.userAgent;
        var Browser = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
        var pos = useragent.indexOf('MSIE');

        if (pos > -1) {
                Version = useragent.substring(pos + 5);
                var pos = Version.indexOf(';');
                var Version = Version.substring(0,pos);
        }
        if (Browser == "Netscape") {
                var Version = useragent.substring(8);
                var pos = Version.indexOf(' ');
                var Version = Version.substring(0, pos);
        }
        var pos = useragent.indexOf('Opera');
        if (pos > -1) {
                Version = useragent.substring(pos + 6);
                var pos = Version.indexOf(' ');
                var Version = Version.substring(0, pos);
        }

        if (Browser == "Netscape" && parseInt(navigator.appVersion) >= 5) {
			var pos = useragent.lastIndexOf('/');
			var Version = useragent.substring(pos + 1);
        }
        browserInfo.version=Version;
        browserInfo.name=Browser;
        return browserInfo;
}

function shortDate(date) {
        // returns a string according to the region for the date, if no date is given, the function returns today's date
        var day, month, year, intDate;

        if (typeof(date)!="object") // We'll assume today
                intDate=new Date();
        else
                intDate=date;

        day=intDate.getDate();
        month=intDate.getMonth()+1;
        year=intDate.getFullYear();

        switch(getRegion().language) { // We only have the language available...
		case "de": // Germany
			return day+"."+month+"."+year;
                case "nl": // The Netherlands
                        return day+"-"+month+"-"+year;
                default:
                        return month+"/"+day+"/"+year;
        }
}

function longDate(date) {
        // returns a string according to the region for the date, if no date is given, the function returns today's date

        var day, month, year, intDate;

        if (typeof(date)!="object") // We'll assume today
                intDate=new Date();
        else
                intDate=date;

        day=intDate.getDate();
        month=intDate.getMonth()+1;
        year=intDate.getFullYear();

        switch(getRegion().language) { // We only have the language available...
		case "de": // Germany
                case "nl": // The Netherlands
                        return day+" "+getRegion().months[month-1]+" "+year;
                default:
                        return getRegion().months[month-1]+" "+day+", "+year;
        }
}

function xLongDate(date) {
// not tested yet
	var intDate;

	if (typeof(date)!="object")
		intDate=new Date();
	else
		intDate=date;
	return getRegion().weekdays[intDate.getDay()]+" "+longDate(intDate);
}

function setLanguage(language) {
			
        var region, str;

        getRegion();        // The region object must be there
        switch (language) {                // for now we just support the below languages
                case "en":
                case "nl":
                case "vi":       
                case "de":
                case "ar":	        
                case "ph": 
                case "es":
                        break;
                default: { // Otherwise we'll use the browserlanguage
                        if(!browserSnipper()) // a safer way would be checking for the type of navigator.language
                                str=navigator.language; // will give system language
                        else
                                str=navigator.userLanguage; // from region settings in windows
			
                        language=str.charAt(0)+str.charAt(1);
                        if(language=="en"){
							
                        }
                }
        }
        myRegion12345.language=language;                                        // We'll set it in the Region object
        createCookie("Language", myRegion12345.language, 30);        // And we'll set the cookie
        return language;                                                                        // And we'll set what is returned
}

function getRegion() {

                var myCookie;
        /*
        returns our own region object with settings for language, location, number format, etc.
        Properties supported:
                language, we'll use the first two letters from the Microsoft definition;
                                        We might add an extended language property to make full difference later
                months, array 0-11 with monthnames
                weekdays, array 0-6 with weekday names, starting with monday
        */

        var str;

        if (typeof(myRegion12345)=="object")
                return myRegion12345;
        else {
                myRegion12345=new Object();
                //first we read if we have a cookie
                myCookie=readCookie("Language");
	//	alert(myCookie);
                if(myCookie==null){
                        //now our cookie is null so we have to create
                        if(!browserSnipper()){ // a safer way would be checking for the type of navigator.language
                                str=navigator.language; // will give system language
                        }
                        else {
                                str=navigator.userLanguage; // from region settings in windows
                        }
                 
                        myRegion12345.language=str.charAt(0)+str.charAt(1);
                        //create a cookie with the myRegion12345.language value
                        //our cookie name "Language"
                }
                else{
                        //now we have a cookie
                        myRegion12345.language=myCookie;
                }
                switch (myRegion12345.language) {
                        case "nl": {
                                myRegion12345.months=new Array("januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december");
                                // days match the getDay function
                                myRegion12345.weekdays=new Array("zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag");
                                break;
                        }
                        case "de":{
								myRegion12345.months= new Array("Januar", "Februar", "März", "April", "Mag", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember")
								myRegion12345.weekdays = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
								break;
                        }
                        case "es":{
								myRegion12345.months = new Array("Enero", "Febrero", "Marcha", "Abril", "Puede", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
								myRegion12345.weekdays = new Array("domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado");
								break;
                        }
                        case "ko":{
								myRegion12345.months = new Array("1?", "2?", "3 ?", "4?","5?", "6??", "7?", "8?", "9?", "10?", "11?", "12?");
								myRegion12345.weekdays = new Array("???", "???", "???", "???", "???", "???", "???");
								break;
                        }
                        case "ph":{
								myRegion12345.months = new Array("Enero", "Febrero", "Marso", "Abril","Mayo", "Hunyo", "Hulyo", "Agusto", "Septembre", "Oktobre", "Nobembre", "Desembre");
								myRegion12345.weekdays = new Array("Domingo","Lunes", "Martes", "Merkules", "Huwebes", "Byernes", "Sabado");
								break;
                        }
                        case "ja":{
								myRegion12345.months = new Array("1?","2?","3?","4?","5?","6?","7?","8?","9?","10?","11?","12?");
								myRegion12345.weekdays = new Array("???" ,"???" ,"???" ,"???" ,"???" ,"???" ,"???");
								break;
                        }                  
                        case "fr":{
								myRegion12345.months = new Array("janvier","février","mars","avril","mai","juin","juillet","aôut","septembre","october","novembre","decembre");
								myRegion12345.weekdays = new Array("dimanche" ,"lundi" ,"mardi" ,"mercredi" ,"jeudi" ,"vendredi" ,"samedi");
								break;
                        }     
                        default: { // We'll default to english
                                myRegion12345.months=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
                                myRegion12345.weekdays=new Array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
								break;
						}
                } // end switch
        }
        //for now i will create a temporary case statement for the text direction
        switch (myRegion12345.language){
			case "ar":{
				myRegion12345.direction="Right";
			break 
			}	
			default:{
				myRegion12345.direction="Left";
			}
        }
        return myRegion12345;
}


function linkImage(imgArray){
var i, image, imageArray=new Array();
        //return image array object with the pictures,link and id
        for(i=0;i<imgArray.length;i++){
                image=new Image();
                image.src=imgArray[i].path;
                image.style.position="absolute";
                clearMargins(image);

                imageArray[i]= new Object();
                imageArray[i].pictures=image;
                imageArray[i].pictures.link=imgArray[i].link
                imageArray[i].pictures.onclick=linkImageClick;
                imageArray[i].pictures.id=imgArray[i].id
        }
        return imageArray;
}

function changeCursor(obj){
        var myObj;

    if(typeof(obj)=="undefined"){
          myObj=this;
    }
    else{
         myObj=obj;
        }
        if(!browserSnipper()){
                myObj.style.cursor="pointer";
        }
        else{
                myObj.style.cursor="hand";
        }
}

function browserSnipper(){ 

// Don't use anymore in new sites. Obsolete. Use browserInfo!

var IE;

        if(navigator.appName=="Microsoft Internet Explorer"){
                return true;
        }
        else{
                return false;
        }

}

function searchBetween(str, stringToSearch){

var returnValue;
        //this function will return a string
        //between the character of strignSearch
        //ex. you have a string like 21-4-5
        //it will return you 4
        first=str.indexOf(stringToSearch);
        last=str.lastIndexOf(stringToSearch);
        returnValue="";
        for(i=first+1;i<last;i++){
                returnValue+=str.charAt(i);
        }
        return returnValue
}

function compareDate(date1, date2) {
    // returns 0 if equal, returns positive if date1 > date 2, returns negative id date 1< date2
        var tmp1, tmp2;

        tmp1=date1.getFullYear()*10000+date1.getMonth()*100+date1.getDate();
        tmp2=date2.getFullYear()*10000+date2.getMonth()*100+date2.getDate();
        return (date1-date2);
}

function stringSearch(str, findWhat, findNext){
var pos1, pos2;
        //this function will search a string of the given string in str variable,
        //return true if the string is present otherwise false
        if(typeof(str)=="undefined" || typeof(findWhat)=="undefined" ){
                return null;
        }
        else{
                pos1=str.indexOf(findWhat);
                pos2=str.indexOf(findNext);
                if(pos1>0 || pos2>0){
                        return true;
                }
                else{
                        return false;
                }
        }
}

function createBlankTable(rowLength, colLength) {
	
	var myTable, myTHead, myTBody, i, j, cell, cells;
      
    myTable=document.createElement("TABLE");
    myTBody=document.createElement("TBODY");
    clearMargins(myTable);
    clearMargins(myTBody);
    myTable.appendChild(myTBody);
    i=0;
    cells=new Array();
    while(i<rowLength){
		cells[i]=new Array();
		tr=document.createElement("TR");
        myTBody.appendChild(tr);
        j=0;
        while(j<colLength) {
                       cell=document.createElement("TD");
                       cells[i][j]=cell;
                        tr.appendChild(cell);
                        j++;
                }
                i++;
    }
    myTable.nrOfColumns=colLength;
    myTable.nrOfRows=rowLength;
    myTable.mycells=cells;
    return myTable;
}

// this funciton is use to inert the column on the given table
function insertColumn(tableObj, columnNo, columnValue){

        var table, cell;

        for(i=0;i<columnValue.length;i++){
                var table=tableObj.rows[i];
                var cell;
                cell=table.insertCell(columnNo)
                clearMargins(cell);
                cell.innerHTML=columnValue[i];
        }
}
//end
// Below is the new createDataTable function, still contains lay-out info, to be described and improved
function createDataTable(rowInfo, columnInfo) {
        var obj, i, l, lc, pEl, name, myTHead, row, cell, title1, title2, headingRow;
        var myTable = new Array();

        i=0;
        while(i<rowInfo.length){
                myTable[i]= new Array();
                j=0;
                while(j<columnInfo.length){
                        myTable[i][j] = new Object();

                        myTable[i][j].content=getDataElement(rowInfo[i].id, columnInfo[j].id);
                        myTable[i][j].header= new Array();
                        myTable[i][j].header[i]=columnInfo[j].text;

                j++
                }
        i++
        }
        return myTable;
} // End of new datatable

function rectangle() {
        // This function returns a rectangle object
        // It supports all the common elements of an HTML object
        // A DIV element does not seem to work, because of an apparent minimum height requirement
        // This means we use a trick which requires the "Empty.gif" picture
        var rect;

        rect=new Image();
        rect.src="Empty.gif";
        rect.style.position="absolute";
        clearMargins(rect);
        return rect;
}

function createCookie(name,value,days) {
        //if you set the days to -1 the cookie will delete
        //if 0 the cookie will delete when the user close the browser
        if (days)
        {
                var date = new Date();
                /*Now get the current Time (in milliseconds) and add the required number of days
                 *(in milliseconds). Set the Time of the date to this new value, so that it now
                 *contains the date in milliseconds that the cookie should expire.*/
                date.setTime(date.getTime()+(days*24*60*60*1000));
                /*Set the variable expires to this date in the UTC/GMT format
                 *required by cookies.*/
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        //Finally write the new cookie intodocument.cookie in the correct syntax
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{//We're going to search for the name of the cookie, followed by an "=".
//So create this new string and put it in nameEQ:
        var nameEQ = name + "=";
/*        Then split document.cookie on semicolons. "ca" becomes an array
containing all cookies that are set for this domain and path.*/
        var ca = document.cookie.split(';');
        /*Then we go through the array (so through all cookies)*/
        for(var i=0;i < ca.length;i++)
        {
                var c = ca[i];/*Set "c" to the cookie to be checked.*/
                /*If the first character is a space, remove it by using the
                substring() method. Continue doing this until
                the first character is not a space*/
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                //now we found what are looking for we have to return it
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        /*If, after having gone through all cookies, we haven't found the name we're
        looking for, the cookie is not present. We return null.*/
        return null;
}

function eraseCookie(name)
{
        //we have to call the createCookie function and supply negative value for the days
        //The browser, seeing that the expiry date has passed, immediately removes the cookie
        createCookie(name,"",-1);
}
// Next function added by Robert. Working on it since April 5, 2005
// the copy_clip function is to copy text to clipboard it work's on IE and Mozilla
function copy_clip(text){

        if (window.clipboardData){
                // for IE
                window.clipboardData.setData("Text", text);
   }
   else if (window.netscape) {
                // for nestcape browser
                netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
                //creating data object
                var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
                if (!clip) return;
                // use to create transferable

                var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
                if (!trans) return;

                //set the dataFlavor
                trans.addDataFlavor('text/unicode');

                // ask for transfer data need to create new object
                var len = new Object();
                var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
                var copytext=text;
                str.data=copytext;
                // object for the out parameter

                /* the length is multiplied by two because we
                        are using a Unicode string which requires two bytes per character.
                */
                trans.setTransferData("text/unicode",str,copytext.length*2);

                var clipid=Components.interfaces.nsIClipboard;
                if (!clip)
                        return false;
                clip.setData(trans,null,clipid.kGlobalClipboard);
   }
   return false;
}

function getClipboard(){
        // the getClipboard function is use to retrieve the content of the clipboard it's work on IE and Mozilla
  if(window.clipboardData){
                 return(window.clipboardData.getData("Text"))
  }
  else if (window.netscape){
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

                // create the transferable
                var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);
                if(!clip){
                        return ;
                }

                var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
                 if(!trans){
                         return ;
                }

                // register the data flavor we use the "text/unicode"
                trans.addDataFlavor("text/unicode");
                clip.getData(trans,clip.kGlobalClipboard);

                var  str =new Object();
                var len =new Object();

                /* this code is use to prevent the error i experience which is
                 "Error: uncaught exception: [Exception... "Component returned failure
                code: 0x80004005 (NS_ERROR_FAILURE) [nsITransferable.getTransferData]
                nsresult: "0x80004005 (NS_ERROR_FAILURE)"*/
                try{trans.getTransferData("text/unicode",str,len);}
                catch(error){return;}
                // get the data from transfering object
                if(str){
                        if(Components.interfaces.nsISupportsWString){
                                 str=str.value.QueryInterface(Components.interfaces.nsISupportsWString);
                        }
                        else if(Components.interfaces.nsISupportsString){
                                 str=str.value.QueryInterface(Components.interfaces.nsISupportsString);
                        }
                        else{
                                str =null;
                        }
                }
                if(str)
                        str=str.data.substring(0,len.value/2);              
        }
  return str ;
}
/*
        var i; // This should be inside function
        var size=0;
        var x=0;
        var xsize;
        var limit=0;
        var x1=0;        var j1=0;
        var str=new Array();
        var arrImage=new Array;
        var index=0;
        var tempImage=new Image();
        var ndx=0;
        var source;
        var maxLimit=300;
        var tempLimit=0;
        var left;
        var top;
        var txtr=0;
        var i2;
        var t;
        var j = 0;
        var preLoad = new Array();
        var imgSlide=new Image();
*/
function slideShow(object, effects, Width, Height, picChangeDelay) {
var objImg = new Object();

	objImg.ImageDiv = createDiv("absolute");
	objImg.ImageDiv.orgWidth = Width;
	objImg.ImageDiv.orgHeight = Height;
//	objImg.ImageDiv.style.width = Width;
//	objImg.ImageDiv.style.height = Height;
//	objImg.ImageDiv.style.backgroundColor = "black";
	
	objImg.slideImage = new Array();
	objImg.firstImage = new Image();
	objImg.secondImage = new Image();
	objImg.fadeTime = 0;
	objImg.index = 0;
	objImg.effects = effects;

	if(typeof(object) == "undefined")
	{
		alert("no pictures found");
		return;
	}
	if(typeof(picChangeDelay) == "undefined")
		picChangeDelay = 2000;
	else
		picChangeDelay *= 1000;

	objImg.fadeTime = Math.round(picChangeDelay/200);

	for(i=0; i < object.length; i++) {		
		objImg.slideImage[i] = new Image();
		objImg.slideImage[i].src = object[i];
	}//end for
	
		objImg.randNum = Math.floor(Math.random()*objImg.slideImage.length);

		objImg.firstImage.src = objImg.slideImage[objImg.randNum].src;
		objImg.firstImage.style.position = "absolute";
		
		objImg.secondImage.style.position = "absolute";
		objImg.secondImage.style.visibility = "hidden";

	if(objImg.effects == "fade") {
		objImg.firstImage.style.filter = "alpha(opacity = 0)";
		objImg.firstImage.style.MozOpacity = 0;
		objImg.firstImage.style.Opacity = 0;
		objImg.firstImage.style.KhtmlOpacity = 0;
		
		objImg.secondImage.style.filter = "alpha(opacity = 0)";
		objImg.secondImage.style.MozOpacity = 0;
		objImg.secondImage.style.Opacity = 0;
		objImg.secondImage.style.KhtmlOpacity = 0;

		for(i = 0; i <= 100; i++) {
			(function(i){
				setTimeout(function(){fadeEffect(i, objImg)}, (i * objImg.fadeTime));
			})(i)
		}
		setInterval(function(){runSlideShow(objImg)}, picChangeDelay);

	}
//	else if(objImg.effects == "drop") {
	
//	}

	objImg.ImageDiv.appendChild(objImg.firstImage);
	objImg.ImageDiv.appendChild(objImg.secondImage);
	objImg.ImageDiv.onresize = function(){resizeSlide(objImg)};
	resizeSlide(objImg);

	return objImg.ImageDiv;
}

// fadeEffect created june 21, 2007
function fadeEffect(firstOpacityValue, obj) {
var secondOpacityValue;
	
	secondOpacityValue = 100 - firstOpacityValue;

	obj.firstImage.style.filter = "alpha(opacity = " + firstOpacityValue + ")";
	obj.firstImage.style.MozOpacity = firstOpacityValue / 100;
	obj.firstImage.style.Opacity = firstOpacityValue / 100;
	obj.firstImage.style.KhtmlOpacity = firstOpacityValue / 100;
	
	obj.secondImage.style.filter = "alpha(opacity = " + secondOpacityValue + ")";
	obj.secondImage.style.MozOpacity = secondOpacityValue / 100;
	obj.secondImage.style.Opacity = secondOpacityValue / 100;
	obj.secondImage.style.KhtmlOpacity = secondOpacityValue / 100;
}

function resizeSlide(obj) {
//still finding ways to make this fully work in mozilla and safari, the div.onresize is not working on this browsers
	if(!scaleObject(obj.ImageDiv.offsetWidth, obj.ImageDiv.offsetHeight, obj.firstImage))
		return false;

	obj.firstImage.style.top = Math.round((obj.ImageDiv.offsetHeight - obj.firstImage.offsetHeight) * 0.5) + "px";	
	obj.firstImage.style.left = Math.round((obj.ImageDiv.offsetWidth - obj.firstImage.offsetWidth) * 0.5) + "px";
	
	if(!scaleObject(obj.ImageDiv.offsetWidth, obj.ImageDiv.offsetHeight, obj.secondImage))
		return false;
	
	if(obj.secondImage.offsetLeft == 0) {
		obj.secondImage.style.top = Math.round((obj.ImageDiv.offsetHeight - obj.secondImage.offsetHeight) * 0.5) + "px";		
		obj.secondImage.style.left = Math.round((obj.ImageDiv.offsetWidth - obj.secondImage.offsetWidth) * 0.5) + "px";
	}
}

// runSlideShow recoded june 21, 2007
function runSlideShow(obj) {
//alert(objImg);
//	var randomNumber;

	obj.randNum=Math.floor(Math.random()*(obj.slideImage.length));

	if (obj.Index==obj.randNum){
		if(obj.Index == 0)
			obj.Index = 1;
		else
			obj.Index -= 1;
	} else
		obj.Index=obj.randNum;

	obj.secondImage.orgWidth = obj.ImageWidth;
	obj.secondImage.orgHeight = obj.ImageHeight;
	obj.secondImage.src = obj.firstImage.src;
	obj.secondImage.style.left = Math.round(obj.firstImage.offsetLeft) + "px";
	obj.secondImage.style.top = Math.round(obj.firstImage.offsetTop) + "px";

	obj.secondImage.style.visibility = "visible";
	resetSize(obj.secondImage);
	resizeSlide(obj);

	obj.secondImage.style.filter = "alpha(opacity = 100)";
	obj.secondImage.style.MozOpacity = 1;
	obj.secondImage.style.Opacity = 1;
	obj.secondImage.style.KhtmlOpacity = 1;
		
	obj.firstImage.style.filter = "alpha(opacity = 0)";
	obj.firstImage.style.MozOpacity = 0;
	obj.firstImage.style.Opacity = 0;
	obj.firstImage.style.KhtmlOpacity = 0;

	obj.firstImage.orgWidth = obj.ImageWidth;
	obj.firstImage.orgHeight = obj.ImageHeight;
	obj.firstImage.src=obj.slideImage[obj.Index].src;
	resetSize(obj.firstImage);
	resizeSlide(obj);

	for(i = 0; i <= 100; i++) {
		//setTimeout(function(){fadeEffect(i,obj)}, (i * obj.fadeTime));
		(function(i){
				setTimeout(function(){fadeEffect(i, obj)}, (i * obj.fadeTime));
		})(i)
	}

}

function Limit(max){
        maxLimit=max;
}

function zoomInZoomOut(objects, x, y, limit){

        left=x;
        top=y;
        Limit(limit);
        for(index=0;index<objects.length;index++){
                arrImage[index]=new Image();
                arrImage[index].src=objects[index].src;
        }
        zoomIn();
        return tempImage;
}
function zoomIn(){
        source=arrImage[ndx].src;
        tempImage.src=source;
        tempImage.style.visibility="visible";
        tempImage.style.position="absolute";
        document.body.appendChild(tempImage);
        if(tempLimit<maxLimit){
                tempLimit++;
                setTimeout("zoomIn()", 50);
        }
        else{
                setTimeout("zoomOut()", 5000);
        }
        tempImage.style.width=tempLimit +"px";
        tempImage.style.height=tempLimit +"px";
}

function zoomOut(){
        if(tempLimit>=1){
                tempLimit--;
                setTimeout("zoomOut()", 50);
        }
        else {
                setTimeout("zoomIn()", 100);
                ndx++;
                if(ndx>index-1) ndx=0;
        }
        tempImage.style.width=tempLimit +"px";
        tempImage.style.height=tempLimit +"px";
}

function maxFont(num){
        limit=num;
}

/*
function growingText(str1, str2){

        str[0]=str1;
        str[1]=str2;
        strObject=document.createElement("P");
        strObject.style.visibility="visible";
        strObject.style.position="absolute";
        strObject.style.fontSize=1+"px";

        document.body.appendChild(strObject);
        if (str1=="") return false;
        strObject.align="center";
        strObject.innerHTML=str[j1];
        strObject.style.fontFamily="trebuchet, sans-serif";
        strObject.style.color="#FFFFFF";
        strObject.style.width="100%"; //required for filter effects
        strObject.style.top=1+"px";
        if(navigator.appName=="Microsoft Internet Explorer"){
                // filter effect required only on IE 4+ browser
                strObject.style.filter="dropshadow() glow()";
                strObject.filters.dropshadow.color=000000;
                strObject.filters.dropshadow.offy=3;
                strObject.filters.dropshadow.offx=3
                strObject.filters.dropshadow.positive=1;
                strObject.filters.glow.color="brown";
                strObject.filters.glow.strength=5;
        }
        else{
                return;          
        }
        setTimeout("upText()", 100);
        return strObject;
}

function upText(){

        strn=str[j1];
        if (x1<0){
                x1=1;
        }
        if(x1<limit){
                x1++;
                setTimeout("upText()", 100);
        }
        else{
                setTimeout("downText()", 3000);
        }
        strObject.innerHTML=strn;
        strObject.style.fontSize=x1+"px";

}

function downText(){

        if(x1>=1){
                x1--;
                setTimeout("downText()", 100);
        }
        else{
                setTimeout("upText()", 3000);
                j1++;
                if(j1>str.length-1) j1=0;
        }

        if (x1>0){
                strObject.innerHTML=strn;
                strObject.style.fontSize=x1+"px";
        }
}

function sizeLimit(num){
        size=num;
}
*/

function openWindow(url, left, top, width, height){
        var win;
        winWidth1=width;
        winHeight1=height;
        winTop1=top;
        winLeft1=left;
        winDesign="\'toolbar=1,scrollbar=1,location=0,align=\"center\",statusbar=1,menubar=0,resizable=1,width="+winWidth1+",height="+winHeight1+",top="+winTop1+",left="+winLeft1+"\'";
        if(navigator.appName=="Microsoft Internet Explorer"){
                win=window.open(url,'window', winDesign);
        }
        else{
                win=window.open(url,'window');
        }
        win.focus();
        return win;
}

function resizeFunc() {

        var resized;

        resized=resizeBasic();
	
        resized=resized&&(resizeNonBasic());

        if (!resized) {
                window.setTimeout(resizeFunc, 500);
                writeStatus("Loading...");
        }
        else
			writeStatus("Done");
}

function clearMargins(obj) {
	obj.style.margin="0";
	obj.style.padding="0";
	obj.style.border="none";
}

function navigate(page) {
		window.location.href=page;
}

function objectReady(obj) {
	if (typeof(obj.myReadyState)=="boolean")
		return obj.myReadyState;
	else {
        if (navigator.appName=="Microsoft Internet Explorer")
                return (obj.readyState=="complete");
        else {
            if (navigator.appName=="Netscape")
                   return obj.complete;
            else
                   window.alert("Browser not supported");
        }
    }
}

function getEventSource(obj) {

	// This is really wrong it seems. What would be the input?

        if (navigator.appName=="Microsoft Internet Explorer")
                return event.srcElement;
        else {
                if (navigator.appName=="Netscape")
                        return window.event;
                else
                        window.alert("Browser not supported");
        }
}

// next two functions from: http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=16

function getWindowWidth() {

        if (document.body && typeof(document.body.clientWidth)=="number")
                return document.body.clientWidth;
        else {
                if (typeof(window.innerWidth)=="number") {
                        //Non-IE
                        return window.innerWidth;
                  }
                else {
                        if (document.documentElement && document.documentElement.clientWidth) {
                                //IE 6+ in 'standards compliant mode'
                                return document.documentElement.clientWidth;
                         }
                        else {
                                if (document.body && document.body.clientWidth) {
                                        //IE 4 compatible
                                        return document.body.clientWidth;
                                }
                                else {
                                        writeStatus("Browser not supported");
                                        return 800;
                                }
                        }
                  }
        }
 }

function getWindowHeight() {
        // I think this function really needs improvement
        info=browserInfo();
        if (info.browserShortName=="IE")
			if (info.browserVersion=="7.0") {
				if (document.documentElement.clientHeight!=0) // this is a really bad solution. Have to dive into this
					return document.documentElement.clientHeight; // if change to clientWidth, the whole page will extend its height producing a scrollbar on the left.. 
				else
					return document.body.clientHeight;
			}
        IE=browserSnipper();
        if(!IE) // We're not sure whether this is right, but it works for us now
                return window.innerHeight;

        if (document.body && typeof(document.body.clientHeight)=="number") { //dexterT: changed a bit, sometimes document.body.clientHeight returns zero for ie6
			if(document.body.clientHeight != 0) {
				return document.body.clientHeight;
			} else {
				return document.documentElement.clientHeight;
			}
        } else {
                if (typeof(window.innerHeight)=="number") {
                        //Non-IE
                        return window.innerHeight;
                  }
                else {
                        if (document.documentElement && document.documentElement.clientHeight) {
                                //IE 6+ in 'standards compliant mode'
                                return document.documentElement.clientHeight;
                         }
                        else {
                                if (document.body && document.body.clientHeight) {
                                        //IE 4 compatible
                                        return document.body.clientHeight;
                                }
                                else {
                                        writeStatus("Browser not supported");
                                        return 800;
                                }
                         }
                  }
        }
 }

function resetSize(obj) {

        obj.style.width="auto";
        obj.style.height="auto";
        obj.orgWidth="a";
        obj.orgHeight="a";
}

function scaleToWidth(obj, width) {
	if (!(typeof(obj.myFlash)=="boolean")) {
		if (typeof(obj)!="object") {
			window.alert("scaleToWidth not called with object. Type of obj parameter: "+typeof(obj));
			return true;
		}
	}
	if (obj.src=="Standard.jpg")
		debugger;
	// First check for IE and PNG
	if (browserInfo().browserShortName=="IE") {
		if (typeof(obj.myPNG)=="boolean") {
			if (typeof(obj.orgWidth)=="number") {
		        obj.style.width=Math.round(width)+"px";
				obj.style.height=Math.round(width/obj.orgWidth*obj.orgHeight)+"px";
				return true;
			}
			else
				return false;
		}
	}

	// Now see if we already figured something out
	// Parenthesis start here
	if ((typeof(obj.orgWidth)!="number")||(typeof(obj.orgHeight)!="number")) { // We didn't
            // First check if we have a offsetWidth and offsetHeight
         	if ((typeof(obj.offsetWidth)=="number")&&(typeof(obj.offsetHeight)=="number")) {
                 	if ((obj.offsetWidth!=0)&&(obj.offsetHeight!=0)) { //check if the offsetWidth and offsetHeight not equal to zero
                         	if (obj.offsetHeight>obj.offsetWidth) {// usually our picture the width is greater than height
                                 	if (!objectReady(obj)) {  //if the height is greater i check if the object is fully loaded to  get the accurate height and width
                                         	return false;
                                         }
                                         else {
                                         	obj.orgWidth=obj.offsetWidth;
                                                obj.orgHeight=obj.offsetHeight;
                                         }
                                 }
                                 else {
                                	obj.orgWidth=obj.offsetWidth;
                                        obj.orgHeight=obj.offsetHeight;
                                  }
                         }
                         else {
                         	if ((obj.width!=0)&&(obj.height!=0)) {   //check if we have a width and height
                                 	obj.orgWidth=obj.width;
                                         obj.orgHeight=obj.height;
                                 
                        	}
                                 else
                                 	return false;
                }
         }
         else 
		if ((typeof(obj.width)=="number")&&(typeof(obj.height)=="number")) {
                        // Otherwise maybe we have a width and a height
                        // They might be 0
       	       		if ((obj.width!=0)&&(obj.height!=0)) {
                    		obj.orgWidth=obj.width;
                                obj.orgHeight=obj.height;
	        	}
                	else {
	                     //modified robert try to figure out the scaling problem
        	             //check if the object has a style.width and height check the px
                	     if(typeof(obj.style.width)=="string") {
                        	       var str, i, tempWidth="", tempHeight;
	                               str=obj.style.width;
        	                       //we have to take out the px
                	              //take out the px for the width
                        	      //for the width
	                               for(i=0;i<str.length-2;i++) {
                                       tempWidth+=str.charAt(i);
                               }
                              //for the height
                              //take out the for the height
                              str=obj.style.height;
                              for(i=0;i<str.length-2;i++) {
                                         tempHeight+=str.charAt(i);
                              }
                              window.status="we arrive here";
                              obj.orgWidth=tempWidth;
                              obj.orgHeight=tempHeight;
                       }
                 else {
                         // We could do some more things to find height and width;
				window.alert("We should never arrive here");
                                return false;
                      }
               }
        }
        else {
             if (!objectReady(obj)) { //wait until the object is ready
                            return false;
             }
        }
         }
	obj.style.width=Math.round(width)+"px";
    obj.style.height=Math.round(width/obj.orgWidth*obj.orgHeight)+"px";
    return true;
}

function scaleToHeight(obj, height) {
        // Maybe better check the style width and height, hopefully to be added later
        if (objectReady(obj)) {
                // First we check if we have an orgWidth and orgHeight already
                if ((typeof(obj.orgWidth)!="number")||(typeof(obj.orgHeight)!="number")) {
                        // We have to get orgWidth and orgHeight
                        if ((typeof(obj.width)=="number")&&(typeof(obj.height)=="number")) {
                                // This seems to be the easiest way, just check width and height
                                obj.orgWidth=obj.width;
                                obj.orgHeight=obj.height;
                        }
                        else { // No width and height, check something else
                                if ((typeof(obj.offsetWidth)=="number")&&(typeof(obj.offsetHeight)=="number")) {
                                        obj.orgWidth=obj.offsetWidth;
                                        obj.orgHeight=obj.offsetHeight;
                                }
                                else {
                                        return false;
                                }
                        }
                }
                // We are supposed to have an orgWidth and orgHeigth
                obj.style.height=Math.round(height)+"px";
                obj.style.width=Math.round(height/obj.orgHeight*obj.orgWidth)+"px";
                return true;
        }
        else
                return false;
}

function scaleObject(maxW, maxH, obj) {

        if (scaleToWidth(obj, maxW)) {
                if (obj.offsetHeight>maxH) {
                        // we have to scale to the height instead of the width
                        obj.style.height=Math.round(maxH)+"px";
                        obj.style.width=Math.round(maxH/obj.orgHeight*obj.orgWidth)+"px";
                }
                return true;
        }
        else
                return false;
}

function myUniqueId() {

        if (typeof(unIdOb)=="undefined") {
                unIdOb=new Object();
                unIdOb.id1=0;
                unIdOb.id2=0;
                unIdOb.startCharNum="A".charCodeAt(0);
        }

        if (unIdOb.startCharNum<"Z".charCodeAt(0)){
                unIdOb.startCharNum++;
        } else {
                unIdOb.startCharNum="A".charCodeAt(0);
                if (unIdOb.id1<=9999)
                        unIdOb.id2++;
                else {
                        unIdOb.id1++;
                        unIdOb.id2=0;
                }
        }
        return String.fromCharCode(unIdOb.startCharNum)+"myUnId"+unIdOb.id1+"_"+unIdOb.id2;
}

function readyFunction(object)
{
        if (object.readyState=="complete")
                writeStatus("Done");
        else
                writeStatus("Loading");
        return object;
}

function waitForReady(object) {

        if (object.readyState!="complete")
                object.onreadystatechange=function anonymus() {readyFunction(object)};
        return object;
}

function resizeWindow(win, x, y, w, h) {

        // Only supports current window (or frame) with empty string.
        // only supports x/y and w/h pairs
        window.resizeBy(x,y);
        if (w < 100)
                w=100;
        if (h < 100)
                h=100;
        window.resizeTo(w,h);
        return win;
}

function writeStatus(str) {
        window.status=str;
}

function msgNum(string, num)

        {
        message(string+num);
        }

function showNavigator() {
        message("Navigator code name: "+navigator.appCodeName);
        message("Navigator name: "+navigator.appName);
        message("Navigator version: "+navigator.appVersion);
        message("Navigator user agent: "+navigator.userAgent);
        message("Navigator platform: "+navigator.platform);
}

var scrollerObjects=new Array(), scrollerIdNum;
var debug=0;

function internalScrollerFunc(Index) {

var currentXPos, currentDiv, i, l, obj, scrollerObject, div0, div1, zIndex, div0Style, div1Style;

scrollerObject=scrollerObjects[Index];

if (scrollerObject.inInternalScroller) // First check if we are not inside the scroller. We would be in big trouble otherwise.
        return;
//else left out
scrollerObject.inInternalScroller=true; // we are in the function with this object

// First some initizalization to speed things up (we hope) and improve readability
div0=scrollerObject.div0;
div1=scrollerObject.div1;
div0Style=div0.style;
div1Style=div1.style;
style=scrollerObject.style;
zIndex=scrollerObject.style.zIndex;

// First we check if we have to resize
if ((scrollerObject.style.left!=scrollerObject.div0.style.left)||
        (scrollerObject.style.top!=scrollerObject.div0.style.top)||
        (scrollerObject.style.width!=scrollerObject.div0.style.width)||
        (scrollerObject.style.height!=scrollerObject.div0.style.height)) {
        // We have to resize
        scrollerObject.div0.style.left=scrollerObject.style.left;
        scrollerObject.div1.style.left=scrollerObject.style.left;
        scrollerObject.div0.style.top=scrollerObject.style.top;
        scrollerObject.div1.style.top=scrollerObject.style.top;
        scrollerObject.div0.style.width=scrollerObject.style.width;
        scrollerObject.div1.style.width=scrollerObject.style.width;
        scrollerObject.div0.style.height=scrollerObject.style.height;
        scrollerObject.div1.style.height=scrollerObject.style.height;
}

currentDivIndex=scrollerObject.currentDivIndex;

// We first show everything that's there. We prepare for the next cycle afterwards. At least one object should be there, otherwise it should never be called.
if (currentDivIndex==0) { // we show DIV 0, which should be below DIV 1
                div0Style.visibility="visible";
        i=0;
        l=div0.childNodes.length;
        while (i<l) {
                div0.childNodes[i].style.visibility="visible";
                i++;
        }
        // and hide DIV 1, which is supposed to be the trick to show DIV 0, because it's on top
        div1.style.visibility="hidden";
        i=0;
        l=div1.childNodes.length;
        while (i<l) {
                div1.childNodes[i].style.visibility="hidden";
                i++;
        }
        //now we increase the Z-index for DIV 0 so it is the top DIV and decrease it for DIV 1
        div0Style.zIndex=zIndex; // nothing should happen
        i=0;
        l=scrollerObject.div0.childNodes.length;
        for (i=0;i<l;i++)
                div0.childNodes[i].style.zIndex=zIndex;
        div1.style.zIndex=zIndex-1;
        i=0;
        l=div1.childNodes.length;
        for (i=0;i<l;i++)
                div1.childNodes[i].style.zIndex=zIndex-1;
} // end of showing of DIV 0
else { // we show DIV 1, which should be below DIV 0
        div1.style.visibility="visible";
        i=0;
        l=div1.childNodes.length;
        while (i<l) {
                div1.childNodes[i].style.visibility="visible";
                i++;
        }
        // now we increase the Z-index for DIV 0 (which is visible), so it's on top, and decrease it for DIV 1, so we can prepare without any problems.
        scrollerObject.div0.style.visibility="hidden";
        i=0;
        l=div0.childNodes.length;
        while (i<l) {
                div0.childNodes[i].style.visibility="hidden";
                i++;
        }
        div1.style.zIndex=zIndex; // nothing should happen
        i=0;
        l=div1.childNodes.length;
        for (i=0;i<l;i++)
                div1.childNodes[i].style.zIndex=zIndex;
        div0.style.zIndex=zIndex-1;
        i=0;
        l=scrollerObject.div0.childNodes.length;
        for (i=0;i<l;i++)
                div0.childNodes[i].style.zIndex=zIndex-1;
} // end of showing of DIV 1

// the current div is on top and shown, the other is below and hidden
// we are going to prepare for the next cycle

if (currentDivIndex==0) { // we are going to prepare for the next cycle for DIV 1
        scrollerObject.currentDivIndex=1;
        currentDiv=scrollerObject.div1;
        scrollerObject.currentXOffset1-=scrollerObject.pixelMove2; // we are decreasing the X-offset to prepare for the next cycle
        currentXPos=scrollerObject.currentXOffset1; // we want to keep track of the current x-position
        i=0;
        l=currentDiv.childNodes.length;
        //we move all childNodes to the left
        while (i<l) {
                currentDiv.childNodes[i].style.left=currentXPos+"px";
                currentXPos+=currentDiv.childNodes[i].offsetWidth; // we want to keep track of the current x-position
                i++;
        }

        // all childNodes are at the appropriate place, now we have to check whether we have to add or remove objects
        // first of course the check of adding, otherwise we might en up without any objects
        while (currentXPos<currentDiv.offsetWidth) { // we have to add objects
                if (scrollerObject.currentObjectIndex1<scrollerObject.objects.length-1) // find next object first
                        scrollerObject.currentObjectIndex1++;
                else
                        scrollerObject.currentObjectIndex1=0;
                // now at the current Object
                obj=scrollerObject.objects[scrollerObject.currentObjectIndex1].cloneNode(true);
                currentDiv.appendChild(obj);
                obj.style.position="absolute";
                obj.style.top="0px";
                obj.style.left=currentXPos+"px";
                currentXPos+=obj.offsetWidth;
        }
        // now we remove childNodes at the front, this might not be efficient, but otherwise we have to keep track of free nodes
        currentXPos=scrollerObject.currentXOffset1; // we already increased the pixels
        obj=currentDiv.firstChild;
        currentXPos+=obj.offsetWidth;
        while (currentXPos<0) {
                currentXPos+=obj.offsetWidth;
                scrollerObject.currentXOffset1+=obj.offsetWidth;
                currentDiv.removeChild(obj);
                obj=currentDiv.firstChild;
        }
} // we prepared DIV 1 for the next cycle
else { // we are going to prepare for the next cycle for DIV 0
        scrollerObject.currentDivIndex=0;
        currentDiv=scrollerObject.div0;
        scrollerObject.currentXOffset0-=scrollerObject.pixelMove2; // we are decreasing the X-offset to prepare for the next cycle
        currentXPos=scrollerObject.currentXOffset0; // we want to keep track of the next x-position
        i=0;
        l=currentDiv.childNodes.length;
        //we move all childNodes to the left
        while (i<l) {
                currentDiv.childNodes[i].style.left=currentXPos+"px";
                currentXPos+=currentDiv.childNodes[i].offsetWidth; // we want to keep track of the next x-position
                i++;
        }
        // all childNodes are at the appropriate place, now we have to check whether we have to add or remove objects
        // first of course the check of adding, otherwise we might en up without any objects
        while (currentXPos<currentDiv.offsetWidth) { // we have to add objects
                if (scrollerObject.currentObjectIndex0<scrollerObject.objects.length-1) // find next object first
                        scrollerObject.currentObjectIndex0++;
                else
                        scrollerObject.currentObjectIndex0=0;
                // now at the current Object
                obj=scrollerObject.objects[scrollerObject.currentObjectIndex0].cloneNode(true);
                currentDiv.appendChild(obj);
                obj.style.position="absolute";
                obj.style.top="0px";
                obj.style.left=currentXPos+"px";
                currentXPos+=obj.offsetWidth;
        }
        // now we remove childNodes at the front, this might not be efficient, but otherwise we have to keep track of free nodes
        currentXPos=scrollerObject.currentXOffset0; // we already increased the pixels
        obj=currentDiv.firstChild;
        currentXPos+=obj.offsetWidth;
        while (currentXPos<0) {
                currentXPos+=obj.offsetWidth;
                scrollerObject.currentXOffset0+=obj.offsetWidth;
                currentDiv.removeChild(obj);
                obj=currentDiv.firstChild;
        }
} // we prepared DIV 0 for the next cycle
scrollerObject.inInternalScroller=false;
}

function scroller(objects, direction, pixelLeft, pixelTop, pixelWidth, pixelHeight, speed, zIndex) {

        var scrollerObject, i, name1, name2, intervalTime, pixelMove, mrq, innerw, innerh, innerx, innery, currentxpos, obj, obj0, obj1;

        if (typeof(objects)=="undefined") return null;
        if (objects==null) return null;
        if (objects.length==0) return null;
        if (pixelWidth<=0) return null;
        if (pixelHeight<=0) return null;
        if (typeof(zIndex)!="number")
                zIndex=1;

        if (typeof(scrollerIdNum) == "undefined")
                scrollerIdNum=0;
        else
                scrollerIdNum++;

        scrollerObjects[scrollerIdNum]=new Object();

        if (direction!="horizontal") {
                alert("Method "+direction+" not supported");
                return;
        }

        // we create the basic div element
        scrollerObjects[scrollerIdNum].div=createBasicDiv(pixelLeft, pixelTop, pixelWidth, pixelHeight);
        scrollerObject=scrollerObjects[scrollerIdNum];
        scrollerObjects[scrollerIdNum].id=myUniqueId();
        scrollerObjects[scrollerIdNum].name=scrollerObjects[scrollerIdNum].id;

        // we create two div elements for alternate showing
        scrollerObjects[scrollerIdNum].div0=document.createElement("DIV");
        scrollerObjects[scrollerIdNum].div0.id="scrollerDiv"+scrollerIdNum+"_0";
        document.body.appendChild(scrollerObjects[scrollerIdNum].div0);

        scrollerObjects[scrollerIdNum].div1=document.createElement("DIV");
        scrollerObjects[scrollerIdNum].div1.id="scrollerDiv"+scrollerIdNum+"_1";
        document.body.appendChild(scrollerObjects[scrollerIdNum].div1);

        scrollerObjects[scrollerIdNum].div0.backgroundColor=document.body.style.backgroundColor;
        scrollerObjects[scrollerIdNum].div1.backgroundColor=document.body.style.backgroundColor;
        //scrollerObjects[scrollerIdNum].div0.style.position="absolute";
        scrollerObjects[scrollerIdNum].div0.style.position="absolute";
        scrollerObjects[scrollerIdNum].div1.style.position="absolute";
        scrollerObjects[scrollerIdNum].div0.style.overflow="hidden";
        scrollerObjects[scrollerIdNum].div1.style.overflow="hidden";
        scrollerObjects[scrollerIdNum].div0.style.zIndex=zIndex;
        scrollerObjects[scrollerIdNum].div1.style.zIndex=zIndex-1;
        scrollerObjects[scrollerIdNum].div0.style.width=pixelWidth+"px";
        scrollerObjects[scrollerIdNum].div1.style.width=pixelWidth+"px";
        scrollerObjects[scrollerIdNum].div0.style.height=pixelHeight+"px";
        scrollerObjects[scrollerIdNum].div1.style.height=pixelHeight+"px";
        scrollerObjects[scrollerIdNum].div0.style.left=(scrollerObjects[scrollerIdNum].div.offsetLeft+scrollerObjects[scrollerIdNum].div.offsetParent.offsetLeft)+"px";
        scrollerObjects[scrollerIdNum].div1.style.left=(scrollerObjects[scrollerIdNum].div.offsetLeft+scrollerObjects[scrollerIdNum].div.offsetParent.offsetLeft)+"px";
        scrollerObjects[scrollerIdNum].div0.style.top=(scrollerObjects[scrollerIdNum].div.offsetTop+scrollerObjects[scrollerIdNum].div.offsetParent.offsetTop)+"px";
        scrollerObjects[scrollerIdNum].div1.style.top=(scrollerObjects[scrollerIdNum].div.offsetTop+scrollerObjects[scrollerIdNum].div.offsetParent.offsetTop)+"px";

        scrollerObjects[scrollerIdNum].objects=objects; // make pointer to objects;

        scrollerObjects[scrollerIdNum].horizontal=true; // for now we only support horizontal
        scrollerObjects[scrollerIdNum].style=new Object();
        scrollerObjects[scrollerIdNum].style.left=pixelLeft+"px";
        scrollerObjects[scrollerIdNum].style.top=pixelTop+"px";
        scrollerObjects[scrollerIdNum].style.width=pixelWidth+"px";
        scrollerObjects[scrollerIdNum].style.height=pixelHeight+"px";
        scrollerObject.style.zIndex=zIndex;

        scrollerObjects[scrollerIdNum].currentObjectIndex0=0;
        scrollerObjects[scrollerIdNum].currentObjectIndex1=0;

        scrollerObject=scrollerObjects[scrollerIdNum];

        if (speed=="undefined") {
                pixelMove=5;
                intervalTime=100; }
        else {
                pixelMove=Math.round(speed/25);
                if (pixelMove<1)
                        pixelMove=1;
                pixelMove=2;
                intervalTime=Math.round(speed/pixelMove);
                intervalTime=20;
                scrollerObjects[scrollerIdNum].intervalTime=intervalTime;
                scrollerObjects[scrollerIdNum].pixelMove=pixelMove;
        }

        scrollerObject.currentDivIndex=0; // this is the one we're going to show first
        // we append one object to each DIV for initialization;
        obj=objects[0];
        obj0=obj.cloneNode(true);
        obj1=obj.cloneNode(true);
        scrollerObjects[scrollerIdNum].div0.appendChild(obj0);
        scrollerObjects[scrollerIdNum].div1.appendChild(obj1);
        obj0.name="object0";
        obj1.name="object1";
        obj0.style.position="absolute";
        obj1.style.position="absolute";
        obj0.style.zIndex=zIndex;
        obj1.style.zIndex=zIndex-1;
        scrollerObjects[scrollerIdNum].currentXOffset0=0;
        scrollerObjects[scrollerIdNum].currentXOffset1=pixelMove; // it is moved one pixelmove
        scrollerObjects[scrollerIdNum].pixelMove2=2*pixelMove; // each DIV moves twice the number we want to see

        scrollerObjects[scrollerIdNum].inInternalScroller=false;
        internalScrollerFunc(scrollerIdNum);
        scrollerTimer=window.setInterval("internalScrollerFunc("+scrollerIdNum+")", intervalTime);
        return scrollerObjects[scrollerIdNum];
} // end of function scroller