function preloadImages() {
	if (document.images) {
		for (var i = 0; i < preloadImages.arguments.length; i++) {
			(new Image()).src = preloadImages.arguments[i];
		}
	}
}

/* ------- */

function dss_addLoadEvent(fn) {
  if(typeof(fn)!="function")return;
  var tempFunc=window.onload;
  window.onload=function() {
    if(typeof(tempFunc)=="function")tempFunc();
    fn();
  }
}

dss_addLoadEvent(function(){
  document.forms[0].onsubmit=function(){return true;}
});

dss_addLoadEvent(function(){
  var allowInputTypeChange = true;
  var fld1 = document.forms[0].field1;
  if(document.getElementById) {
    try { // to keep IE from showing errors.
      fld1.type = 'text';
      if(fld1.type == 'text') fld1.value = 'has這';
      else allowInputTypeChange = false;
    } catch(e) { allowInputTypeChange = false; }
  }
  if(allowInputTypeChange) {
    fld1.onfocus = function() {
      var tempVal = this.value; // NS6 fix.
      var iType = this.type; // Opera 7 fix.
      if(this.type != 'password') this.type = 'password';
      this.value = tempVal; // NS6 fix.
      if(this.value.toLowerCase()=='has這')
        this.value = '';
      if(window.opera && iType != 'password') this.focus();
    }
    fld1.onblur = function() {
      if(this.type == 'password')
      if(this.value=='' || this.value.toLowerCase()=='has這') {
        this.type = 'text';
        this.value = 'has這';
      }
    }
  }
});

function changeInputType(
  oldElm, // a reference to the input element
  iType, // value of the type property: 'text' or 'password'
  iValue, // the default value, set to 'password' in the demo
  blankValue, // true if the value should be empty, false otherwise
  noFocus) {  // set to true if the element should not be given focus
  if(!oldElm || !oldElm.parentNode || (iType.length<4) || 
    !document.getElementById || !document.createElement) return;
  var newElm = document.createElement('input');
  newElm.type = iType;
  if(oldElm.name) newElm.name = oldElm.name;
  if(oldElm.id) newElm.id = oldElm.id;
  if(oldElm.className) newElm.className = oldElm.className;
  if(oldElm.size) newElm.size = oldElm.size;
  if(oldElm.tabIndex) newElm.tabIndex = oldElm.tabIndex;
  if(oldElm.accessKey) newElm.accessKey = oldElm.accessKey;
  newElm.onfocus = function(){return function(){
    if(this.hasFocus) return;
    var newElm = changeInputType(this,'password',iValue,
      (this.value.toLowerCase()==iValue.toLowerCase())?true:false);
    if(newElm) newElm.hasFocus=true;
  }}();
  newElm.onblur = function(){return function(){
    if(this.hasFocus)
    if(this.value=='' || (this.value.toLowerCase()==iValue.toLowerCase())) {
      changeInputType(this,'text',iValue,false,true);
    }
  }}();
  newElm.hasFocus=false;
  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(!blankValue) newElm.value = iValue;
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm = newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}

dss_addLoadEvent(function(){
  var ua = navigator.userAgent.toLowerCase();
  if(!((ua.indexOf('konqueror')!=-1) && (document.all || 
    (ua.indexOf('khtml/3.4')!=-1))) && !(((ua.indexOf('safari')!=-1) && 
    !window.print) || (document.defaultCharset && !window.print))) {
      changeInputType(document.forms[0].pass,'text','has這',false,true);
  }
});

