


//disable buttons in file upload dialog
function disableButton(button,textbox, button2 ) {
	if(textbox.value!="") {
		button.disabled=true
		button2.disabled=false
	} else {
		button.disabled=false
		button2.disabled=true
	}
}

//expand page to show file boxes
function togglemenu(curMenu, filebox, prevbox) {
	if (document.getElementById) {
		thisMenu=document.getElementById(curMenu).style
		if(thisMenu.display=="block") {
			if(filebox.value=="") {
				thisMenu.display="none"
			}
		}
		else {
			if(prevbox.value!="") {
				thisMenu.display="block"
			}
		}
		return false
	}
	else {
		return true
	}
}

//Add Item to List Box
function AddToList(filepath) {
	alert ("Added " + filepath +" to list");
}

//Redirect to to login page hiding URL from user
function GoToLogin() {
	document.location="login.php";
}
var popupWin=0;
function popUpWindow(url,l,t,w,h) {
features='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+w+',height='+h+',left='+l+',top='+t;
if(popupWin) {
	popupWin.close();
}
popupWin=window.open(url,'imagewin',features);
//popupWin.document.title='BuyTees.co.uk';
if (!popupWin.opener) {popupWin.opener = self;}
}

popupWin=0;
function popUpWindowScroll(url,l,t,w,h) {
features='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+w+',height='+h+',left='+l+',top='+t;
if(popupWin) {
	popupWin.close();
}
popupWin=window.open(url,'imagewin',features);
//popupWin.document.title='BuyTees.co.uk';
if (!popupWin.opener) {popupWin.opener = self;}
}

//Display popp window with englarged image

//function popUpWindow(URLStr, left, top, width, height)
//{
//  if(popupWin)
//  {
//    popupWin.close();
//  }
//  popupWin = open(URLStr, 'popupWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  //popupWin.document.title='BuyTees.co.uk';
 //popupWin.document.write("<img src="+URLStr+" width=480 height=360><br>");
//}

//Restore Image after rollover
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_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];}
}

function get_type(selectobj) {
	//alert (selectobj);
var makeid=selectobj.split(",");
myfilter.set(makeid[1]);

}

function filterlist(selectobj) {

  //==================================================
  // PARAMETERS
  //==================================================

  // HTML SELECT object
  // For example, set this to document.myform.myselect
  this.selectobj = selectobj;

  // Flags for regexp matching.
  // "i" = ignore case; "" = do not ignore case
  // You can use the set_ignore_case() method to set this
  this.flags = 'i';

  // Which parts of the select list do you want to match?
  this.match_text = false;
  this.match_value = true;

  // You can set the hook variable to a function that
  // is called whenever the select list is filtered.
  // For example:
  // myfilterlist.hook = function() { }

  // Flag for debug alerts
  // Set to true if you are having problems.
  this.show_debug = true;

  //==================================================
  // METHODS
  //==================================================

  //--------------------------------------------------
  this.init = function() {
    // This method initilizes the object.
    // This method is called automatically when you create the object.
    // You should call this again if you alter the selectobj parameter.

    if (!this.selectobj) return this.debug('selectobj not defined');
    if (!this.selectobj.options) return this.debug('selectobj.options not defined');

    // Make a copy of the select list options array
    this.optionscopy = new Array();
    if (this.selectobj && this.selectobj.options) {
      for (var i=0; i < this.selectobj.options.length; i++) {

        // Create a new Option
        this.optionscopy[i] = new Option();

        // Set the text for the Option
        this.optionscopy[i].text = selectobj.options[i].text;

        // Set the value for the Option.
        // If the value wasn't set in the original select list,
        // then use the text.
        if (selectobj.options[i].value) {
          this.optionscopy[i].value = selectobj.options[i].value;
        } else {
          this.optionscopy[i].value = selectobj.options[i].text;
        }

      }
    }
  }

  //--------------------------------------------------
  this.reset = function() {
    // This method resets the select list to the original state.
    // It also unselects all of the options.

    this.set('');
  }


  //--------------------------------------------------
  this.set = function(pattern) {
	  window.status="Please wait....";
	  //ShowLayer('layer1');
    // This method removes all of the options from the select list,
    // then adds only the options that match the pattern regexp.
    // It also unselects all of the options.
    var loop=0, index=0, regexp, e;
    if (!this.selectobj) return this.debug('selectobj not defined');
    if (!this.selectobj.options) return this.debug('selectobj.options not defined');
	
    // Clear the select list so nothing is displayed
    this.selectobj.options.length = 0;

    // Set up the regular expression.
    // If there is an error in the regexp,
    // then return without selecting any items.
    try {

      // Initialize the regexp
      regexp = new RegExp(pattern, this.flags);

    } catch(e) {

      // There was an error creating the regexp.

      // If the user specified a function hook,
      // call it now, then return
      if (typeof this.hook == 'function') {
        this.hook();
      }

      return;
    }

    // Loop through the entire select list and
    // add the matching items to the select list
    for (loop=0; loop < this.optionscopy.length; loop++) {

      // This is the option that we're currently testing
      var option = this.optionscopy[loop];
	  var myopt=option.value;
		var subid=myopt.split(",");
      // Check if we have a match
      //if ((this.match_text && regexp.test(option.text)) ||
          //(this.match_value && regexp.test(option.value))) {
		if ((subid[0]==pattern)||(subid[0]=='0')) {
        // We have a match, so add this option to the select list
        // and increment the index

        this.selectobj.options[index++] =
          new Option(option.text, option.value, false);

      }
    }

    // If the user specified a function hook,
    // call it now
    if (typeof this.hook == 'function') {
      this.hook();
    }
window.status=""
  }


  //--------------------------------------------------
  this.set_ignore_case = function(value) {
    // This method sets the regexp flags.
    // If value is true, sets the flags to "i".
    // If value is false, sets the flags to "".

    if (value) {
      this.flags = 'i';
    } else {
      this.flags = '';
    }
  }


  //--------------------------------------------------
  this.debug = function(msg) {
    if (this.show_debug) {
      alert('FilterList: ' + msg);
    }
  }


  //==================================================
  // Initialize the object
  //==================================================
  this.init();

}

function cleartext(box) {
	//alert("hello");
	box.value="";
}
