String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
function isNumeric(val){return(parseFloat(val,10)==(val*1));}

function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();};}}

function toggleDisplay(id){if(document.getElementById(id).style.display===''){document.getElementById(id).style.display='none';}else{document.getElementById(id).style.display='';}}

function replaceHtml(el,html){var oldEl=typeof el==="string"?document.getElementById(el):el;var newEl=oldEl.cloneNode(false);newEl.innerHTML=html;oldEl.parentNode.replaceChild(newEl,oldEl);return newEl;}

function clearDefault(el){if(el.defaultValue==el.value){el.value='';}}
function clickclear(a,b){if(a.value==b){a.value="";}}
function clickrecall(a,b){if(a.value.length===0){a.value=b;}}
function gotosite(site){if(site!==''){self.location.href=site;}}

function DisplayMail(Server,Login,Display){if((Display.length===0)||(Display.indexOf('@')+1)){document.write('<a href='+'"mai'+'lto:'+Login+'@'+Server+'">'+Login+'@'+Server+'<\/a>');}
else{document.write('<a href='+'"mai'+'lto:'+Login+'@'+Server+'">'+Display+'<\/a>');}}

function DisplayMail2(Server,Login,Display,Style){document.write('<a href='+'"mai'+'lto:'+Login+'@'+Server+'"');if(Style.length!==0){document.write(' class="'+Style+'"');}
document.write('>');if((Display.length===0)||(Display.indexOf('@')+1)){document.write(Login+'@'+Server);}
else{document.write(Display);}
document.write('<\/a>');}

function won(text) {window.status=text;}
function woff() {window.status='';}

function checkML(){var f=document.MLForm;var e=document.MLForm.elements;var l=document.MLForm.length;var re=new RegExp("^[0-9A-Z]+([-_.0-9A-Z])*@[0-9A-Z]+([-.][0-9A-Z]+)*[.][A-Z]{2,4}$","i");if(f.Subscriber.value.length===0){alert("Please enter your NAME.");f.Subscriber.focus();return false;}
if(f.Email.value.length===0){alert("Please enter your EMAIL ADDRESS.");f.Email.focus();return false;}
if(!re.test(f.Email.value)){alert("Please enter a valid EMAIL ADDRESS.");f.Email.focus();return false;}
return true;}

function showDiv(divList){var i=divList.split(",");for(a=0;a<i.length;a++){if(document.getElementById(i[a])!==null){if(document.getElementById(i[a]).style.display=='none'){document.getElementById(i[a]).style.display='';}}}}

function hideDiv(divList){var i=divList.split(",");for(a=0;a<i.length;a++){if(document.getElementById(i[a])!==null){if(document.getElementById(i[a]).style.display!='none'){document.getElementById(i[a]).style.display='none';}}}}