/* -------- */

 var imageTag = false;
  var theSelection = false;
  var clientPC = navigator.userAgent.toLowerCase(); // Get client info
  var clientVer = parseInt(navigator.appVersion); // Get browser version
  var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
  var is_nav  = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
  && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
  && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
  var is_win   = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
  var is_mac    = (clientPC.indexOf("mac")!=-1);
  bbcode = new Array();
  bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]');
  imageTag = false;
  
  
  // Replacement for arrayname.length property
  function getarraysize(thearray) {
  for (i = 0; i < thearray.length; i++) {
  if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
  return i;
  }
  return thearray.length;
  }
  
  // Replacement for arrayname.push(value) not implemented in IE until version 5.5
  // Appends element to the array
  function arraypush(thearray,value) {
  thearray[ getarraysize(thearray) ] = value;
  }
  
  // Replacement for arrayname.pop() not implemented in IE until version 5.5
  // Removes and returns the last element of an array
  function arraypop(thearray) {
  thearraysize = getarraysize(thearray);
  retval = thearray[thearraysize - 1];
  delete thearray[thearraysize - 1];
  return retval;
  }
  
  function checkForm() {
  formErrors = false;
  if (document.post.message.value.length < 2) {
  formErrors = empty_message;
  }
  if (formErrors) {
  alert(formErrors);
  return false;
  } else {
  if (document.post.quick_quote.checked) {
  document.post.message.value = last_message + '\n\n' + document.post.message.value;
  if (document.post.subject.value == '' && last_message_subject != '') document.post.subject.value = last_message_subject;
  }
  document.post.quick_quote.checked = false;
  if (screen && screen.width && screen.height) document.post.screen.value = screen.width + 'x' + screen.height;
  return true;
  }
  }
  
  function emoticon(text) {
  //text = ' ' + text + ' ';
  if (document.post.message.createTextRange && document.post.message.caretPos) {
  var caretPos = document.post.message.caretPos;
  caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  document.post.message.focus();
  } else if (document.post.message.selectionStart != undefined) {
  document.post.message.value = document.post.message.value.substring(0, document.post.message.selectionStart) + text + document.post.message.value.substring(document.post.message.selectionStart);
  document.post.message.focus();
  } else {
  document.post.message.value += text;
  document.post.message.focus();
  }
  }
  
  function bbfontstyle(bbopen, bbclose) {
  if (document.selection && document.selection.createRange && document.selection.createRange().text && document.post.message.value.indexOf(document.selection.createRange().text) != -1) {
  theSelection = document.selection.createRange().text;
  document.selection.createRange().text = bbopen + theSelection + bbclose;
  } else if (document.post.message.setSelectionRange && document.post.message.selectionStart != undefined && document.post.message.selectionEnd != undefined) {
  var selStart = document.post.message.selectionStart;
  var selEnd = document.post.message.selectionEnd
  var theSelection = document.post.message.value.substring(selStart, selEnd);
  document.post.message.value = document.post.message.value.substring(0, selStart) + bbopen + theSelection + bbclose + document.post.message.value.substring(selEnd);
  if (selStart < selEnd) document.post.message.setSelectionRange(selStart, selEnd + (bbopen+bbclose).length);
  } else if (document.post.message.caretPos) {
  var caretPos = document.post.message.caretPos;
  caretPos.text = bbopen + bbclose;
  } else {
  document.post.message.value += bbopen + bbclose;
  }
  document.post.message.focus();
  }
  
  function bbstyle(bbnumber) {
  
  donotinsert = false;
  theSelection = false;
  bblast = 0;
  
  if (bbnumber == -1) { // Close all open tags & default button names
  while (bbcode[0]) {
  butnumber = arraypop(bbcode) - 1;
  document.post.message.value += bbtags[butnumber + 1];
  buttext = eval('document.post.addbbcode' + butnumber + '.value');
  eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
  }
  imageTag = false; // All tags are closed including image tags :D
  document.post.message.focus();
  return;
  }
  
  if (document.selection && document.selection.createRange)
  theSelection = document.selection.createRange().text; // Get text selection
  
  if (theSelection && document.post.message.value.indexOf(document.selection.createRange().text) != -1) {
  // Add tags around selection
  document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
  document.post.message.focus();
  theSelection = '';
  return;
  } else if (document.post.message.setSelectionRange && document.post.message.selectionStart != undefined && document.post.message.selectionEnd != undefined && document.post.message.selectionStart < document.post.message.selectionEnd) {
  var selStart = document.post.message.selectionStart;
  var selEnd = document.post.message.selectionEnd
  var theSelection = document.post.message.value.substring(selStart, selEnd);
  document.post.message.value = document.post.message.value.substring(0, selStart) + bbtags[bbnumber] + theSelection + bbtags[bbnumber+1] + document.post.message.value.substring(selEnd);
  document.post.message.setSelectionRange(selStart, selEnd + (bbtags[bbnumber]+bbtags[bbnumber+1]).length);
  document.post.message.focus();
  theSelection = '';
  return;
  }
  
  // Find last occurance of an open tag the same as the one just clicked
  for (i = 0; i < bbcode.length; i++) {
  if (bbcode[i] == bbnumber+1) {
  bblast = i;
  donotinsert = true;
  }
  }
  
  if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
  while (bbcode[bblast]) {
  butnumber = arraypop(bbcode) - 1;
  document.post.message.value += bbtags[butnumber + 1];
  buttext = eval('document.post.addbbcode' + butnumber + '.value');
  eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
  imageTag = false;
  }
  document.post.message.focus();
  return;
  } else { // Open tags
  
  if (imageTag && (bbnumber != 14)) {		// Close image tag before adding another
  document.post.message.value += bbtags[15];
  lastValue = arraypop(bbcode) - 1;	// Remove the close image tag from the list
  document.post.addbbcode14.value = "Img";	// Return button back to normal state
  imageTag = false;
  }
  
  // Open tag
  document.post.message.value += bbtags[bbnumber];
  if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
  arraypush(bbcode,bbnumber+1);
  eval('document.post.addbbcode'+bbnumber+'.value += "*"');
  document.post.message.focus();
  return;
  }
  storeCaret(document.post.message);
  }
  
  // Insert at Claret position. Code from
  // http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
  function storeCaret(textEl) {
  if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
  }
  
  var selectedText = quoteAuthor = '';
  function quoteSelection() {
  theSelection = false;
  if (selectedText) theSelection = selectedText;
  else if (document.selection && document.selection.createRange) theSelection = document.selection.createRange().text; // Get text selection
  
  if (theSelection) {
  // Add tags around selection
  emoticon( (document.post.message.value ? '\n' : '') + '[quote' + (quoteAuthor ? '="' + quoteAuthor + '"' : '') + ']' + theSelection + '[/quote]\n');
  document.post.message.focus();
  selectedText = quoteAuthor = theSelection = '';
  return;
  } else {
  alert(no_text_selected);
  }
  }
  
	
