//******  Calendar Picker
// if two digit year input dates after this year considered 20 century.
var NUM_CENTYEAR = 30;
// is time input control required by default
var BUL_TIMECOMPONENT = false;
// are year scrolling buttons required by default
var BUL_YEARSCROLL = true;

var calendars = [];
var RE_NUM = /^\-?\d+$/;

function calendar1(obj_target) {

	// assigning methods
	this.gen_date = cal_gen_date1;
	this.gen_time = cal_gen_time1;
	this.gen_tsmp = cal_gen_tsmp1;
	this.prs_date = cal_prs_date1;
	this.prs_time = cal_prs_time1;
	this.prs_tsmp = cal_prs_tsmp1;
	this.popup    = cal_popup1;

	// validate input parameters
	if (!obj_target)
		return cal_error("Error calling the calendar: no target control specified");
	if (obj_target.value == null)
		return cal_error("Error calling the calendar: parameter specified is not valid target control");
	this.target = obj_target;
	this.time_comp = BUL_TIMECOMPONENT;
	this.year_scroll = BUL_YEARSCROLL;
	
	// register in global collections
	this.id = calendars.length;
	calendars[this.id] = this;
}

function cal_popup1 (str_datetime) {
	if (str_datetime)
		this.dt_current = this.prs_tsmp(str_datetime);
	else 
		this.dt_selected = this.dt_current = this.prs_tsmp(this.target.value);

	if (!this.dt_current) return;

	var obj_calwindow = window.open(
		'calendar.html?id=' + this.id + '&s=' + this.dt_selected.valueOf() + '&c=' + this.dt_current.valueOf(),
		'Calendar', 'width=200,height=' + (this.time_comp ? 215 : 190) +
		',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes'
	);
	obj_calwindow.opener = window;
	obj_calwindow.focus();
}

// timestamp generating function
function cal_gen_tsmp1 (dt_datetime) {
	return(this.gen_date(dt_datetime) + ' ' + this.gen_time(dt_datetime));
}

