function Go() {
	return
}

function submitAdvanceform(search)
{
	var s="YES";

	if (search == "ADVANCED"){
		document.search.ADVANCED.value=s;
		document.search.BASIC.value="";
		 
	} else if (search == "BASIC"){
		document.search.BASIC.value=s;
		document.search.ADVANCED.value="";
	}

	document.search.submit();
}

 function selectAllUsers(bool,select_name)
 {
  var opts  = "";
  var nbrOpts = "";
    if(select_name=="PROJMANAGERID"){
      opts  = document.add_proj.PROJMANAGERID.options;
      nbrOpts  = document.add_proj.PROJMANAGERID.options.length;
    } else {
      opts  = document.add_proj.CONTACTID.options;
      nbrOpts  = document.add_proj.CONTACTID.options.length;
    }
  for (var i = 0; i<nbrOpts; i++)
  {
   opts.item(i).selected = bool;
  }
 }

function add_user(name_list,select_name){

  var option_list = name_list.split(';');
  var last_item;
  if (select_name=="PROJMANAGERID"){
	last_item  = document.add_proj.PROJMANAGERID.options.length;
  }
  else {
	last_item  = document.add_proj.CONTACTID.options.length;
  }

  var i = 0;
  for (i = 0; i < option_list.length-1; i++){
    var option_separate = option_list[i].split(',');
    if(select_name=="PROJMANAGERID"){
      document.add_proj.PROJMANAGERID.options[last_item] = new Option(option_separate[1],option_separate[0]);
    } else {
      document.add_proj.CONTACTID.options[last_item] = new Option(option_separate[1],option_separate[0]);
    }
    last_item = last_item+1;
  }
}
function delete_last_user(){
  document.add_proj.CONTACTID.options.length--;
}

function confirmAction(url){
        if (confirm("Are you sure?")){
                document.location=url;
        }
}

function confirmDownload(url){

        if (confirm("Do you agree to the Terms and Conditions?")){
                //self.location.replace(url);
                document.location=url;
	}
}

function toggleDiv(id,flagit) {
  if (flagit=="1"){
    if (document.layers) document.layers[''+id+''].visibility = "show"
    else if (document.all) document.all[''+id+''].style.visibility = "visible"
    else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
  } else if (flagit=="0"){
    if (document.layers) document.layers[''+id+''].visibility = "hide"
    else if (document.all) document.all[''+id+''].style.visibility = "hidden"
    else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
  }
}

// Toggles a div area depending on whether checkbox is checked or not.
// i.e <INPUT TYPE=CHECKBOX NAME=SEC VALUE=YES onChange=toggleSectonCB("divareaname",this)>
function toggleSectionCB(div,checkbox){
        if (checkbox.checked){
                toggleDiv(div,1);
        }
        else {
                toggleDiv(div,0);
        };
};
function toggleSectionCBReverse(div,checkbox){
        if (checkbox.checked){
                toggleDiv(div,0);
        }
        else {
                toggleDiv(div,1);
        };
};


function openWindow( pageToLoad, winName, width, height, center) {

	var x;
	var xposition=0; 
	var yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}

	var args = "width=" + width + ","
	+ "height=" + height + ","
	+ "location=0,"
	+ "menubar=0,"
	+ "resizable=0,"
	+ "scrollbars=1,"
	+ "status=0,"
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0";

	window.open(pageToLoad,winName,args);
} 

function StringArray (n) {
  var currentdate = 0
  var core = 0

  this.length = n;
  for (var i =1; i <= n; i++) {
    this[i] = ' '
  }
}

  function checkAll(form, list){
    for (property in form) {
      if(property.match(new RegExp(list+"\\d*?"))){
        form[property].checked = true;
      }
    }
  }

  function uncheckAll(form, list){
    for (property in form) {
      if(property.match(new RegExp(list+"\\d*?"))){
        form[property].checked = false;
      }
    }
  }

function unread_form() {
        document.forms["MSGLIST"].UNREAD.value = "1";
        document.forms["MSGLIST"].submit();
}

var myPopUp = null;

window.name="invoice";

function invoicePopup(invoiceid,type)
{


  var page = "";
  if ( ( myPopUp == null ) || myPopUp.closed ){
    myPopUp = open( "", "myPopUp", "width=450,height=400" );
  }
  else
  {
    myPopUp.focus();
  }

	if (type == "copy"){
		page = copy(invoiceid);
	} else if (type == "paid"){
		page = paid(invoiceid);
	};
	myPopUp.document.writeln(page);
	myPopUp.document.close();
}

function submitForm()
{
 if(document.myform.onsubmit())
 {		
	alert("submitted");
 //   document.myform.submit();
 } else {
 	alert("NOT submitted");
 }
}

function submitInvoiceForm(action)
{
        document.invoice.ACTION.value=action;
        document.invoice.submit();
        return(false);
}

function downloadConf(purchaseid) {

	if (confirm("Do you agree to the Terms and Conditions?")) {

		document.location="/?getPurchase&PURCHASEID=" + purchaseid;
	}
}



// Browser Detection


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
};
BrowserDetect.init();
