
var isIE=document.all?true:false;
var OS='';
if (navigator.userAgent.indexOf("Windows NT 6.0") > -1) { OS='vista'; }// Windows vista 
var now   = new Date();
var year  = now.getYear();
if (year < 2000) year = year + 1900;

var randoms=1; //set random for page editor

function ryear(){ document.write(year); }
function onb(ref,clr) { ref.style.background=clr; }
function offb(ref,clr){ ref.style.background=clr; }
function on(ref,clr)  { ref.style.color=clr; }
function off(ref,clr) { ref.style.color=clr; }

function new1(w, h,title, ref){ window.open(ref,title,'width='+w+', height='+h+', toolbar=no, statusbar=no, menubar=no, copyhistory=no, status=no, resizable=yes, scrollbars=yes, location=no'); }
function wind(ref,title){ window.open(ref,title,'width=700, height=450, copyhistory=no, status=no, resizable=yes, scrollbars=yes'); }
function editor_html(objname,page) { showModalDialog(page, window, "resizable: yes; help: no; status: no; scroll: yes;"); }
function editor_html_modeless(objname,page) { showModelessDialog(page, window, "resizable: yes; help: no; status: no; scroll: yes;"); }

function email_address(name,website){
 var email_add="<a href='mailto:"+name+"&#64;"+website+"?subject="+website+"'>Click here</a>";
 if(name && website)return email_add; else return 'n/a';
}

///////// picture popup
function PopupPic(sPicURL,h,w) { window.open(sPicURL, "Image","resizable=1,HEIGHT="+h+",WIDTH="+w); }

/////////fit pic to screen center.............. onload='FitPic();'
var arrTemp=self.location.href.split("?");
var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
var NS = (navigator.appName=="Netscape")?true:false;

function FitPic()
{
 iWidth = (NS)?window.innerWidth:document.body.clientWidth;
 iHeight = (NS)?window.innerHeight:document.body.clientHeight;
 iWidth = document.images[0].width - iWidth;
 iHeight = document.images[0].height - iHeight;
 window.resizeBy(iWidth, iHeight);

 var winl = (screen.width-iWidth)/2;
 var wint = (screen.height-iHeight)/2;
 var winl = (screen.width-document.images[0].width)/2;
 var wint = (screen.height-document.images[0].height)/2;
 if (winl < 0) winl = 0;
 if (wint < 0) wint = 0;
 window.moveTo(winl, wint);		
       
 self.focus();
}

///////////////////////check popup first page must contain onLoad='checkPopUp();'
function checkPopUp()
{
 //knocked it out due to ie lockup 20080109
}
function checkPopUps()
{
 var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
 var popUpsBlocked;
 if(mine){ popUpsBlocked = false; mine.close() }
 else{ popUpsBlocked = true; }
 
 if(popUpsBlocked) alert('POPUP BLOCKER ACTIVE\n\nWe have detected that you are using popup blocking software.\n\nThis website needs to open a window to show messages, along with help menus...\n\nPlease disable your popup blocker.');
}
///////end popup blocker checker

//add an onload event 
//create a function and call it with the addLoadEvent handler  
 function addLoadEvent(func)
 {
  var oldonload = window.onload;   
  if (typeof window.onload != 'function'){ window.onload = func; }
  else{ window.onload = function() { if (oldonload) { oldonload(); } func(); } }   
 }   

////////////////////////////////////random images
//insert text in pages below
//<script>
// //set height and width if required or leave as default sizes
// if(document.random)randompics(0,0,'%%home%%/i','i_box.gif|i_cards.gif|i_cart.gif|i_edit.gif|i_email.gif|i_exit.gif');
//</script>

function pickRandom(range) 
{
 if (Math.random) return Math.round(Math.random() * (range-1));
 else
 {
  var now = new Date();
  return (now.getTime() / 1000) % range;
 } 
}