// date generating function
function cal_gen_date1 (dt_datetime) {
	return (
		(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "-"
		+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "-"
		+ dt_datetime.getFullYear()
	);
}
// time generating function
function cal_gen_time1 (dt_datetime) {
	return (
		(dt_datetime.getHours() < 10 ? '0' : '') + dt_datetime.getHours() + ":"
		+ (dt_datetime.getMinutes() < 10 ? '0' : '') + (dt_datetime.getMinutes()) + ":"
		+ (dt_datetime.getSeconds() < 10 ? '0' : '') + (dt_datetime.getSeconds())
	);
}

// timestamp parsing function
function cal_prs_tsmp1 (str_datetime) {
	// if no parameter specified return current timestamp
	if (!str_datetime)
		return (new Date());

	// if positive integer treat as milliseconds from epoch
	if (RE_NUM.exec(str_datetime))
		return new Date(str_datetime);
		
	// else treat as date in string format
	var arr_datetime = str_datetime.split(' ');
	return this.prs_time(arr_datetime[1], this.prs_date(arr_datetime[0]));
}

// date parsing function
function cal_prs_date1 (str_date) {

	var arr_date = str_date.split('-');

	if (arr_date.length != 3) return cal_error ("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy.");
	if (!arr_date[0]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
	if (!RE_NUM.exec(arr_date[0])) return cal_error ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
	if (!arr_date[1]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
	if (!RE_NUM.exec(arr_date[1])) return cal_error ("Invalid month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
	if (!arr_date[2]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
	if (!RE_NUM.exec(arr_date[2])) return cal_error ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");

	var dt_date = new Date();
	dt_date.setDate(1);

	if (arr_date[1] < 1 || arr_date[1] > 12) return cal_error ("Invalid month value: '" + arr_date[1] + "'.\nAllowed range is 01-12.");
	dt_date.setMonth(arr_date[1]-1);
	 
	if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900);
	dt_date.setFullYear(arr_date[2]);

	var dt_numdays = new Date(arr_date[2], arr_date[1], 0);
	dt_date.setDate(arr_date[0]);
	if (dt_date.getMonth() != (arr_date[1]-1)) return cal_error ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+".");

	return (dt_date)
}

// time parsing function
function cal_prs_time1 (str_time, dt_date) {

	if (!dt_date) return null;
	var arr_time = String(str_time ? str_time : '').split(':');

	if (!arr_time[0]) dt_date.setHours(0);
	else if (RE_NUM.exec(arr_time[0]))
		if (arr_time[0] < 24) dt_date.setHours(arr_time[0]);
		else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed range is 00-23.");
	else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed values are unsigned integers.");
	
	if (!arr_time[1]) dt_date.setMinutes(0);
	else if (RE_NUM.exec(arr_time[1]))
		if (arr_time[1] < 60) dt_date.setMinutes(arr_time[1]);
		else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed range is 00-59.");
	else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed values are unsigned integers.");

	if (!arr_time[2]) dt_date.setSeconds(0);
	else if (RE_NUM.exec(arr_time[2]))
		if (arr_time[2] < 60) dt_date.setSeconds(arr_time[2]);
		else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed range is 00-59.");
	else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed values are unsigned integers.");

	dt_date.setMilliseconds(0);
	return dt_date;
}

function cal_error (str_message) {
	alert (str_message);
	return null;
}

//** Window Maximiser
function windowMax() {
window.moveTo(0,0);
window.resizeTo(screen.width,screen.height);
}




//** Fading Ad Popup window
var tmr;
var t;
var obj;

function fadingad() {
setTimeout('sFa()', 2000); 		// delay 2 seconds before opening
setTimeout('hFa()', 5000);	// delay 5 seconds before closing
}

function sFa() {
	obj = gObj();
	sLft();
	shw(true);
	t = 0;
	sTmr();
}

function hFa() {
	t = -100;
	sTmr();
	return false;
}

function sTmr() {
	tmr = setInterval("fd()",220);
}

function fd() {
	var amt = Math.abs(t+=10);
	if(amt == 0 || amt == 100) clearInterval(tmr);
	amt = (amt == 100)?99.999:amt;
  	
	obj.style.filter = "alpha(opacity:"+amt+")";
	obj.style.KHTMLOpacity = amt/100;
	obj.style.MozOpacity = amt/100;
	obj.style.opacity = amt/100;
	
	if(amt == 0) shw(false);
}

function sLft() {
	var w = 160;	// set this to 1/2 the width of the fa div defined in the style sheet 
			// there's not a reliable way to retrieve an element's width via javascript!!
					
	var l = (document.body.innerWidth)? document.body.innerWidth / 2:document.body.offsetWidth / 2;

	obj.style.left = (l - w)+"px";
}

function gObj() {
	return document.getElementById("fa");	
}

function shw(b) {
	(b)? obj.className = 'show':obj.className = '';	
}


//** Fading SLideshow

function tFader (a_items, a_tpl) {

	// validate parameters and set defaults
	if (!a_items) return alert("items structure is missing");
	if (typeof(a_items) != 'object') return alert("format of the items structure is incorrect");
	if (a_items[a_items.length - 1] == null) return alert("last element of the items structure is undefined");
	if (!a_tpl) a_tpl = [];
	for (var i = 0; i < A_TSLIDEDEFS.length; i += 2)
		if (a_tpl[A_TSLIDEDEFS[i]] == null)
			a_tpl[A_TSLIDEDEFS[i]] = A_TSLIDEDEFS[i + 1];

	// save config parameters in the slider object
	this.a_tpl   = a_tpl;
	this.a_items = a_tpl.random ? tslide_randomize(a_items) : a_items;

	// initialize parameters, assign methods	
	this.n_currentSlide = 0;
	this.f_goto  = tslide_goto;
	this.f_run   = function () { this.b_running = 1; this.f_goto(); };
	this.f_stop  = function () { this.b_running = 0; clearTimeout(this.o_timerS); };
	this.f_fadeIn  = tslide_fadeIn;
	this.f_fadeOut = tslide_fadeOut;
	this.f_slideOp = tslide_slideOp;

	// register in the global collection	
	if (!window.A_SLIDES)
		window.A_SLIDES = [];
	this.n_id = window.A_SLIDES.length;
	window.A_SLIDES[this.n_id] = this;

	// generate control's HTML
	var s_attributes = ' '
		+ (a_tpl['css']    ? ' class="'  + a_tpl['css']    + '"' : '')
		+ (a_tpl['width']  ? ' width="'  + a_tpl['width']  + '"' : '')
		+ (a_tpl['height'] ? ' height="' + a_tpl['height'] + '"' : '')
		+ (a_tpl['alt']    ? ' title="'  + a_tpl['alt']    + '" alt="' + a_tpl['alt'] + '"' : '');

	this.a_imgRefs = [];
	document.write ('<img src="', this.a_items[0] , '"', s_attributes, ' name="tslide', this.n_id, '_0" />');
	this.a_imgRefs[0] = document.images['tslide' + this.n_id + '_0'];
	this.n_currentSlide = 0;

	// exit on old browsers
	if (!this.a_imgRefs[0] || !this.a_imgRefs[0].style || this.a_imgRefs[0].style.marginLeft == null)
		return;

	for (var i = 1; i < this.a_items.length; i++) {
		document.write('<img src="', this.a_items[i] , '"', s_attributes, ' name="tslide', this.n_id, '_', i, '" style="position:relative;z-index:-1;filter:alpha(opacity=100);" />');
		this.a_imgRefs[i] = document.images['tslide' + this.n_id + '_' + i];
		this.a_imgRefs[i].style.marginLeft = '-' + this.a_tpl.width + 'px';
		this.f_slideOp(i, 0);
		this.a_imgRefs[i].style.zIndex = i;
	}

	// calculate transition variables
	this.n_timeDec = Math.round(this.a_tpl['transtime'] * 1e3 / this.a_tpl['steps']);
	this.n_opacDec = Math.round(100 / this.a_tpl['steps']);

	// run this sucker
	this.f_run();
}

function tslide_goto (n_slide, b_now) {

	// cancel any scheduled transitions	
	if (this.o_timerS) {
		clearTimeout(this.o_timerS);
		this.o_timerS = null;
		if (this.n_nextSlide) {
			this.f_slideOp(this.n_nextSlide, 0);
			this.n_nextSlide = null;
		}
	}

	// determine the next slide
	this.n_nextSlide = (n_slide == null ? this.n_currentSlide + 1 : n_slide) % this.a_items.length;
	if (this.n_nextSlide == this.n_currentSlide) return;
	
	// schedule transition
	this.o_timerS = setTimeout('A_SLIDES[' + this.n_id + '].f_fade' + (this.n_nextSlide > this.n_currentSlide ? 'In' : 'Out') + '()', (b_now ? 0 : this.a_tpl['slidetime'] * 1e3));
}

function tslide_fadeIn (n_opacity) {
	// new transition
	if (n_opacity == null) {
		n_opacity = 0;
	}
	n_opacity += this.n_opacDec;
	// end of transition
	if (n_opacity > 99) {
		this.f_slideOp(this.n_nextSlide, 99);
		this.f_slideOp(this.n_currentSlide, 0);
		this.n_currentSlide = this.n_nextSlide;
		this.n_nextSlide = null;
		return this.f_run();
	}
	// set transparency
	this.f_slideOp(this.n_nextSlide, n_opacity);

	// cycle
	this.o_timerT = setTimeout('A_SLIDES[' + this.n_id + '].f_fadeIn(' + n_opacity + ')', this.n_timeDec);
}
function tslide_fadeOut (n_opacity) {
	// new transition
	if (n_opacity == null) {
		n_opacity = 99;
		this.f_slideOp(this.n_nextSlide, 99);
	}
	n_opacity -= this.n_opacDec;
	// end of transition
	if (n_opacity < 0) {
		this.f_slideOp(this.n_currentSlide, 0);
		this.n_currentSlide = this.n_nextSlide;
		this.n_nextSlide = null;
		return this.f_run();
	}
	// set transparency
	this.f_slideOp(this.n_currentSlide, n_opacity);

	// cycle
	this.o_timerT = setTimeout('A_SLIDES[' + this.n_id + '].f_fadeOut(' + n_opacity + ')', this.n_timeDec);
}

function tslide_slideOp (n_slide, n_opacity) {
	if (!n_slide) return;
	var e_slide = this.a_imgRefs[n_slide];
	tslide_setOpacity(e_slide, n_opacity);
}

function tslide_randomize (a_source) {
	var n_index,
		a_items = [];
	while (a_source.length) {
		n_index = Math.ceil(Math.random() * a_source.length) - 1;
		a_items[a_items.length] = a_source[n_index];
		a_source[n_index] = a_source[a_source.length - 1];
		a_source.length = a_source.length - 1;
	}
	return a_items;
}

// cross-browser opacity
var s_uaApp  = navigator.userAgent.toLowerCase();
if (s_uaApp.indexOf('opera') != -1 || s_uaApp.indexOf('safari') != -1)
	window.tslide_setOpacity = function (e_element, n_opacity) {
		e_element.style.opacity = n_opacity / 100;
	};
else if (s_uaApp.indexOf('gecko') != -1)
	window.tslide_setOpacity = function (e_element, n_opacity) {
		e_element.style.MozOpacity = n_opacity / 100;
	};
else if (s_uaApp.indexOf('msie') != -1)
	window.tslide_setOpacity = function (e_element, n_opacity) {
		try { e_element.filters.alpha.opacity = n_opacity } catch (e) {};
	};
else
	window.tslide_setOpacity = null;

// defaults
var A_TSLIDEDEFS = [
	'steps', 40,
	'css', '',
	'transtime', 0.5,
	'slidetime', 2
];




//*** Form Validator/Checker 1

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);


  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}
function isEmpty(str){
  return (str == null) || (str.length == 0);
}
// returns true if the string is a valid email
function isEmail(str){
  if(isEmpty(str)) return false;
  var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
  return re.test(str);
}
// returns true if the string only contains characters A-Z or a-z
function isAlpha(str){
  var re = /[^a-zA-Z]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string only contains characters 0-9
function isNumeric(str){
  var re = /[\D]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string only contains characters A-Z, a-z or 0-9
function isAlphaNumeric(str){
  var re = /[^a-zA-Z0-9]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string's length equals "len"
function isLength(str, len){
  return str.length == len;
}
// returns true if the string's length is between "min" and "max"
function isLengthBetween(str, min, max){
  return (str.length >= min)&&(str.length <= max);
}
// returns true if the string is a US phone number formatted as...
// (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000
function isPhoneNumber(str){
  var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/
  return re.test(str);
}
// returns true if the string is a valid date formatted as...
// mm dd yyyy, mm/dd/yyyy, mm.dd.yyyy, mm-dd-yyyy
function isDate(str){
  var re = /^(\d{1,2})[\s\.\/-](\d{1,2})[\s\.\/-](\d{4})$/
  if (!re.test(str)) return false;
  var result = str.match(re);
  var y = parseInt(result[3]);
  var m = parseInt(result[1]);
  var d = parseInt(result[2]);
  if(m < 1 || m > 12 || y < 1900 || y > 2100) return false;
  if(m == 2){
          var days = ((y % 4) == 0) ? 29 : 28;
  }else if(m == 4 || m == 6 || m == 9 || m == 11){
          var days = 30;
  }else{
          var days = 31;
  }
  return (d >= 1 && d <= days);
}
// returns true if "str1" is the same as the "str2"
function isMatch(str1, str2){
  return str1 == str2;
}
// returns true if the string contains only whitespace
// cannot check a password type input for whitespace
function isWhitespace(str){ // NOT USED IN FORM VALIDATION
  var re = /[\S]/g
  if (re.test(str)) return false;
  return true;
}
// removes any whitespace from the string and returns the result
// the value of "replacement" will be used to replace the whitespace (optional)
function stripWhitespace(str, replacement){// NOT USED IN FORM VALIDATION
  if (replacement == null) replacement = '';
  var result = str;
  var re = /\s/g
  if(str.search(re) != -1){
    result = str.replace(re, replacement);
  }
  return result;
}



//** Form Validator/Checker 2
function checkThisForm(formname, submitbutton, errors) {
  if (errors == '') {
    eval(formname+'.'+submitbutton+'.disabled=true');
    //eval('document.'+formname+'.submit()');
    submitorder()
  } else {
    alert(errors);
  }
}
function checkText(formname, textboxname, displaytext) {
  var localerror = '';
//   nmcheck = document.bcardorder.name.value    
//   if (nmcheck.length <1) 
  if(Trim(eval('document.'+formname+'.'+textboxname+'.value'))=='') {
    localerror =  '- '+displaytext+' is Required.\n';
   

  } else localerror = '';
  return localerror;
}
function checkemailaddress(param, displaytext) {
var goodEmail = param.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
var localerror = '';
if (goodEmail){}
  else  localerror =  '- '+displaytext+' is not valid.\n';
  return localerror;
  }
function checkNum(formname, textboxname, displaytext) {
  var localerror = '';
  if(isNaN(eval('document.'+formname+'.'+textboxname+'.value'))) {
    localerror =  '- '+displaytext+' Should Be A Number With No Spaces.\n';
  } else localerror = '';
  return localerror;
}
function checkSpaces(formname, textboxname, displaytext) {
  var valid = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'; // define valid characters
  var localerror = '';
  if(!isValid(Trim(eval('document.'+formname+'.'+textboxname+'.value')), valid)) {
    localerror =  '- '+displaytext+' Should Not Contain Spaces.\n';
  } else localerror = '';
  return localerror;
}
function checkSelect(formname, selectboxname, displaytext) {
  var localerror = '';
  if(eval('document.'+formname+'.'+selectboxname+'.selectedIndex')==0) {
    localerror =  '- '+displaytext+' is Required.\n';
  } else localerror = '';
  return localerror;
}
function getRadio(formname, radioname, displaytext) {
  for (var i=0; i < eval('document.'+formname+'.'+radioname+'.length'); i++) {
    if (eval('document.'+formname+'.'+radioname+'[i].checked')) {
      var rad_val = eval('document.'+formname+'.'+radioname+'[i].value');
      return rad_val;
    }
  }
}
function checkRadio(formname, radioname, displaytext) {
  var localerror = '';
  var rad_val    = '';
  for (var i=0; i < eval('document.'+formname+'.'+radioname+'.length'); i++) { //check every radio button by that name
    if (eval('document.'+formname+'.'+radioname+'[i].checked'))  { //if it is checked
      rad_val += '-';
      }	else rad_val += '';
      }
    if (rad_val=='') {
      localerror =  '- '+displaytext+' is Required.\n';
    }
  return localerror;
}
function checkcheckbox(formname, boxname, displaytext) {
  var localerror = '';
     if (eval('document.'+formname+'.'+boxname+'.checked'))  {}
      else localerror =  '- '+displaytext+'\n';
      return localerror;
}

function autoComplete (field, select, property) {
/*onKeyUp="autoComplete(this,this.form.selectboxname,'value',false)" - add this to textbox where you are typing*/
  var found = false;
  for (var i = 0; i < select.options.length; i++) {
    if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
      found=true; break;
    }
  }
  if (found) {
    select.selectedIndex = i;
  } else {
    select.selectedIndex = -1;
  }
  if (field.createTextRange) {
    if (!found) {
      field.value=field.value.substring(0,field.value.length-1);
      return;
    }
    var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
    if (cursorKeys.indexOf(event.keyCode+";") == -1) {
      var r1 = field.createTextRange();
      var oldValue = r1.text;
      var newValue = found ? select.options[i][property] : oldValue;
      if (newValue != field.value) {
        field.value = newValue;
        var rNew = field.createTextRange();
        rNew.moveStart('character', oldValue.length) ;
        rNew.select();
      }
    }
  }
}

function Trim(s) {
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) {
    s = s.substring(1,s.length);
  }
  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')) {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function isValid(string,allowed) {
//  var valid = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; // define valid characters
    for (var i=0; i< string.length; i++) {
      if (allowed.indexOf(string.charAt(i)) == -1) return false;
    }
    return true;
}
function check(formname, submitbutton) {
  var errors = '';
  errors += checkText(formname, 'name', 'Name');
errors += checkText(formname, 'address', 'Delivery address');
  //errors += checkText(formname, 'emaddress', 'Email Address');
  errors += checkemailaddress(document.bcardorder.emaddress, 'Email Address');
  
  errors += checkcheckbox(formname, 'readartwork', 'Please read the art work requirements!');
  checkThisForm(formname, submitbutton, errors);
}



//**** Form Reset/Submit 3
//   param.focus()
//   param.select()
function resetmine(){
 document.bcardorder.mdate.value=customDateSpring(new Date())+showtime();
 document.bcardorder.name.value="";
document.bcardorder.firm.value="";
document.bcardorder.address.value="";
 document.bcardorder.emaddress.value="";
 document.bcardorder.delivery.value="";
document.bcardorder.special.checked=false;
document.bcardorder.samples.checked=false;
document.bcardorder.comment.value="";

 document.bcardorder.submitbutton.disabled = false;
} 
function submitorder(){
     alert("Please DO NOT forget to attach the artwork!");
      var embody = "Dear Sir,%0D%0A%0D%0A%0D%0AI would like to place an order for 1000 digitally printed business cards %0D%0A%0D%0A"+
      "%0D%0A     Date of order: "+document.bcardorder.mdate.value+
      "%0D%0A     Name: "+document.bcardorder.name.value+
"%0D%0A     Company: "+document.bcardorder.firm.value+
"%0D%0A     Delivery address: "+document.bcardorder.address.value+
      "%0D%0A     Email address: "+document.bcardorder.emaddress.value+
"%0D%0A     Comment: "+document.bcardorder.comment.value+
      "%0D%0A     Required by: "+document.bcardorder.delivery.value+
"%0D%0A     Artwork: "+document.bcardorder.artworksel.value;

if (document.bcardorder.special.checked) {embody+="%0D%0A%0D%0A%0D%0A     The cards are required for a special occasion!"}; 
if (document.bcardorder.samples.checked) {embody+="%0D%0A%0D%0A%0D%0A     Please supply me some digital print samples!"}; 
embody+="%0D%0A%0D%0A%0D%0A%0D%0A%0D%0AFaithfully yours,%0D%0A%0D%0A"+document.bcardorder.name.value;

      window.location = "mailto:admin@recordprinting.com.au?subject="+document.title+"&body="+embody //+"&attachment="+document.bcardorder.attFile.value;
	document.bcardorder.submitbutton.disabled=true     
}

/// aut check box
function changeBox(cbox) {
box = eval(cbox);
//box.checked = !box.checked;
box.checked=true;
}



//***** Blink Text
window.onerror = null;
 var bName = navigator.appName;
 var bVer = parseInt(navigator.appVersion);
 var NS4 = (bName == "Netscape" && bVer >= 4);
 var IE4 = (bName == "Microsoft Internet Explorer" 
 && bVer >= 4);
 var NS3 = (bName == "Netscape" && bVer < 4);
 var IE3 = (bName == "Microsoft Internet Explorer" 
 && bVer < 4);
 var blink_speed=100;
 var i=0;
 
if (NS4 || IE4) {
 if (navigator.appName == "Netscape") {
 layerStyleRef="layer.";
 layerRef="document.layers";
 styleSwitch="";
 }else{
 layerStyleRef="layer.style.";
 layerRef="document.all";
 styleSwitch=".style";
 }
}
function Blink(layerName){
 if (NS4 || IE4) { 
 if(i%2==0)
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="visible"');
 }
 else
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="hidden"');
 }
 } 
 if(i<1)
 {
 i++;
 } 
 else
 {
 i--
 }
 setTimeout("Blink('"+layerName+"')",blink_speed);
}



