var DefaultMessageText=''

function UpdateMessage(MessageText) {
	document.getElementById('msgtext').firstChild.data = MessageText;
}
function DefaultMessage() {
	document.getElementById('msgtext').firstChild.data = " "+DefaultMessageText;
}
var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus) {
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";win=window.open(mypage,myname,settings);
	win.focus();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*
 * Original from: http://brainerror.net/scripts/javascript/blendtrans/demo.html
 *
 * Edits by ASC:
 *   - Removed unnecessary OO code that caused MSIE to choke
 *   - Added pause between setting bg image and setting opacity to zero to
 *     prevent MSIE image flash
 *   - Increased opacity check argument to 103 for completely smooth fade
 *
 */

//find next image
function nextImage(o) {
    do o = o.nextSibling;
    while(o && o.tagName != 'IMG');
    return o;
}

//find first image inside an element
function firstChildImage(o) {
    
    o = o.firstChild;
        
    while(o && o.tagName != 'IMG') {
        o = o.nextSibling;
    }
    
    return o;
}

//set the opacity of an element to a specified value
function setOpacity(obj, o) {

    obj.style.opacity = (o / 100);
    obj.style.MozOpacity = (o / 100);
    obj.style.KhtmlOpacity = (o / 100);
    obj.style.filter = 'alpha(opacity=' + o + ')';
}

//make image invisible and set next one as current image
function getNextImage(image) {
	
    if (next = nextImage(image)) {
	image.style.display = 'none';
	image.style.zIndex = 0;

	next.style.display = 'block';
	next.style.zIndex = 100;

    } else {
	//if there is not a next image, get the first image again
	next = firstChildImage(image.parentNode);
    }

    return next;
}

//set default values for parameters and starting image
function blendImages(id, speed, pause, caption) {

    if(speed == null) {
        speed = 30;
    }
    
    if(pause == null) {
        pause = 5000;
    }

    var blend = document.getElementById(id);

    var image = firstChildImage(blend);

    startBlending(image, speed, pause, caption);
}

//make image a block-element and set the caption
function startBlending(image, speed, pause, caption) {

    image.style.display = 'block';

    if(caption != null) {
	document.getElementById(caption).innerHTML = image.alt;
    }

    continueFadeImage(image, 0, speed, pause, caption);
}

// ASC: copied from http://www.sean.co.uk/a/webdesign/javascriptdelay.shtm
function pausecomp(millis) {
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); }
    while(curDate-date < millis);
} 

//set an increased opacity and check if the image is done blending
function continueFadeImage(image, opacity, speed, pause, caption) {

    opacity = opacity + 3;

    if (opacity < 103) {

	setTimeout(function() {fadeImage(image, opacity, speed, pause, caption)}, speed);

    } else {
	//if the image is done, set it to the background and make it transparent
	image.parentNode.style.backgroundImage = "url("+image.src+")";

	// ASC: pause 1sec here to prevent MSIE image flash ...
	var paws=pause-1000;
	if (paws < 0 ) {
		paws = 0;
	}
	pausecomp(1000);

	setOpacity(image,0);
	//get the next image and start blending it again
	image = getNextImage(image);
	setTimeout(function() {startBlending(image, speed, pause, caption)}, paws);		
    }
}

//set the opacity to a new value and continue the fading
function fadeImage(image, opacity, speed, pause, caption) {
    setOpacity(image,opacity);
    continueFadeImage(image, opacity, speed, pause, caption);
}
function initslideshow() {
       blendImages('slideshow', 100, 15000);
}
function strtolower_utf8($inputString) {
    $outputString    = utf8_decode($inputString);
    $outputString    = strtolower($outputString);
    $outputString    = utf8_encode($outputString);
    return $outputString;
}
function createXMLHttpRequest() {  
	var ua;  
	if(window.XMLHttpRequest) {  
		try {  
			ua = new XMLHttpRequest();  
		} 
		catch(e) {  
			ua = false;  
		}  
	} else if(window.ActiveXObject) {  
		try {  
			ua = new ActiveXObject("Microsoft.XMLHTTP");  
		}
		catch(e) {  
			ua = false;  
		}  
	}  
	return ua;  
}  

function sendRequest(frm, file) {  
	var rnd982g = Math.random();  
	var str = "";  
	if(str = getForm(frm)) {  
		req.open('GET', file+'?'+str+'&rnd982g='+rnd982g);  
		req.onreadystatechange = handleResponse;  
		req.send(null);  
	}  
	return false;  
}  
function handleResponse() {  
	if(req.readyState == 4) {  
		var response = req.responseText;  
		document.getElementById("quick_form").innerHTML = response;  
	}  
}  
function getForm(fobj) {  
	var str = "";  
	var ft = "";  
	var fv = "";  
	var fn = "";  
	var els = "";  
	for(var i = 0;i < fobj.elements.length;i++) {  
		els = fobj.elements[i];  
		ft = els.title;  
		fv = els.value;  
		fn = els.name;  
		switch(els.type) {  
			case "text":  
			case "hidden":  
			case "password":  
			case "textarea":  
			// is it a required field?  
			//if(encodeURI(ft) == "required" && encodeURI(fv).length < 1) {  
				//alert('\''+fn+'\' is a required field, please complete.');  
				//els.focus();  
				//return false;  
			//}  
				str += fn + "=" + encodeURI(fv) + "&";  
				break;   
	
			case "checkbox":  
			case "radio":  
				if(els.checked) str += fn + "=" + encodeURI(fv) + "&";  
				break;      
	 
			case "select-one":  
				str += fn + "=" +  
				els.options[els.selectedIndex].value + "&";  
				break;  
		} // switch  
	} // for  
	str = str.substr(0,(str.length - 1));  
	return str;  
}  