function randompics(h,w,imghome,images)
{
 var range=images.split('|');
 var choice = pickRandom(range.length);
 var imgh='',imgw='';
 if(h & w){ imgh='height='+h; var imgw='width='+w; }
 var text ='<img src="'+imghome+'/'+range[choice]+'" '+imgh+' '+imgw+' border=0>';
 document.write(text);
}
////////////////////////////end random pics

/////preload images
//eg: <script id=PreLoadImages> if(document.randoms)onLoad="MM_preloadImages('../i/on.gif','../i/off.gif');" </script>
function MM_preloadImages()
{
 var d=document;
 if(d.images)
 {
  if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
  for(i=0; i< a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i]; }
 }
}

///////////////////////////slider pics
var slider=1; //set slider for page editor
function sliderpics(imgslctn,barimages,barimgref,refhome,where)
{
 var text='';
  text+=' <script>\n';
  text+='  var images=new Array()\n';
  text+='  var imgref=new Array()\n';
  text+='  images="'+barimages+'".split("|"); \n';
  text+='  imgref="'+barimgref+'".split("|"); \n';
  text+=' var imggap="";    //(use HTML) default= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp"...overrides gapwidth\n';
  text+=' slideshow(imggap,"'+refhome+'","'+imgslctn+'",images,imgref);\n';
 //'+'"'+home+'/"'+
  text+='</script>\n';

 document.write(text);
}
////////////////////////////end slider pics

function loading(ref)
{
 document.write("<div id=fc_featured style='position:absolute; top:"+screenH/3+"; left:"+screenW/3+"; visibility:visible;' align=center><img src="+ref+"></div>");
}

function click() {
//  if (event.button==2) alert("Copyright ©1997 Auzform");
} document.onmousedown=click

function HelpWindow(doc){
  new_window = window.open(doc, 'help_window', 'left=50, top=100, width=280, height=320, resizable=yes, scrollbars=yes');
}
function BuyWindow(doc){
  new_window = window.open(doc, 'Buy_window', 'left=35, top=35, width=750, height=400, resizable=yes, scrollbars=yes, status=yes');
}
function PriceWindow(doc){
  new_window = window.open(doc, 'Price_window', 'left=100, top=50, width=600, height=400, resizable=yes, scrollbars=yes');
}

function checkdate(date){
 var days, day, month, year, temp;
 day   = date.substring(6,8);
 month = date.substring(4,6);
 year  = date.substring(0,4);

 if (year<1) year='2000';
 if (month<1 || month>12) month='01';
 if (day<1 || day>31) day='01';

 if (month==2){ if (isLeapYear(year)) days=29; else days=28; }
 else if (month==4 || month==6 || month==9 || month==11) days=30;
 else days=31;

 if (day>days) day=days;
 return(year+month+day);
}

function isLeapYear (Year) {
 if ((Year % 4)==0 && (Year % 100)!=0 || (Year % 400)==0) return (true);else return (false);
}

function convertdate(date){
 var days, day, month, year, temp;
 day=date.substring(0,2);
 month=date.substring(3,5);

 if(date.length==10) year=date.substring(6,10);
 else if(date.length==8) year=date.substring(6,8);

 if(date.length==8 && year>30) year='19'+year;
 else if(date.length==8 && year<30) year='20'+year;

 if (month==2){ if (isLeapYear(year)) days=29; else days=28; }
 else if (month==4 || month==6 || month==9 || month==11) days=30;
 else days=31;
 if (day>days) day=days;
 date=day+month+year;
 return(date);
}


function Format(total,decimals)
{
   if ( decimals==undefined ) decimals = 2;

   decimals *= 1;

   var suffix = ""
   for ( var i=0; i<decimals; i++ ) suffix += "0";

   var num = "" + parseFloat(total);
   if ( num == "NaN" ) return num = "0" + ((decimals>0) ? "."+suffix : "");

   if ( num.indexOf(".") == -1 ) return num += (decimals>0) ? "."+suffix : "";

   num += suffix;
   var tp = num.indexOf(".")+decimals;
   var rnd = Math.round(num.substring(tp,tp+1)+"."+num.substring(tp+1));

   return num.substring(0,tp)+rnd;
}