//***** Popup Window
function popupWin() {
text =  "<html>\n<head>\n<title>Record Printing Business Card Deal</title>\n<body>\n";
text += "<center>\n<br>";
text += "<a href='http://www.recordprinting.com.au' target='_blank'><h2>Record Printing</h2></a>";
text += "<img src='images/rpcard.jpg' alt='Contact Ken or order online!'/>";
text += "<h2>$99/1000 Business Cards</h2>";
text += "<img src='images/specialhands.jpg' alt='Do not miss this opportunity!!!'/>";
text += "<img src='images/rponline.jpg' alt='House of the $99/1000 Business Cards!!!'/>";
text += "</center>\n</body>\n</html>\n";
setTimeout('windowProp(text)', 2000); 		// delay 2 seconds before opening
}
function windowProp(text) {
newWindow = window.open('','newWin','width=400,height=700');

newWindow.document.write(text);
parent.focus()
//setTimeout('closeWin(newWindow)', 5000);	// delay 5 seconds before closing
}
function closeWin(newWindow) {
newWindow.close();				// close small window and depart
}





//***** StatusBar scroller
var osd ="WELCOME to the home of $99 Business Cards";
osd +="          ";
var timer;
var msg = "";
function scrollMaster () {
//msg = customDateSpring(new Date())
clearTimeout(timer)
//msg += " " + showtime() + " " + osd
msg += " " + " " + osd
for (var i= 0; i < 100; i++){
msg = " " + msg;}
scrollMe()
}
function scrollMe(){
window.status = msg;
msg = msg.substring(1, msg.length) + msg.substring(0,1);
timer = setTimeout("scrollMe()", 40);
}






