// JavaScript Document
<!---



//trim whitespace between words
function trimW(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}

//limit textarea lengths

function limitlenght(textarea,maxlen,displaylimit){
	var thearea=document.getElementById(textarea);
	var thedisplay=document.getElementById(displaylimit);

	if (thearea.value.length > maxlen){
	thearea.value=thearea.value.substring(0,maxlen);
	thedisplay.style.color='red';
	} else {
		thedisplay.innerHTML= maxlen - thearea.value.length;
		thedisplay.style.color='black';
	}
}

//fill in KEYWORD with orgname
function keyorg(org,key){
	var o=document.getElementById(org);
	var k=document.getElementById(key);
	var kv=k.innerHTML;
	if(o.value!=''){
		k.innerHTML=','+o.value+','+kv;	
	}
}

//hide and show details of forms
function showtable(spanid){
s=document.getElementById(spanid);
	if(s.style.visibility=='collapse'){
		s.style.visibility='visible';
	} else {
		s.style.visibility='collapse';
	}
}

//show other field
function show(other,abother){
var other=document.getElementById(other);
var ableother=document.getElementById(abother);

other.style.visibility='visible';
ableother.disabled=false;
}

//hide other field
function hide(other,disother){
var otherfield=document.getElementById(other);
var disableother=document.getElementById(disother);
otherfield.style.visibility='hidden';
//disableother.disabled=true;
disableother.value='';
}

//disable finish

function disablefinish(buttonid,checkid){
	button=document.getElementById(buttonid);
	check=document.getElementById(checkid);
	
	if(check.checked==true){
		button.disabled=false;	
	} 
	else {
		button.disabled=true;
	}
}