function trim(string) {
  var check="";
  for(n=1; n<=string.length; n++){
   if(string.substring(n-1, n)=='+'
      || string.substring(n-1, n)=='#'
      || string.substring(n-1, n)=='!'
      || string.substring(n-1, n)=='"'
      || string.substring(n-1, n)=='$'
      || string.substring(n-1, n)=='?'
      || string.substring(n-1, n)=='%'
      || string.substring(n-1, n)==';'
      || string.substring(n-1, n)=='=')
   {
    alert('The Invalid character " '+string.charAt(n-1)+' "  has been replaced with "_".');
    check+="_";
   }
   else if(string.substring(n-1, n)=='\'') check+="`";
   else check+=string.substring(n-1, n);
  }
  string=check;

  spos=0;
  while(string.charAt(spos)==' ' && spos<string.length) spos++;
  if(spos==string.length) string='';
  else {
   string=string.substring(spos, string.length);
   epos=(string.length)-1;
   while(string.charAt(epos)==' ') epos--;
   string=string.substring(0, epos+1);
  }
  return(string);
}

//////////////////////////////hide layers
 function HideLayer(id)
 { 
  if (document.all)
  { 
   document.all[id].style.visibility = 'hidden';
   document.all[id].style.position   = 'absolute';
  } 
  else if(document.layers)
  { 
   document.layers[id].visibility = 'hide';
   document.layers[id].position   = 'absolute';
  } 
  else if(document.getElementById)
  {
   document.getElementById(id).style.visibility ='hidden';
   document.getElementById(id).style.position   ='absolute';
  } 
 }
 
 function ShowLayer(id)
 { 
  if (document.all)
  { 
   if(document.all[id].style.visibility == 'visible'){ HideLayer(id); return; }
   document.all[id].style.visibility = 'visible';
   document.all[id].style.position   = 'relative';
  } 
  else if(document.layers)
  { 
   if(document.layers[id].visibility == 'visible'){ HideLayer(id); return; }
   document.layers[id].visibility = 'show' ;
   document.layers[id].position   = 'relative';
  } 
  else if(document.getElementById)
  {
   if(document.getElementById(id).style.visibility == 'visible'){ HideLayer(id); return; }
   document.getElementById(id).style.visibility = 'visible';
   document.getElementById(id).style.position   = 'relative';
  } 
 } 

////////////////////////////////////////////////////menu display
//USE overhelp.js

function ShowDes(ref){ toolTip(mess[ref],WIDTH,250,CAPTION,links[ref][0]); }
function HideDes(ref){ toolTip(); }


// START DATE SCRIPT
//<script>showdate('[menubgoff]','[menutxtoff]')</script>
function showdate(bgclr,clr)
{
 //var dateLR	= "left"  	// DATE LEFT OR RIGHT
 //var dateX	= "125"  	// DATE X LOCATION
 //var dateY	= "150"  	// DATE Y LOCATION
 //document.write('<div id="date-location" style="'+dateLR+': '+dateX+'px; POSITION: absolute; TOP: '+dateY+'px">');
 var d=new Date();
 var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
 var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
 document.write("<font style='background-color:"+bgclr+"; color:"+clr+"; font-size:9pt;'>" + weekday[d.getDay()] + " ");
 document.write(monthname[d.getMonth()] + ", ");
 document.write(d.getDate() + ", ");
 document.write(d.getFullYear());
 document.write("</font>");
}

//////////////////Copy to Clipboard
function CopyToClipboard(fromId)
{
 var r = document.getElementById(fromId).createTextRange();
 r.select();
 r.execCommand('copy');
}