//*****  Time&Date
function showtime (){
var now = new Date();
var hours= now.getHours();
var minutes= now.getMinutes();
var seconds= now.getSeconds();
var months= now.getMonth();
var dates= now.getDate();
var years= now.getYear();
var timeValue = ""
timeValue += ((months >9) ? "" : " ")
timeValue += ((dates >9) ? "" : " ")
timeValue = ( months +1)
timeValue +="/"+ dates
timeValue +="/"+  years
var ap="A.M."
if (hours == 12) {
ap = "P.M."
}
if (hours == 0) {
hours = 12
}
if(hours >= 13){
hours -= 12;
ap="P.M."
}
var timeValue2 = " " + hours
timeValue2 += ((minutes < 10) ? ":0":":") + minutes + " " + ap
return timeValue2;
}
function MakeArray(n) {
this.length = n
return this
}
monthNames = new MakeArray(12)
monthNames[1] = "Janurary"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"
daysNames = new MakeArray(7)
daysNames[1] = "Sunday"
daysNames[2] = "Monday"
daysNames[3] = "Tuesday"
daysNames[4] = "Wednesday"
daysNames[5] = "Thursday"
daysNames[6] = "Friday"
daysNames[7] = "Saturday"
function customDateSpring(oneDate) {
var theDay = daysNames[oneDate.getDay() +1]
var theDate =oneDate.getDate()
var theMonth = monthNames[oneDate.getMonth() +1]
var dayth="th"
if ((theDate == 1) || (theDate == 21) || (theDate == 31)) {
dayth="st";
}
if ((theDate == 2) || (theDate ==22)) {
dayth="nd";
}
if ((theDate== 3) || (theDate  == 23)) {
dayth="rd";
}
//return theDay + ", " + theMonth + " " + theDate + dayth + ","
return theDay + ", " + theDate + dayth + " "+theMonth + ","
}