//disable upload if standard plan
function freeplan(splanid,upfield,logoreq,logotext,b1,b2,b3,bf1,bf2,bf3,tel21,tel22,tel23,fax1,fax2,fax3,prd,cod,hrs,pay,wc,alt1,alt2,alt3,alt4,alt5,alt6,altinfo,telf,faxf,prdf,codf,hrsf,payf,wcf,alt1f,alt2f,alt3f,alt4f,typemore1,typemore2,typemore3,altinfof,website,websitef,logof,fnamef){


//the standard plan radio
//if checked disable all logo fields, display red message and fade out logo text
var s=document.getElementById(splanid);
//the non standard plan radio
//if checked enable logo fiels, hide red message and unfade logo text
//var nons=document.getElementById(planid);


//the upload field

var uf=document.getElementById(upfield);

//the logorequired field

var lr=document.getElementById(logoreq);

//the logo text

var lt=document.getElementById(logotext);

//the message regarding logo


//the bold items
//if standard disable all bold and show message
var bld1=document.getElementById(b1);
var bld2=document.getElementById(b2);
var bld3=document.getElementById(b3);
//check to bold text 
var bldf1=document.getElementById(bf1);
var bldf2=document.getElementById(bf2);
var bldf3=document.getElementById(bf3);
//check to bold text when disabled

//telephone 2 and fax fields
var t1=document.getElementById(tel21);
var t2=document.getElementById(tel22);
var t3=document.getElementById(tel23);

var f1=document.getElementById(fax1);
var f2=document.getElementById(fax2);
var f3=document.getElementById(fax3);
//product and comp description fields
var pr=document.getElementById(prd);
var co=document.getElementById(cod);

//operating hours, payment, wheelchair fields
var hr=document.getElementById(hrs);
var pa=document.getElementById(pay);
var wch=document.getElementById(wc);

//contact info field
var a1=document.getElementById(alt1);
var a2=document.getElementById(alt2);
var a3=document.getElementById(alt3);
var a4=document.getElementById(alt4);
var a5=document.getElementById(alt5);
var a6=document.getElementById(alt6);

var altin=document.getElementById(altinfo);
var websitename=document.getElementById(website);
var websitefont=document.getElementById(websitef);

//the spans for label colours
//telephone 2 and fax fields
var t1f=document.getElementById(telf);

var f1f=document.getElementById(faxf);
//product and comp description fields
var prf=document.getElementById(prdf);
var cof=document.getElementById(codf);

//operating hours, payment, wheelchair fields
var hrf=document.getElementById(hrsf);
var paf=document.getElementById(payf);
var wchf=document.getElementById(wcf);

//contact info field
var a1f=document.getElementById(alt1f);
var a2f=document.getElementById(alt2f);
var a3f=document.getElementById(alt3f);
var a4f=document.getElementById(alt4f);
var typem1=document.getElementById(typemore1);
var typem2=document.getElementById(typemore2);
var typem3=document.getElementById(typemore3);

var altinf=document.getElementById(altinfof);

var needlogocolor=document.getElementById(logof);
//name
var fnameff=document.getElementById(fnamef);

if(s.checked==true){
		uf.disabled=true;
		lr.disabled=true;
		lt.style.color='#A3A3A3';
		bld1.disabled=true;
		bld2.disabled=true;
		bld3.disabled=true;
		bldf1.style.color='#A3A3A3';
		bldf2.style.color='#A3A3A3';
		bldf3.style.color='#A3A3A3';
		t1.disabled=true;
		t2.disabled=true;
		t3.disabled=true;
		f1.disabled=true;
		f2.disabled=true;
		f3.disabled=true;
		pr.disabled=true;
		co.disabled=true;
		hr.disabled=true;
		pa.disabled=true;
		wch.disabled=true;
		a1.disabled=true;
		a2.disabled=true;
		a3.disabled=true;
		a4.disabled=true;
		a5.disabled=true;
		a6.disabled=true;
		altin.disabled=true;
		websitename.disabled=true;
		t1f.style.color='#A3A3A3'
		f1f.style.color='#A3A3A3'
		prf.style.color='#A3A3A3'
		cof.style.color='#A3A3A3'
		hrf.style.color='#A3A3A3'
		paf.style.color='#A3A3A3'
		wchf.style.color='#A3A3A3'
		a1f.style.color='#A3A3A3'
		a2f.style.color='#A3A3A3'
		a3f.style.color='#A3A3A3'
		a4f.style.color='#A3A3A3'
		typem1.style.color='#A3A3A3'
		typem2.style.color='#A3A3A3'
		typem3.style.color='#A3A3A3'
		altinf.style.color='#A3A3A3'
		websitefont.style.color='#A3A3A3'
		needlogocolor.style.color='#A3A3A3'
		fnameff.style.color='#A3A3A3'


	} else {
		uf.disabled=false;
		lr.disabled=false;
		lt.style.color='black';
		bld1.disabled=false;
		bld2.disabled=false;
		bld3.disabled=false;
		bldf1.style.color='black';
		bldf2.style.color='black';
		bldf3.style.color='black';
		t1.disabled=false;
		t2.disabled=false;
		t3.disabled=false;
		f1.disabled=false;
		f2.disabled=false;
		f3.disabled=false;
		pr.disabled=false;
		co.disabled=false;
		hr.disabled=false;
		pa.disabled=false;
		wch.disabled=false;
		a1.disabled=false;
		a2.disabled=false;
		a3.disabled=false;
		a4.disabled=false;
		a5.disabled=false;
		a6.disabled=false;
		altin.disabled=false;
		websitename.disabled=false;




		t1f.style.color='#000000'
		f1f.style.color='#000000'
		prf.style.color='#000000'
		cof.style.color='#000000'
		hrf.style.color='#000000'
		paf.style.color='#000000'
		wchf.style.color='#000000'
		a1f.style.color='#000000'
		a2f.style.color='#000000'
		a3f.style.color='#000000'
		a4f.style.color='#000000'
		typem1.style.color='#000000'
		typem2.style.color='#000000'
		typem3.style.color='#000000'
		altinf.style.color='#000000'
		websitefont.style.color='#000000'
		needlogocolor.style.color='#000000'
		fnameff.style.color='#000000'
	}
}


//disable upload
function disableupload(){
var logochecked=document.getElementById('orglogorequired');
var upload=document.getElementById('orglogo');
var upfieldf=document.getElementById('uploadfield');

	if(logochecked.checked==true){
		upload.disabled=true;
		upfieldf.style.color='#A3A3A3';
	} else {
		upload.disabled=false;
		upfieldf.style.color='#000000';
	}
}
//bold unbold
//i need to practice for loops!!!
function boldaddress(bid1,bid2,bid3,bid4,bid5){
	var bolditem1=document.getElementById(bid1);
	var bolditem2=document.getElementById(bid2);
	var bolditem3=document.getElementById(bid3);
	var bolditem4=document.getElementById(bid4);
	var bolditem5=document.getElementById(bid5);

	if (bolditem1.style.fontWeight=='normal'){
		bolditem1.style.fontWeight='bold';
	} else {
			bolditem1.style.fontWeight='normal';
		}
	if (bolditem2.style.fontWeight=='normal'){
		bolditem2.style.fontWeight='bold';
	} else {
			bolditem2.style.fontWeight='normal';
		}
	if (bolditem3.style.fontWeight=='normal'){
		bolditem3.style.fontWeight='bold';
	} else {
			bolditem3.style.fontWeight='normal';
		}
	if (bolditem4.style.fontWeight=='normal'){
		bolditem4.style.fontWeight='bold';
	} else {
			bolditem4.style.fontWeight='normal';
		}
	if (bolditem5.style.fontWeight=='normal'){
		bolditem5.style.fontWeight='bold';
	} else {
			bolditem5.style.fontWeight='normal';
		}
}