function isNumericals(num)
{
 if(!num.length)return true;
 for(var x=0;x<num.length;x++) if(!isDigit(num.substring(x,x+1)))return false;
 return true;
}

function isDigit(num) {
    if(!num.length)return false;
    var string=".1234567890";
    if (string.indexOf(num)!=-1) return true;
    return false;
}

function isNumeric(val){ return(parseFloat(val,10)==(val*1)); }

 ////////add options to forms. start-finish-increment-
 function addopts(start,finish,increment,val,zero)
 {
  if(!start)start=0;
  if(!finish)finish=1;
  if(!increment)increment=1;
  for(var s=start;s<=finish;s+=increment)
  {
   document.write("<option value='"); if(zero && s<10)document.write("0"); document.write(s+"'");
   if(s==val || s==parseFloat(val)) document.write(" selected");
   document.write(">");
   if(zero && s<10)document.write("0");
   document.write(s+"\n");
  }
 }

 ////////add yesno to forms.
 function yesno(ref,val,onchange)
 {
  var y=''; var n ='';
  var s=' selected';
  if(val=='Yes')y=s; else n=s;
  var text="<select class='select' name='"+ref+"' id='"+ref+"' onChange='"+onchange+"'>";
  text+="<option value='No'"+n+">No";
  text+="<option value='Yes'"+y+">Yes";
  text+="</select>";
  document.write(text);
 }

//////////display preview image
 var fileTypes=["gif","jpg"];     // valid file types

 document.write("<style>.preview { FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale); }</style>");
 function showimg(ref,val,size)
 {
alert(ref.value);
  var source=ref.value;  
  if(ref)
  {
   var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
   for (var i=0; i< fileTypes.length; i++) if (fileTypes[i]==ext) break;
  }
  if (i==fileTypes.length)
  {
   alert(fileTypes+" Image formats can be used Only.<br>BMP images can be changed to JPG or GIF from your Windows Paint program or any other image software.");
   ref.value='';
   return;
  }
  var field = document.getElementById("previewField"+val);
  field.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = source;
  field.style.width  = size+"px";
  field.style.height = size+"px";
 }

////////////////////////////////

 function txtarea(ref,x,y)
 {
  document.write("<textarea name='"+ref+"' ROWS="+x+" COLS="+y+" value=''></textarea>");
 }

 function CA(ref,process)
 {
  var act=true;
  if(ref.checked!=act){ ref.checked=false; act=false; }
  for (i=0; i< form.elements.length; i++) if (form.elements[i].type == 'checkbox') form.elements[i].checked = act;
  if(process) process();
 }

 /////form validation - storage and return onload/////
 function validatefields(ref)
 {
  var re=/'/g;
  for(var x=0;x<ref.length;x+=2)
  {
   var field= document.getElementById(ref[x]);
   if(field)
   {
    if(field.type=='textarea')field.value=field.value.replace(re,'`'); document.getElementById(ref[x]).value=field.value;
    if(field.value==''
       || (field.name.indexOf('Email')!=-1 && (field.value.indexOf('@')==-1 || field.value.indexOf('.')==-1)
      )
     )
    {
     if((field.name=='Phone' || field.name=='Mobile')
         && (document.getElementById('Phone').value!='' || document.getElementById('Mobile').value!='')){ document.getElementById(ref[x]).style.background='white'; continue; }
     if(field.name=='Email')alert('A valid email address is required.');
     else alert(ref[x+1]+' field required.');
     document.getElementById(ref[x]).style.background='pink';
     if(document.getElementById(ref[x]).type!='hidden')document.getElementById(ref[x]).focus();
     x=ref.length;
     return false;
    }
    document.getElementById(ref[x]).style.background='white';
   }
  }
  return true;
 }

 function storefields(no,ref,days)
 {
  for(var x=0;x<ref.length;x+=2)
  {
   var field= document.getElementById(ref[x]);
   if(field)
   {
    if(field.name=='code' || field.name=='PW')continue;
    else if(field && field.name && field.value)
    {
     if(field.value.indexOf('Email')!=-1 || field.value.indexOf('PassWord')!=-1 || field.value.indexOf('PW')!=-1)
     {
      SetCookie(no+field.name,field.value,days,'/');
     }
     else
     {
      if(field.value.indexOf('Email')!=-1)field.value=answer.toLowerCase()
      SetCookie(no+field.name,field.value,0,'/');
     }
    }
   }
  }
 }

 function returnfields(no,ref)
 {
  if(no)
  {
   for(var x=0;x<ref.length;x+=2)
   {
    var field= document.getElementById(ref[x]);
    if(field)
    {
     var val= GetCookie(no+field.name);
     if(val != null)
     {
      if(field.style!='radio' && field.name!='PassWord' && field.name!='APW')
       document.getElementById(ref[x]).value=trim(val);
     }
    }
   }
  }
 }