//***** Rainbow Text
function toSpans(span) {
  var str=span.firstChild.data;
  var a=str.length;
  span.removeChild(span.firstChild);
  for(var i=0; i<a; i++) {
    var theSpan=document.createElement("SPAN");
    theSpan.appendChild(document.createTextNode(str.charAt(i)));
    span.appendChild(theSpan);
  }
}
function RainbowSpan(span, hue, deg, brt, spd, hspd) {
    this.deg=(deg==null?360:Math.abs(deg));
    this.hue=(hue==null?0:Math.abs(hue)%360);
    this.hspd=(hspd==null?3:Math.abs(hspd)%360);
    this.length=span.firstChild.data.length;
    this.span=span;
    this.speed=(spd==null?50:Math.abs(spd));
    this.hInc=this.deg/this.length;
    this.brt=(brt==null?255:Math.abs(brt)%256);
    this.timer=null;
    toSpans(span);
    this.moveRainbow();
}
RainbowSpan.prototype.moveRainbow = function() {
  if(this.hue>359) this.hue-=360;
  var color;
  var b=this.brt;
  var a=this.length;
  var h=this.hue;

  for(var i=0; i<a; i++) {

    if(h>359) h-=360;

    if(h<60) { color=Math.floor(((h)/60)*b); red=b;grn=color;blu=0; }
    else if(h<120) { color=Math.floor(((h-60)/60)*b); red=b-color;grn=b;blu=0; }
    else if(h<180) { color=Math.floor(((h-120)/60)*b); red=0;grn=b;blu=color; }
    else if(h<240) { color=Math.floor(((h-180)/60)*b); red=0;grn=b-color;blu=b; }
    else if(h<300) { color=Math.floor(((h-240)/60)*b); red=color;grn=0;blu=b; }
    else { color=Math.floor(((h-300)/60)*b); red=b;grn=0;blu=b-color; }

    h+=this.hInc;

    this.span.childNodes[i].style.color="rgb("+red+", "+grn+", "+blu+")";
  }
  this.hue+=this.hspd;
}



//**scrollMaser();
