//vars for the flash embed/detection script
var requiredMajorVersion = 8;
var requiredMinorVersion = 0;
var requiredRevision = 0;


//Highlight form element- � Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

var highlightcolor="lightyellow"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}
	
// Open pop-up window
function openwindow(path,windowname,attributes) { 
	window.open(path,windowname,attributes);
}

// Get window size

function getWindowSize() {
	// returns innerHeight / innerWidth of window
	if (self.innerHeight) {
		// all except Explorer
		var width = self.innerWidth;
		var height = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		// Explorer 6 Strict Mode
		var width = document.documentElement.clientWidth;
		var height = document.documentElement.clientHeight;
	} else if (document.body) {
		// other Explorers
		var width = document.body.clientWidth;
		var height = document.body.clientHeight;
	};
	
	//alert("width="+width);
	//alert("height="+height);
	
	return { width: width, height: height };
};

function showspec(id) {
	//getWindowSize(id);
	window.open('/techspecs.asp?id=' + id,'TechSpecs','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=400,height=500');	
	//techspecs.document.open();
	
	//techspecs.document.write('<html><head><title>Popup</title>');
  	//techspecs.document.write('<link rel="stylesheet" href="sellingshimano.css">');
  	//techspecs.document.write('</head><body>');
  	//techspecs.document.write('<h2>Tech Specs</h2>');
	//techspecs.document.write('<div id="spec">tech spec copy</div>');
  	//techspecs.document.write('<p><a href="javascript:self.close()">close window</a></p>');
  	//techspecs.document.write('</body></html>');
	
  	//techspecs.document.close();
}

// Read form value and place into hidden form field
function ReadPath() {
	 var filepath = document.form1.filepath.value;
	 document.form1.hiddenpath.value = filepath;
}

// Dropdown navigation without submit
function FastLink() {
window.location= document.getElementById('idcontact').value;
}

// Macromedia functions used by many Dreamweaver behaviors
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;
}


// Toggle checkboxes
function flevToggleCheckboxes() { // v1.1
	// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
	var sF = arguments[0], bT = arguments[1], bC = arguments[2], oF = MM_findObj(sF);
    for (var i=0; i<oF.length; i++) {
		if (oF[i].type == "checkbox") {if (bT) {oF[i].checked = !oF[i].checked;} else {oF[i].checked = bC;}}} 
}

// Form validation
function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}

//Start textbox suggestion tool - Global variables and functions - additional js on each page that utilizes the tool
var NS4 = (document.layers) ? true : false;
var IE4 = (document.all) ? true : false;
var NS4MAC = NS4 &&
            (navigator.appVersion.indexOf("Macintosh") > -1);

var size = 1;
var textwidth = 1;
var active = false;

// select index style:
//   1. Standard
//      Selects an option if a substring match is found.
//      If no match is found, selects the closest match
//      from the bottom. For example, if the string is
//      "cz", it will match "cy...", "cx...", etc.
//   2. Explorer
//      Simulates the new index in Internet Explorer's
//      help. If the string is empty, selects the first
//      option. Otherwise, if no substring match is found
//      the selection doesn't change.
var style = 1;

function site(name, url) {
  this.name = name;
  this.url = url;
}

function byName(a, b) {
  var anew = a.name.toLowerCase();
  var bnew = b.name.toLowerCase();
  if (anew < bnew) return -1;
  if (anew > bnew) return 1;
  return 0;
}

function display() {
  var list = document.organizer.list;
  if (list.selectedIndex > -1) // if an option is selected
    location.href = list.options[list.selectedIndex].value;
}

function update() {
  if ((!NS4 && !IE4) || NS4MAC) return;
  var form = document.organizer;
  var field = form.prefix;
  var list = form.list;
  field.value = list.options[list.selectedIndex].text;
}

function select(list, i) {
  if (list.selectedIndex != i) list.selectedIndex = i;
}

function checkKey() {
  if (!active) return;
  var form = document.organizer;
  var field = form.prefix;
  var list = form.list;
  var str = field.value.toLowerCase();
  if (str == "") {
    select(list, 0);
    return;
  }
  for (var i = 0; i < list.options.length; ++i) {
    if (list.options[i].text.toLowerCase().indexOf(str) == 0) {
      select(list, i);
      return;
    }
  }
  if (style == 1) {
    for (i = list.options.length - 1; i >= 0; --i) {
      if (str > list.options[i].text.toLowerCase()) {
        select(list, i);
        return;
      }
    }
    select(list, 0);
  }
}

//END textbox suggestion tool


//confirm delete 
function confirmSubmit(msg)
{
var agree=confirm(msg);
if (agree)
	return true ;
else
	return false ;
}

//Automatically Clear default value from text box
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

//image swap
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 MM_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=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];}}
}

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];}
}

//Calendar Picker
/// <summary>
/// Launches the DatePicker page in a popup window, 
/// passing a JavaScript reference to the field that we want to set.
/// </summary>
/// <param name="strField">String. The JavaScript reference to the field that we want to set, in the format: FormName.FieldName
/// Please note that JavaScript is case-sensitive.</param>
function calendarPicker(strField)
{
	window.open('/functions/DatePicker.aspx?field=' + strField,'calendarPopup','width=230,height=170,resizable=yes');
}

function displayPanel(oCheckbox) {
var bWhich = oCheckbox.checked;
if (el = document.getElementById(oCheckbox.value))
el.style.display = (bWhich) ? 'block' : 'none';
}