///////////////////////////////////////////////////////////////
 function cleantext(ref)
 {
  for(var x=0;x<ref.length;x++)
  {
   var field= document.getElementById(ref[x]);
   if(field && field.type=='textarea')
   {
    field.value=field.value.replace(/\^/g,'');
    field.value=field.value.replace(/</g,'&#60;');
    field.value=field.value.replace(/>/g,'&#62;');
    field.value=field.value.replace(/\n/g,'^');
    document.getElementById(ref[x]).value=field.value;
   }
  }
 }

 function textclean(ref)
 {
  ref=ref.replace(/&#60;/g,'<');
  ref=ref.replace(/&#62;/g,'>');
  ref=ref.replace(/\^/g,'\n');
  return ref;
 }

 //////////////////////////////menu swap images///
 //<td><a href="contact" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contact','','images/contact-1.jpg',1)"><img src="images/contact.jpg" alt="Contact" name="contact" width="170" height="30" border="0"></a></td>
 function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
 }

 function PI_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=PI_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
 }

 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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){ document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2]; }
 }
 ////end images


// onMouseOver='playSound(0)' onMouseOut='stopSound(0)'

var aySound = new Array();
aySound[0] = "i/laser.wav";

// DO NOT edit below this line
document.write('<BGSOUND ID="auIEContainer">')
var IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
var NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
var ver4 = IE||NS? 1:0;

/////////////////if(document.onload)auPreload();

function auPreload()
{
 if (!ver4) return;
 if (NS) auEmb = new Layer(0,window);
 else {
 Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
 document.body.insertAdjacentHTML("BeforeEnd",Str);
 }
 var Str = '';
 for (i=0;i<aySound.length;i++)
 Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
 if (IE) auEmb.innerHTML = Str;
 else {
 auEmb.document.open();
 auEmb.document.write(Str);
 auEmb.document.close();
 }
 auCon = IE? document.all.auIEContainer:auEmb;
 auCon.control = auCtrl;
}

function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }

///////////Status Scroller
//<script id=Scroller>if(this.TSpeed)Start('Text')</script>; 

var Count = 0;
var Text = "Enter your own text to display at the status bar";
var TSpeed = 90;
var timerID = null;
var TimerRunning = false;

function Scroll()
{
 window.status = Text.substring(Count++, Text.length);
 if (Count == Text.length) Count = 0;
 timerID = setTimeout("Scroll()", TSpeed);
 TimerRunning = true;
}

function Scroller(T)
{
 Text =T;
 var i = 0;
 while (i++ < 140) Text = " " + Text;
 ScrollerStop();
 Scroll(); 
}

function ScrollerStop()
{
 if(TimerRunning)clearTimeout(timerID);
 TimerRunning = false;
}
/////////////////end Status Scroller

function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	if (imageType == "swf"){
	newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
	newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('</embed></object>');	}else{
	newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

// 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 isNumerical(str)
{
  var re = /[\D]/g
  if (re.test(str)) return false;
  return true;
}