function boldit(bid0){
	bolditem=document.getElementById(bid0);
	if (bolditem.style.fontWeight=='normal'){
		bolditem.style.fontWeight='bold';
	} else {
			bolditem.style.fontWeight='normal';
		}
}

function bolditall(bid1,bid2){
	b1=document.getElementById(bid1);
	b2=document.getElementById(bid2);
	
	if (b1.style.fontWeight=='normal'){
		b1.style.fontWeight='bold';
	} else {
			b1.style.fontWeight='normal';
		}
	if (b2.style.fontWeight=='normal'){
		b2.style.fontWeight='bold';
	} else {
			b2.style.fontWeight='normal';
		}

}






//disable right-click
//document.oncontextmenu=new Function("return false")

//hide and show stuff in a div or a span ///
function showItems(thing){
	thing=document.getElementById(thing);
	if (thing.style.display == "none"){
		thing.style.display = "";
	}
	else{
		thing.style.display = "none";
	}
}

//popup
//FULL SCREEN POPUPS
winWidth = 400; // sets a default width for browsers who do not understand screen.width below
winheight = 400; // ditto for height

if (screen){ // weeds out older browsers who do not understand screen.width/screen.height
   winWidth = screen.width;
   winHeight = screen.height;
}
	
// this function calls a popupWindow where
// win is the page address i.e. '../page.html'

function popupDetails(name){
	
	newWindow = window.open(name,'newWin','toolbar=no,location=yes,scrollbars=yes,resizable=yes,width=975,height=777,left=350,top=50');
	newWindow.focus();
}

function popupListing2(list){
	
	newWindow = window.open(list,'newWin','toolbar=no,location=yes,scrollbars=yes,resizable=yes,width=975,height=800,left=350,top=50');
	newWindow.focus();
}
function popupListing(list){
	
	newWindow = window.open(list,'newWin','toolbar=no,location=yes,scrollbars=yes,resizable=yes,width=975,height=800,left=350,top=50');
	newWindow.focus();
}

function openPostList(win){
	
//	newWindow = window.open(win,'newWin','toolbar=no,location=no,scrollbars=yes,resizable=yes,width='+winWidth+',height='+winHeight+',left=0,top=0');
	newWindow = window.open(win,'newWin','');
	newWindow.focus();
}

function popupWindow(win){
	
	newWindow = window.open(win,'newWin','toolbar=no,location=no,scrollbars=yes,resizable=yes,width='+winWidth+',height='+winHeight+',left=0,top=0');
	newWindow.focus();
}
function popmailinglist(win){
	
	newWindow = window.open(win,'newWin','toolbar=no,location=no,scrollbars=yes,resizable=no,width=310,height=220,left=400,top=300');
	newWindow.focus();
}
// PopUps

function customPopup(url, features) {
	poper=window.open(url, '', features);
	poper.focus();
}

//hide emails
// uids
var info='info';
var sales='sales';
var service='service';
var hr='hr';
//...you get the idea
//common bits of email adds
var at='@';
var domain='domainname';
var dot=".";
var extension="com";

// now add them up to get the email addresses
var eminfo=info+at+domain+dot+extension;
var emsales=sales+at+domain+dot+extension;
var emservice=service+at+domain+dot+extension;
var emhr=hr+at+domain+dot+extension;

//open link in main window and close popus
function linkOpen(theURL) {
		window.opener.parent.location=theURL;
		window.close();
  }

//TO CHANGE MAXLENGHT ON CREDIT CARD NUMBER INPUT

function creditCheck() {
	document.getElementById('cardNumber').maxLength='16';
	if(document.getElementById('ccRadioAmex').checked==true) {
		document.getElementById('cardNumber').value=document.getElementById('cardNumber').value.substr( 0, 15 );
		document.getElementById('cardNumber').maxLength='15';
	}
}

//TO CHANGE MAXLENGHT ON CREDIT CARD SECURITY NUMBER INPUT

function securityDigitCheck() {
	document.getElementById('securityNumber').maxLength='4';
	if(document.getElementById('ccRadioAmex').checked!=true) {
		document.getElementById('securityNumber').value=document.getElementById('securityNumber').value.substr( 0, 3 );
		document.getElementById('securityNumber').maxLength='3';
	}
}


//TO HIDE AND SHOW NEWS ITEM CONTENTS---NEEDS WORK FOR MULTIPLE BROWSER SUPPORT

function showNewsItemFullContent(fullContent)
{
fullContent=document.getElementById(fullContent);
if (fullContent.style.display == "none")
{
fullContent.style.display = "";
}
else
{
fullContent.style.display = "none";
}
}
//TO HIDE AND SHOW MENU ITEMS---NEEDS WORK FOR MULTIPLE BROWSER SUPPORT