/* Submit Once form validation - Dynamic Drive (www.dynamicdrive.com)
http://www.dynamicdrive.com/dynamicindex11/submitonce.htm
Modified by SunStar Media (www.ssmedia.com)
<form method="POST" onsubmit="submitonce(this)">  */
function submitonce(theform){if(document.getElementById){for(i=0;i<theform.length;i++){var tempobj=theform.elements[i];if(tempobj.type){if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset"||tempobj.type.toLowerCase()=="button"){tempobj.disabled=true;}}}}}

/* "Accept terms" form submission - Dynamic Drive (www.dynamicdrive.com)
http://www.dynamicdrive.com/dynamicindex16/acceptterm.htm
Modified by SunStar Media (www.ssmedia.com)
<form name="agreeform" onsubmit="return defaultagree(this)">
<input name="IAgree" type="checkbox" onclick="agreesubmit(this)">I agree
<input type="submit" value="Submit!" disabled>  */
var checkobj;function agreesubmit(el){checkobj=el;if(document.all||document.getElementById){for(i=0;i<checkobj.form.length;i++){var tempobj=checkobj.form.elements[i];if(tempobj.type){if(tempobj.getAttribute('name')&&tempobj.type.toLowerCase()=="submit"){tempobj.disabled=!checkobj.checked;}}}}}


function defaultagree(el){if(!document.all&&!document.getElementById){if(window.checkobj&&checkobj.checked){return true;}
else{alert("Please read/accept terms to submit form.");return false;}}}

/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
* http://www.dynamicdrive.com/dynamicindex16/limitinput2.htm
***********************************************/
function textCounter(field,counter,maxlimit,linecounter){var fieldWidth=parseInt(field.offsetWidth,10);var charcnt=field.value.length;if(charcnt>maxlimit){field.value=field.value.substring(0,maxlimit);}
else{var percentage=parseInt(100-((maxlimit-charcnt)*100)/maxlimit,10);document.getElementById(counter).style.width=parseInt((fieldWidth*percentage)/100,10)+"px";document.getElementById(counter).innerHTML="&nbsp;Limit: "+percentage+"%";setcolor(document.getElementById(counter),percentage,"background-color");}}

function setcolor(obj,percentage,prop){obj.style[prop]="rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";}

/* <input onkeypress="return numbersonly(this, event);">
(optional) dec = field name to jump to when the . key is pressed  */
function numbersonly(myfield,e,dec){var key;var keychar;if(window.event){key=window.event.keyCode;}
else if(e){key=e.which;}
else{return true;}
keychar=String.fromCharCode(key);if((key===null)||(key===0)||(key==8)||(key==9)||(key==13)||(key==27)){return true;}
else if((("0123456789").indexOf(keychar)>-1)){return true;}
else if(dec&&(keychar==".")){myfield.form.elements[dec].focus();return false;}
else{return false;}}

function changeclass(idref,classname){var el=document.getElementById(idref);var attributeNode=el.getAttributeNode("class");if(attributeNode){attributeNode.value=classname;}
else{el.setAttribute("class",classname);}}

/*  http://www.onlinetools.org/articles/unobtrusivejavascript/cssjsseparation.html */
function jscss(a,o,c1,c2){switch(a){case'swap':o.className=!jscss('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);break;case'add':if(!jscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
break;case'remove':var rep=o.className.match(' '+c1)?' '+c1:c1;o.className=o.className.replace(rep,'');break;case'check':return new RegExp('\\b'+c1+'\\b').test(o.className);}}


/* http://www.hunlock.com/blogs/Snippets:_Howto_Grey-Out_The_Screen */

function grayOut(vis,options){var options=options||{};var zindex=options.zindex||50;var opacity=options.opacity||70;var opaque=(opacity/100);var bgcolor=options.bgcolor||'#000000';var dark=document.getElementById('darkenScreenObject');var pageWidth='100%';var pageHeight='100%';if(!dark){var tbody=document.getElementsByTagName("body")[0];var tnode=document.createElement('div');tnode.style.position='absolute';tnode.style.top='0px';tnode.style.left='0px';tnode.style.overflow='hidden';tnode.style.display='none';tnode.id='darkenScreenObject';tbody.appendChild(tnode);dark=document.getElementById('darkenScreenObject');}
if(vis){if(document.body&&(document.body.scrollWidth||document.body.scrollHeight)){pageWidth=document.body.scrollWidth+'px';pageHeight=document.body.scrollHeight+'px';}else if(document.body.offsetWidth){pageWidth=document.body.offsetWidth+'px';pageHeight=document.body.offsetHeight+'px';}
dark.style.opacity=opaque;dark.style.MozOpacity=opaque;dark.style.filter='alpha(opacity='+opacity+')';dark.style.zIndex=zindex;dark.style.backgroundColor=bgcolor;dark.style.width=pageWidth;dark.style.height=pageHeight;dark.style.display='block';}else{dark.style.display='none';}}


function findPosX(Elem){var obj=document.getElementById(Elem);var curleft=0;if(obj.offsetParent){while(1){curleft+=obj.offsetLeft;if(!obj.offsetParent){break;}
obj=obj.offsetParent;}}
else if(obj.x){curleft+=obj.x;}
return curleft;}

function findPosY(Elem){var obj=document.getElementById(Elem);var curtop=0;if(obj.offsetParent){while(1){curtop+=obj.offsetTop;if(!obj.offsetParent){break;}
obj=obj.offsetParent;}}
else if(obj.y){curtop+=obj.y;}
return curtop;}

/* http://www.quirksmode.org/js/cookies.html */
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(c.indexOf(nameEQ)===0){return c.substring(nameEQ.length,c.length);}}
return null;}

function createCookie(name,value,days){var expires="";if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString();}
document.cookie=name+"="+value+expires+"; path=/";}
function eraseCookie(name){createCookie(name,"",-1);}

function PopUpWindow(url,hWind,nWidth,nHeight,nScroll){var cToolBar='toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+nScroll+',resizable=0,width=" + nWidth + ",height='+nHeight;var popupwin=window.open(url,hWind,cToolBar);}

/* http://www.white-hat-web-design.co.uk/articles/js-fontsize.php
<a href="javascript:decreaseFontSize();">-</a> 
<a href="javascript:increaseFontSize();">+</a> */
var iMin=8;var iMax=18;function increaseFontSize(){var p=document.getElementsByTagName('p');var s=12;for(i=0;i<p.length;i++){if(p[i].style.fontSize){s=parseInt(p[i].style.fontSize.replace('px',''),10);}
if(s!=iMax){s+=1;}
p[i].style.fontSize=s+'px';}}
function decreaseFontSize(){var p=document.getElementsByTagName('p');var s=12;for(i=0;i<p.length;i++){if(p[i].style.fontSize){s=parseInt(p[i].style.fontSize.replace('px',''),10);}
if(s!=iMin){s-=1;}
p[i].style.fontSize=s+'px';}}
