var printing='Mon 18th Jun 07';
var program='Fri 12th Dec 08';

function getDateText()
{
	var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	var date = new Date();
	var day = date.getDate();
	var month = date.getMonth();
	var yy = date.getYear();
	var year = (yy < 1000) ? yy + 1900 : yy;	
	
	switch (day)
	{
		case 1: return (days[date.getDay()]+' '+day + "st " + months[month] + " " + year);
		case 2: return (days[date.getDay()]+' '+day + "nd " + months[month] + " " + year);
		case 3: return (days[date.getDay()]+' '+day + "rd " + months[month] + " " + year);
		case 21: return (days[date.getDay()]+' '+day + "st " + months[month] + " " + year);
		case 22: return (days[date.getDay()]+' '+day + "nd " + months[month] + " " + year);
		case 23: return (days[date.getDay()]+' '+day + "rd " + months[month] + " " + year);
		case 31: return (days[date.getDay()]+' '+day + "st " + months[month] + " " + year);
		default: return (days[date.getDay()]+' '+day + "th " + months[month] + " " + year);
	}  
}

function download(filelocal)
{
	var downloadText;
	
	downloadText='Terms & Conditions of Downloading Materials\n';
	downloadText+='\n';
	downloadText+='The downloads on this website are provided "as is" without warranties of any kind.\n'
	downloadText+='In no event will Company Dynamics Software be liable for any damages of any\n';
	downloadText+='kind to your hardware, peripherals or software programs as a result of the download\n';
	downloadText+='or use of this material.\n';
	downloadText+='\n';
	downloadText+='To use these materials, you must agree to the above terms and conditions.\n\n';
	downloadText+='To accept this agreement and proceed with the download, click "OK" or\n';
	downloadText+='click "Cancel" to decline.';

	if (confirm(downloadText))
  	  window.location=filelocal;
}

function GetUpdate(td, idx)
{	
	elm=document.getElementById(td);
	
	if (idx==1)
		elm.innerHTML='<a href="javascript:download('+"'"+'downloads/update.exe'+"'"+');" class="headnav">BW Program - '+program+'</a>';

	if (idx==2)
		elm.innerHTML='<a href="javascript:download('+"'"+'downloads/printing.exe'+"'"+');" class="headnav">BW Printing - '+printing+'</a>';
}

function SetStartFocus(id)
{
  document.getElementById(id).focus();
}

function loginKeyDown()
{
	var charCode=event.keyCode;
	
	if (charCode==13)
	{
		login();
	}
}

function login()
{
    var tr=document.getElementById('login_error');
	var usr=document.getElementById('username').value;	
	var pwd=document.getElementById('password').value;	
	
	if (usr=="customer" && pwd=="support")
	{
		tr.style.background='#FFFFFF';		
		
		content=document.getElementById('support').innerHTML;
		document.getElementById('login').innerHTML=content;
		document.getElementById('login').background=document.getElementById('support').background;		
	}	
	else
  		{ 	
			tr.style.background='#FF0000';
			
			if (usr!="customer")
			{
				document.getElementById("username").focus();			
			}
			else
				{
					document.getElementById("password").focus();
				}
		}
	return false;
}

function redirect(url, idx)
{
	if (idx==0) 
	  document.location=url;
	else setTimeout("redirect('"+url+"',0);",idx);
}

function disableSelection(target)
{
	if (typeof target.onselectstart!="undefined")
		target.onselectstart=function()	{return false}
	else if (typeof target.style.MozUserSelect!="undefined")
		target.style.MozUserSelect="none"
	else 
		target.onmousedown=function(){return false}
		
	target.style.cursor = "default"
}

function MM_swapImgRestore() { //v2.0

  if (document.MM_swapImgData != null)

    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)

      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];

}

 

function MM_preloadImages() { //v2.0

  if (document.images) {

    var imgFiles = MM_preloadImages.arguments;

    if (document.preloadArray==null) document.preloadArray = new Array();

    var i = document.preloadArray.length;

    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){

      preloadArray[i] = new Image;

      preloadArray[i++].src = imgFiles[j];

  } }

}

 

function MM_swapImage() { //v2.0

  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;

  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {

    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];

    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||

        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))

      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);

    obj = eval(objStr);

    if (obj != null) {

      swapArray[j++] = obj;

      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];

      obj.src = MM_swapImage.arguments[i+2];

  } }

  document.MM_swapImgData = swapArray; //used for restore

}