function showSubMenus(subMenu)
{
subMenu=document.getElementById(subMenu);
if (subMenu.style.display == "none")
{
subMenu.style.display = "";
}
else
{
subMenu.style.display = "none";
}
}
//TO HIDE AND SHOW MENU ITEMS SELECTIVELY!!!!---NEEDS WORK FOR MULTIPLE BROWSER SUPPORT

function showSubSections(subMenu)
{
subMenu=document.getElementById(subMenu);
if (subMenu.style.display == "none")
{
subMenu.style.display = "";
}
else
{
subMenu.style.display = "none";
}
}

<!-- To hide and show Payment Method Options May Need Work for multi-browser support -->
var currentPay;
function showPayOps(pay){
        if (currentPay != null) {
		hidePay();
	}
	document.getElementById('payMethod'+pay).style.display = '';
	currentPay = pay;
	return false;
}
function hidePay(){
	document.getElementById('payMethod'+currentPay).style.display = 'none';
}

<!-- To hide and show Payment Method RADIO Options May Need Work for multi-browser support -->
var currentRad;
function hideRads(rad){
              if (currentRad != null) {
		showRad();
	}
	document.getElementById('radio'+rad).style.display = 'none';
	currentRad = rad;
}
function showRad(){
	document.getElementById('radio'+currentRad).style.display = '';
}

<!-- change the source of the iframe -->
function changeSource(source) {
document.getElementById('theIframe').src=source
}

<!-- change the source of the main iframe-->
function changeIframeSource(source) {
parent.document.getElementById('mainframe').src=source
}

<!--  jump menu -->
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

<!-- To hide and show sub menu items May Need Work for multi-browser support -->
var currentSubMenu;
function showSubMenu(subMenuNum){
              if (currentSubMenu != null) {
		hideSubMenus();
	}
	document.getElementById('subMenu'+subMenuNum).style.display = '';
	currentSubMenu = subMenuNum;
	setLooks(subMenuNum);
}
function hideSubMenus(){
	document.getElementById('subMenu'+currentSubMenu).style.display = 'none';
	document.getElementById('topMenu'+currentSubMenu).style.backgroundColor = '#ffffff';
	document.getElementById('topMenu'+currentSubMenu).style.color = '#CCCCCC';
}
function setLooks(topMenuNum){
	if(topMenuNum==currentSubMenu){
		document.getElementById('topMenu'+topMenuNum).style.backgroundColor = '#EAEAEA';
		document.getElementById('topMenu'+topMenuNum).style.color = '#000000';
	}else{
		document.getElementById('topMenu'+topMenuNum).style.backgroundColor = '#ffffff';
		document.getElementById('topMenu'+topMenuNum).style.color = '#CCCCCC';
	}
}
function hoverLook(topMenu){
	topMenu.style.backgroundColor = '#FF9900';
	topMenu.style.color = '#CCCCCC';
}

<!--  scroll stuff-- NEEDS A LOT OF WORK -->
var wx=new Array(),wy=new Array(),count=new Array()
var ex=new Array(),ey=new Array(),spd=new Array()
var step=new Array(),stepX=new Array(),stepY=new Array()
var mvFlag=new Array(),slideID=new Array()
function moveLayer(layName,startX,startY,endX,endY,speed,stpx){

  if(!mvFlag[layName]){
   if(document.layers)clearTimeout(slideID[layName])
    count[layName]=0
    var ofX=(endX-startX)
    var ofY=(endY-startY)
    step[layName]=stpx
    stepX[layName]=ofX/stpx
    stepY[layName]=ofY/stpx
    wx[layName]=startX
    wy[layName]=startY
    ex[layName]=endX
    ey[layName]=endY
    spd[layName]=speed
    mvFlag[layName]=true
  }
  if(mvFlag[layName]&&(count[layName]<=step[layName]-1)){
    count[layName]++
    wx[layName]+=stepX[layName]
    wy[layName]+=stepY[layName]
     if(document.getElementById){
      document.getElementById(layName).style.left=wx[layName]
      document.getElementById(layName).style.top=wy[layName]
    } else if(document.layers) {
      document.layers[layName].moveTo(wx[layName],wy[layName])
    } else if(document.all){
      document.all(layName).style.pixelLeft=wx[layName]
      document.all(layName).style.pixelTop=wy[layName]
    }
    if(document.layers)clearTimeout(slideID[layName])
    slideID[layName]
        =setTimeout('moveLayer("'+layName+'")',spd[layName])
  }else{
    wx[layName]=ex[layName]
    wy[layName]=ey[layName]
    clearTimeout(slideID[layName]);mvFlag[layName]=false
  }
}

function scrFirst(newsLay){
 moveLayer(newsLay,30,33,30,3,30,20);
}
function scrSecond(newsLay){
 moveLayer(newsLay,30,3,30,-33,30,20);
}

//-->