// CSS switching function based on browser

function switchCSS()
{		
	if (navigator.appName == "Netscape")
		{
		nsCSS = "<link rel='stylesheet' href='nd-ns.css' type='text/css' />";
		document.write(nsCSS);		
		}
	else
		{
		mainCSS = "<link rel='stylesheet' href='nd.css' type='text/css' />";
		document.write(mainCSS);
		}
}


// CSS switching function for long pages based on browser

function switchCSS2()
{		
	if (navigator.appName == "Netscape")
		{
		nsCSS = "<link rel='stylesheet' href='nd2-ns.css' type='text/css' />";
		document.write(nsCSS);		
		}
	else
		{
		mainCSS = "<link rel='stylesheet' href='nd2.css' type='text/css' />";
		document.write(mainCSS);
		}
}


// homepage event div swap timer activated on loading the page

var the_timeout;
function firstSwap()
{		
	clearTimeout(the_timeout);
	changeDiv("eventbox","hidden");
	changeDiv("secondevent","visible");
	the_timeout = setTimeout("secondSwap();",4000);
}

function secondSwap()
{
	clearTimeout(the_timeout);
	changeDiv("secondevent","hidden");
	changeDiv("eventbox","visible");
	the_timeout = setTimeout("firstSwap();",4000);
}

// eventbox pull down menu function

function pullDown(event_page)
{
	window.document.pulldownmenu.the_choice.selectedIndex = 0;
	window.open(event_page,"UpcomingEventsWindow","");
}


// for hiding and unhiding the popup menu divs

var div_array = new Array("docspop","custpop","newspop","prodpop","applpop","abuspop");

function hideAll()
{
	for (var loop=0; loop <div_array.length; loop++)
		{
		changeDiv(div_array[loop], "hidden");
		}
}
	
function changeDiv(the_div,the_change)
{

	if (document.all)
	
		{
		
		div_string = "window.document.all." + the_div;
		
		}
		
		else
		
		{
		
		div_string = "document.getElementById('" + the_div + "')";
		
		}		

	the_div = eval(div_string);
	if(the_div.style!=0){
		the_div.style.visibility = the_change;		
	}
	
}



// window open function for evalKit comparison chart

function ekwindow(url) 
{
	window.open(url,"evalKitChartWindow","toolbar=no,width=610,height=286,top=50,left=100,status=no,resize=no,menubar=no");
}


// window open function for Series 2000 System Configuration chart

function s2000window(url) 
{
	window.open(url,"s2000SysConfigWindow","toolbar=no,width=596,height=447,top=50,left=100,status=no,resize=no,menubar=no");
}

// window open function for Distributor List pages

function start(page) {
	window.open(page,"DistributorWindow","toolbar=no,width=300,height=450,top=50,left=400,menubar=no,scrollbars=yes,resizable=yes");
}

// form validator functions for Customer Support form

function pick(frm) 
{ 
if(frm.salesSupport[0].checked == true) 
{ 
return checkform(frm) 
} 
} 

function checkform(form) 

{

            var el = document.forms[0].elements["00N30000000eloV"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #1") ;

                        el.focus() ;						

                        return false; 

            }


            var el = document.forms[0].elements["00N30000000elod"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #2") ;

                        el.focus() ;

                        return false; 

            }


            var el = document.forms[0].elements["industry"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #3") ;

                        el.focus() ;

                        return false; 

            }
						 

            var el = document.forms[0].elements["00N30000000eloj"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #4") ;

                        el.focus() ;

                        return false; 

            }


            var el = document.forms[0].elements["00N30000000elpX"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #5") ;

                        el.focus() ;

                        return false; 

            }


            var el = document.forms[0].elements["00N30000000esSW"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #6") ;

                        el.focus() ;

                        return false; 

            }


            var el = document.forms[0].elements["00N30000000elqh"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #8") ;

                        el.focus() ;

                        return false; 

            }


            var el = document.forms[0].elements["00N30000000elrJ"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #9") ;

                        el.focus() ;

                        return false; 

            }


            var el = document.forms[0].elements["00N30000000elrI"];

            fee = el.options[el.selectedIndex].value;

            if (fee == 0) { 

                        alert("Please answer sales support question #10") ;

                        el.focus() ;

                        return false; 

            }


            return true;

}



// form validator functions for Tag-it membership form and Customer Support form

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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


// time function for home page

function timeStamper()
{
	var today=new Date();
	var theyear=today.getFullYear();
	var thedom=today.getDate();
	var thedow=today.getDay();
	if (thedow == 0)
		{
		thedow = "Nd.";
		}
		else
	if (thedow == 1)
		{
		thedow = "Pn.";
		}
		else
	if (thedow == 2)
		{
		thedow = "Wt.";
		}
		else
	if (thedow == 3)
		{
		thedow = "Sr.";
		}
		else
	if (thedow == 4)
		{
		thedow = "Czw.";
		}
		else
	if (thedow == 5)
		{
		thedow = "Pt.";
		}
		else
	if (thedow == 6)
		{
		thedow = "Sob.";
		}
		else
		{
		thedow = "The Rapture has happened!!";
		}
		
	var themonth=today.getMonth();
		if (themonth == 0)
		{
		themonth = "Styczen";
		}
		else
	if (themonth == 1)
		{
		themonth = "Luty";
		}
		else
	if (themonth == 2)
		{
		themonth = "Marzec";
		}
		else
	if (themonth == 3)
		{
		themonth = "Kwiecien";
		}
		else
	if (themonth == 4)
		{
		themonth = "Maj";
		}
		else
	if (themonth == 5)
		{
		themonth = "Czerwiec";
		}
		else
	if (themonth == 6)
		{
		themonth = "Lipiec";
		}
		else
	if (themonth == 7)
		{
		themonth = "Sierpien";
		}
		else
	if (themonth == 8)
		{
		themonth = "Wrzesien";
		}
		else
	if (themonth == 9)
		{
		themonth = "Pazdziernik";
		}
		else
	if (themonth == 10)
		{
		themonth = "Listopad";
		}
		else
	if (themonth == 11)
		{
		themonth = "Grudzien";
		}
	var wholedate=(thedow+" "+thedom+" "+themonth+", "+theyear);
	var userday;
	var usermonth;
	var hrs=today.getHours();
	var daysplit;
	if (hrs > 11)
		{
		daysplit = "pm";
		}
		else
		{
		daysplit = "am";
		}
	if (hrs > 12)
		{
		hrs = (hrs-12);
		}
	if (hrs == 0)
		{
		hrs = "12";
		}
		
	var mins=parseInt(today.getMinutes());
	if (mins == 0)
		{
		mins = "00"
		}
	if (mins == 1)
		{
		mins = "01"
		}
	if (mins == 2)
		{
		mins = "02"
		}
	if (mins == 3)
		{
		mins = "03"
		}
	if (mins == 4)
		{
		mins = "04"
		}
	if (mins == 5)
		{
		mins = "05"
		}
	if (mins == 6)
		{
		mins = "06"
		}
	if (mins == 7)
		{
		mins = "07"
		}
	if (mins == 8)
		{
		mins = "08"
		}
	if (mins == 9)
		{
		mins = "09"
		}
	var wholetime=(hrs+":"+mins+daysplit);
	window.document.write(wholedate);
}
