var IEbrowser = /*@cc_on!@*/false;

function eid(id){
  var element = document.getElementById(id);
  return element;
}

function v(id){
  var elementval = document.getElementById(id).value;
  return elementval;
}

function iframeHeight(iframeid){
  var the_height=document.getElementById(iframeid).contentWindow.document.body.scrollHeight;
  if( the_height < 400 ){
    document.getElementById(iframeid).style.height=400;
  }else{
    document.getElementById(iframeid).style.height=the_height+50;
  }
}

function sendUrl(url) {
    var http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    http_request.open('GET', url+(url.indexOf("?")>0 ? "&"+new Date().getTime() : "?"+new Date().getTime()), true);
    http_request.send(null);

}

function displaySwitch(id){
  if( document.getElementById(id).style.display=='block' ){
    document.getElementById(id).style.display='none'
  }else{
    document.getElementById(id).style.display='block'
  }
}



function smiley(myField,myValue) {
  myField = eid(myField);

  //IE support
  if (document.selection) {
    myField.focus();
		theSelection = document.selection.createRange();
		document.selection.createRange().text = ' ' + myValue + ' ' + theSelection.text;
    theSelection.moveStart('character',myValue.lenght + 2);
    theSelection.moveEnd('character',myValue.lenght + 2);

  //MOZILLA/NETSCAPE support
  } else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos) + ' ' + myValue + ' ' + myField.value.substring(myField.selectionStart, myField.selectionEnd) + myField.value.substring(endPos, myField.value.length);
    myField.selectionStart = endPos + myValue.length + 2;
    myField.selectionEnd = endPos + myValue.length + 2;
    myField.focus();

  } else {
    myField.value += ' ' + myValue + ' ';
  }

}


function insertAtCursor(myField, myValue1, myValue2) {
  myField = eid(myField);

  //IE support
  if (document.selection) {
    myField.focus();
		theSelection = document.selection.createRange();
		document.selection.createRange().text = myValue1 + theSelection.text + myValue2;
    theSelection.moveStart('character',myValue1.lenght);
    theSelection.moveEnd('character',myValue1.lenght);

  //MOZILLA/NETSCAPE support
  } else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
    + myValue1 + myField.value.substring(myField.selectionStart, myField.selectionEnd)
    + myValue2 +myField.value.substring(endPos, myField.value.length);
    myField.selectionStart = startPos + myValue1.length;
    myField.selectionEnd = startPos + myValue1.length;
    myField.focus();

  } else {
    myField.value += myValue1+myValue2;
  }

}

// Form submitter on enter
function submitenter(myfield,e){
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;
  if( keycode == 13 ){
    myfield.form.submit();
    return false;
  }else
    return true;
}

function inputboxLayoutFocus(field,new_class,default_textid){
  field.className = new_class;
  if( field.value==eid(default_textid).value ){
    field.value = '';
  }
}
function inputboxLayoutBlur(field,org_class,default_textid,def_color){
  field.className = org_class;
  if( field.value=='' ){
    field.value = eid(default_textid).value;
    field.style.color = def_color;
  }
  if( field.value==eid(default_textid).value ){
    field.style.color = def_color;
  }
}
function selectboxLayoutFocus(field,new_class){
  field.className = new_class;
}
function selectboxLayoutBlur(field,org_class,def_color){
  field.className = org_class;
  if( field.value=='' ){
    field.style.color = def_color;
  }
}


// Hints
var horizontal_offset="5px" //horizontal offset of hint box from anchor link
var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all
function getposOffset(what, offsettype){
  var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
  var parentEl=what.offsetParent;
  while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
  }
  return totaloffset;
}
function iecompattest(){
  return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function clearbrowseredge(obj, whichedge){
  var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
  if (whichedge=="rightedge"){
    var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
    dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
      edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
  }else{
    var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
    dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
      edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
  }
  return edgeoffset
}
function showhint(menucontents, obj, e, tipwidth){
  var IE = document.all?true:false
  // If NS -- that is, !IE -- then set up for mouse capture
  if (!IE) document.captureEvents(Event.MOUSEMOVE)
  // Temporary variables to hold mouse x-y pos.s
  var tempX = 0
  var tempY = 0
  // Main function to retrieve mouse x-y pos.s

  var tipwidth2 = tipwidth.replace('px','')

  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}

  if ((ie||ns6) && document.getElementById("hintbox")){
    dropmenuobj=document.getElementById("hintbox")
    dropmenuobj.innerHTML="<div>"+menucontents+"</div>"
    dropmenuobj.style.left=dropmenuobj.style.top=-500
    if (tipwidth!=""){
      dropmenuobj.widthobj=dropmenuobj.style
      dropmenuobj.widthobj.width=tipwidth
    }
    dropmenuobj.x=getposOffset(obj, "left")
    dropmenuobj.y=getposOffset(obj, "top")
//    dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
//    dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
//    dropmenuobj.style.left=dropmenuobj.x+5
//    dropmenuobj.style.top=dropmenuobj.y+20
    dropmenuobj.style.left=tempX-(tipwidth2/2)+20
    dropmenuobj.style.top=tempY+24
    dropmenuobj.style.zIndex="1960"
    dropmenuobj.style.visibility="visible"
    obj.onmouseout=hidetip
  }
}
function hidetip(e){
  dropmenuobj.style.visibility="hidden"
  dropmenuobj.style.left="-500px"
}
function createhintbox(){
  var divblock=document.createElement("div")
  divblock.setAttribute("id", "hintbox")
  document.body.appendChild(divblock)
}
if (window.addEventListener)
  window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
  window.attachEvent("onload", createhintbox)
else if (document.getElementById)
  window.onload=createhintbox


/***********************************************
* Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
* http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm
***********************************************/

var fadebgcolor="black"

////NO need to edit beyond here/////////////

var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers

var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all

function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}

var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2

if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')

if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}

fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
picobj.innerHTML=slideHTML
}


fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}

fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}


fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}

/***********************************************
* End image fader
***********************************************/

function rgb2hex(rgb) {
    if (rgb.substr(0, 1) === '#') {
        return rgb;
    }
    rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
    function hex(x) {
        x = parseInt(x).toString(16);
        if( x.length==1 ) x = '0' + x;
        return x;
    }
    return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}