function marquee(x,typ,p){
typ={
'up':[-1,'top','offsetHeight'],
'down':[1,'top','offsetHeight'],
'left':[-1,'left','offsetWidth'],
'right':[1,'left','offsetWidth']
}[typ];
var m=this,mOut,mIn,turlaj,T,i=typ[0],j=0,p=p||55; 
(mOut=document.getElementById(x)).onmouseover=function(){T=clearInterval(T)};
mOut.appendChild((mIn=mOut.childNodes)[0].cloneNode(1));
mOut.onmouseout=function(e){
e=e||event;e=e.toElement||e.relatedTarget;
if(e)do{if(e==this)return!1}while(e=e.parentNode)
T=setInterval(turlaj,p)
};
mOut=mIn[0][typ[2]];
turlaj=function(){
mIn[0].style[typ[1]]=(-2*i*(j+=i)<(i-1)*mOut?(j=(-i-1)/2*mOut+i):j)+'px';
mIn[1].style[typ[1]]=j+mOut+'px';
}
T=setInterval(turlaj,p);
}

/*
onl=window.onload||new Function;
onload=function(){ onl(); new marquee('partnerzy','up');
}
*/

/*

CUSTOM FORM ELEMENTS

Created by Ryan Fait
www.ryanfait.com

The only thing you need to change in this file is the following
variables: checkboxHeight, radioHeight and selectWidth.

Replace the first two numbers with the height of the checkbox and
radio button. The actual height of both the checkbox and radio
images should be 4 times the height of these two variables. The
selectWidth value should be the width of your select list image.

You may need to adjust your images a bit if there is a slight
vertical movement during the different stages of the button
activation.

Visit http://ryanfait.com/ for more information.

*/

var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "92";

/* No need to change anything after this */

//document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: 92px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } input.styled2 { display: none; } select.styled2 { position: relative; width: 40px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } select.styled3 { position: relative; width: 220px; opacity: 0; filter: alpha(opacity=0); z-index: 5; }</style>');

var Custom = {
	init: function() {
   	new marquee('partnerzy_l','up');
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;

				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				span[a].onmousedown = Custom.pushed;
				span[a].onmouseup = Custom.check;
				document.onmouseup = Custom.clear;
			}
		}
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "styled" || inputs[a].className == "styled2" || inputs[a].className == "styled3") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
							
				span[a] = document.createElement("span");
				if(inputs[a].className == "styled") {
				span[a].className = "select";
				}
				else 	if(inputs[a].className == "styled2")
				{ span[a].className = "select2"; } else
				{ span[a].className = "select3"; }
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose;
			}
		}
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}
window.onload = Custom.init;
