
var inExpert = true;
var overli = false;
var pow=null;
var prew=null;

 function encode_utf8(rohtext) {
   // dient der Normalisierung des Zeilenumbruchs
   rohtext = rohtext.replace(/\r\n/g,"\n");
   var utftext = "";
   for(var n=0; n<rohtext.length; n++)
     {
       // ermitteln des Unicodes des  aktuellen Zeichens
       var c=rohtext.charCodeAt(n);
       // alle Zeichen von 0-127 => 1byte
       if (c<128)
	 utftext += String.fromCharCode(c);
       // alle Zeichen von 127 bis 2047 => 2byte
       else if((c>127) && (c<2048)) {
	 utftext += String.fromCharCode((c>>6)|192);
	 utftext += String.fromCharCode((c&63)|128);}
       // alle Zeichen von 2048 bis 66536 => 3byte
       else {
	 utftext += String.fromCharCode((c>>12)|224);
	 utftext += String.fromCharCode(((c>>6)&63)|128);
	 utftext += String.fromCharCode((c&63)|128);}
     }
   return utftext;
 }



function e_toggleRows(toExpert) {
  if (toExpert == inExpert)
    return;
  inExpert = !inExpert;

  dataTable = document.getElementById('edittable');
  dataTabletRows = dataTable.getElementsByTagName('TR');
  for (i = 0; i < dataTabletRows.length; i++) {
    currentRow = dataTabletRows[i];
    e_toggle(currentRow);
  }
  if (inExpert)
    document.getElementById('mode1').checked = true;
  else
    document.getElementById('mode4').checked = true;

  if (inExpert) {
    buildExpertField();
    parseExpertArea();
    if (pow && pow.open && !pow.closed) pow.close();
  }
  else {
    grid2expert();
    parseScore();
  }
}

function e_toggle(item) {
  if (item.style.display == '') {
    item.style.display = 'none';
    opening = false;
  } else {
    item.style.display = '';
    opening = true;
  }
}

// ----------------------------------------

function parsensave() {
  //    alert (BrowserDetect.browser);
  if (document.getElementById("NLB").value.length == 0) {
    alert("Please enter the record number. Enter 0 when testing.");
    document.getElementById("NLB").focus();
    return;
  }

  if (inExpert) {
    //parseScore();
    if (!isinstrumental())
      grid2expert();
    document.getElementById('exmod').value='Y';
  }
  else {
    if (BrowserDetect.browser == "Safari") {
      //alert("This is Safari. About to switch to Expert Mode.");
      e_toggleRows(true);
      //alert("Switched to Expert Mode. About to set exmod to N anyways.");
      document.getElementById('exmod').value='N';
      //alert("Set exmod to N.");
    } else {
      buildExpertField(); 
      if (pow && pow.open && !pow.closed) pow.close();
      document.getElementById('exmod').value='N';
    }
  }
  document.editform.submit();
}


var gliss = new Array();
var pitchcl = new Array();
var octave=new Array();
var duration=new Array();
var dotted=new Array();
var tied=new Array();
var slur=new Array();
var triplet=new Array();
var lyrics=new Array();
var twijfel = new Array();
var timech = new Array();
pitchcl[0] = new Array(); 
octave[0]=new Array(); duration[0]=new Array(); dotted[0]=new Array(); tied[0]=new Array(); slur[0]=new Array(); triplet[0] = new Array(); 
lyrics[0] = new Array(); twijfel[0] = new Array(); gliss[0] = new Array();
timech[0] = new Array();

function buildExpertField() {
  var text = '';
  var tripletcounter = 0;
  for (l=0; l<pitchcl.length; l++) {
    var notes = new Array();
    for (c=0; c<pitchcl[l].length; c++) {
      //alert('timech['+l+']['+c+']='+timech[l][c]+'; '+'gliss['+l+']['+c+']='+gliss[l][c]);
      notes[c] = timech[l][c]+gliss[l][c];
      if (triplet[l][c] && (tripletcounter == 0)) {
	notes[c] += '\\times 2/3 {';
        tripletcounter = 1;
      }
      if (tripletcounter > 0)
	tripletcounter++;
      notes[c] += twijfel[l][c] + pitchcl[l][c]+octave[l][c]+duration[l][c]+dotted[l][c]+tied[l][c]+slur[l][c];
      if (tripletcounter == 4) {
	notes[c] += "}"; tripletcounter = 0;
      }
    }
     
    var lyrline = '';
    for (c=0; c<lyrics[l].length; c++) {
      var lyr = lyrics[l][c];
      while (lyr.length != notes[c].length)
	if (lyr.length < notes[c].length)
	  lyr += ' ';
	else
	  notes[c] += ' ';
      lyrline += lyr;
      if (c<lyrics[l].length-1)
	lyrline += "\t";
    }

    for (c=0; c<pitchcl[l].length; c++) {
      text += notes[c];
       if (c<pitchcl[l].length-1)
	text += "\t";
    }
    text += "\n" + lyrline + "\n\n";
    delete notes;
  }
  document.getElementById('expertarea').value = text; 
}

function adjustspaces() {
  parseScore(); buildExpertField();
}

function removespaces () {
  var text = document.getElementById('expertarea').value;
  var lines=text.split("\n");
  for (var i=0; i < lines.length; i++) {
    var col=lines[i].split("\t");
    for (var c=0; c < col.length; c++) {
      res = col[c].match(/^\s*(.*?)\s*$/);
      if (res != null)
	if (res[1] != null)
	  col[c] = res[1];
    }
    lines[i] = col.join("\t");
  }
  document.getElementById('expertarea').value = lines.join("\n");
}

// parseScore:

function parseScore() {
  var text = document.getElementById('expertarea').value;
  //    alert("getelementbyid(expertarea) is: "+text);
  var lines=text.split("\n");
  var ncol, tcol;
  if (pitchcl != null) delete pitchcl; pitchcl = new Array();
  if (octave != null) delete octave;  octave = new Array(); 
  if (duration != null) delete duration; duration = new Array();
  if (dotted != null) delete dotted; dotted = new Array();
  if (tied != null) delete tied; tied = new Array();
  if (slur != null) delete slur; slur = new Array();
  if (gliss != null) delete gliss; gliss = new Array();
  if (twijfel != null) delete twijfel; twijfel = new Array();
  if (timech != null) delete timech; timech = new Array();
  if (triplet != null) delete triplet;   triplet = new Array();
  if (lyrics != null) delete lyrics;   lyrics = new Array();
  var oTbl = document.getElementById('begnotes').tBodies[0];
  while (oTbl.rows.length>0)
  oTbl.deleteRow(0);

  if (lines.length > 0)
    while (lines.length > 0 && lines[lines.length-1].match(/^\s*$/))
      lines.pop();
  
  while (lines.length % 3 != 0 && text != "")
    lines[lines.length] = "";

  var noteditable;

  for (var i=0; i < lines.length; i++)
    {
      if (i % 3 == 0) {
	ncol=lines[i].split("\t");
	if (ncol.length == 1 && ncol[0].length > 10)
	  ncol = lines[i].split("\s");
      }
      else if (i % 3 == 1) {
	var lpitchcl = new Array();
	var loctave = new Array(); 
	var lduration = new Array();
	var ldotted = new Array();
	var ltied = new Array();
	var lslur = new Array();
	var lgliss = new Array();
	var ltwijfel = new Array();
	var ltimech = new Array();
	var ltriplet = new Array();

	var  oTR = oTbl.insertRow(-1);
	tcol=lines[i].split("\t");
	if (tcol.length < ncol.length && !isinstrumental())
	  alert("Warning: you specified too few lyrics syllables in line "+((i-(i%3))/3+1)+". I am adding \"\" for each syllable that is missing a note. You might want to correct this (this is easiest in expert mode).");
	for (a=tcol.length; a<ncol.length; a++)
          tcol[a] = '';

	while (tcol.length > ncol.length && tcol[tcol.length-1].match(/^\s*$/))
	  tcol.pop(); // delete any extra empty syllables without complaining
	if (tcol.length > ncol.length) // still extra syllables?
	  alert("Warning: you specified too many  lyrics syllables in line "+((i-(i%3))/3+1)+". For example this one: \""+tcol[tcol.length-1]+"\". I am simply removing all syllables for which there is no note. You might want to correct this (this is easiest in expert mode).");
	while (tcol.length > ncol.length)
	  tcol.pop();
	lyrics[(i-(i%3))/3] = tcol;
	var addedcells = 0;
	for (j=0; j<ncol.length; j++) {
	  noteditable = false;
	  var txt = ncol[j];
	  var pattern = /([\\glx]+\s+)?([cdefgabisr]+)([,\']*)([0-9]*)([\.]*)([~]?)([\)\(]*)([\}]?)/; 
	  var res = txt.match(/\s*\\time\s+(\d+)\s*\/\s*(\d+)\s*(.*)/);
	  if (res != null) {
	    ltimech[j] = "\\time "+res[1]+"/"+res[2]+" ";
	    txt = res[3];
	  } else
	    ltimech[j] = "";

	  lgliss[j] = '';
	  var res = txt.match(/\s*(\\gl\s+)?\s*(.*)/);
	  if (res != null) {
	    if (res[1])
	      lgliss[j] = res[1];
	    txt = res[2];
	  }

	  var res = txt.match(/\s*.times\s+\d\/\d\s*\{(.*)/);
	  if (res != null) {
	    ltriplet[j] = true;
	    txt = res[1];
	  }
	  var res = txt.match(pattern); 
	  if (res != null) {
	    var oTD = oTR.insertCell(-1);
	    oTD.innerHTML=//ncol[j]+"<br/>"+tcol[j];
	      (overli?
	      '<a href="javascript:void(0);" style="text-decoration:none" onclick="overlib(editcell('+(i-(i%3))/3+','+j+'), WIDTH, 400, OFFSETX, 500, OFFSETY, 200, STICKY, CAPTION, \'Edit Note\', NOCLOSE, HEIGHT, 510, ABOVE);" onmouseout="return nd();">'+ncol[j]+"<br/>"+tcol[j]+"</a>"
	       :'<a href="javascript:void(0);" style="text-decoration:none" onclick="edcell_pow('+(i-(i%3))/3+','+j+');">'+ncol[j]+"<br/>"+tcol[j]+"</a>")
;
	    oTD.vAlign="top";
	    ltwijfel[j] = ''; 
	    if (res[1] != null)
	      if (res[1] == "\\x ")
		ltwijfel[j] = res[1];
	      else if (res[1] == "\\gl ")
		lgliss[j] = res[1];
	    //	    if (res[2] != null)
	    //	      if (res[2] == "\\x ")
	    //		ltwijfel[j] = res[2];
	    //	      else if (res[2] == "\\gl ")
	    //		lgliss[j] = res[2];
	    lpitchcl[j] = res[2];
	    loctave[j] = res[3];
	    lduration[j] = res[4];
	    ldotted[j] = res[5];
	    ltied[j] = res[6];
	    lslur[j] = res[7];
	    //ltriplet[j] = res[9];	    
	    addedcells++;
	  } else {
	    if (txt != "")
	      alert("no match: "+pattern+"  -"+txt+"-");
	    else
	      noteditable = true;
	  }
	  if (noteditable) {
	    var oTD = oTR.insertCell(-1);
	    oTD.innerHTML=ncol[j]+"<br/>"+tcol[j];
	    oTD.vAlign = "top";
	    ltwijfel[j] = ''; 
	    lpitchcl[j] = '';
	    loctave[j] = '';
	    lduration[j] = '';
	    ldotted[j] = '';
	    ltied[j] = '';
	    lslur[j] = '';
	    addedcells++;
	  }
	}
	if (addedcells > 0) {
	  oTD = oTR.insertCell(-1);
	  oTD.vAlign="top";
	  oTD.innerHTML=//ncol[j]+"<br/>"+tcol[j];
	    (overli?
	    '<a href="javascript:void(0);" style="text-decoration:none" onclick="overlib(editcell('+(i-(i%3))/3+',-1), WIDTH, 400, OFFSETX, 500, OFFSETY, 200,STICKY, CAPTION, \'Add Note\', NOCLOSE, HEIGHT, 510, ABOVE);" onclick="return nd();"><img src="/med/newn.gif" width="16" height="16" border="0"></a>' :'<a href="javascript:void(0);" style="text-decoration:none" onclick="edcell_pow('+(i-(i%3))/3+',-1);"><img src="/med/newn.gif" width="16" height="16" border="0"></a>');
	}

	pitchcl[(i-(i%3))/3] = lpitchcl;
	octave[(i-(i%3))/3] = loctave;
	duration[(i-(i%3))/3] = lduration;
	dotted[(i-(i%3))/3] = ldotted;
	tied[(i-(i%3))/3] = ltied;
	slur[(i-(i%3))/3] = lslur;
	twijfel[(i-(i%3))/3] = ltwijfel;
	timech[(i-(i%3))/3] = ltimech;
	gliss[(i-(i%3))/3] = lgliss;
	triplet[(i-(i%3))/3] = ltriplet;
	delete lpitchcl;
	delete loctave; 
	delete lduration;
	delete ldotted;
	delete ltied;
	delete lslur;
	delete lgliss;
	delete ltwijfel;
	delete ltriplet;
	delete ltimech;
      }
    }
  var  oTR = oTbl.insertRow(-1);
  var oTD = oTR.insertCell(-1);
  oTD.innerHTML=//ncol[j]+"<br/>"+tcol[j];
    (overli?
    '<a href="javascript:void(0);" style="text-decoration:none" onclick="overlib(editcell(-1,-1), WIDTH, 400, OFFSETX, 500, OFFSETY, 200, STICKY, CAPTION, \'Add Note\', NOCLOSE, HEIGHT, 510, ABOVE);" onmouseout="return nd();"><img src="/med/newn.gif" width="16" height="16" border="0"></a>' :'<a href="javascript:void(0);" style="text-decoration:none" onclick="edcell_pow(-1,-1);"><img src="/med/newn.gif" width="16" height="16" border="0"></a>');
  oTD.colSpan=5;
}

var mincol=7;

function parseExpertArea() {
  var text = document.getElementById('expertarea').value;
  //  alert(text);
  var lines=text.split("\n");
  var ncol, tcol;
  var tcn=0;
  var griddoc = document.getElementById('gridframe').contentDocument; //window.frames["grid"].document;

  if (!griddoc)
   griddoc = window.frames["grid"].document;

//  if (!griddoc)
//    alert("problem in browser: "+BrowserDetect.browser);
//  else alert("ok");

  if (lines.length > 0)
    while (lines.length > 0 && lines[lines.length-1].match(/^\s*$/))
      lines.pop();
  
  while (lines.length % 3 != 0 && text != "")
    lines[lines.length] = "";

  var gline = 0;
  
  for (var i=0; i < lines.length; i++)   {
      if (i % 3 == 0)
	ncol=lines[i].split("\t");
      else if (i % 3 == 1) {
	tcol=lines[i].split("\t");
	//if (tcol.length < ncol.length && !document.getElementById('i1').checked)
	//  alert("Warning: you specified too few lyrics syllables in line "+((i-(i%3))/3+1)+". I am adding \"\" for each syllable that is missing a note. You might want to correct this (this is easiest in expert mode).");
	for (a=tcol.length; a<ncol.length; a++)
          tcol[a] = '';

	//while (tcol.length > ncol.length && tcol[tcol.length-1].match(/^\s*$/))
	//  tcol.pop(); // delete any extra empty syllables without complaining
	//if (tcol.length > ncol.length) // still extra syllables?
	//  alert("Warning: you specified too many  lyrics syllables in line "+((i-(i%3))/3+1)+". For example this one: \""+tcol[tcol.length-1]+"\". I am simply removing all syllables for which there is no note. You might want to correct this (this is easiest in expert mode).");
	//while (tcol.length > ncol.length)
	//  tcol.pop();
	lyrics[(i-(i%3))/3] = tcol;
	//alert("i="+i+", ncol.length="+ncol.length+", gline="+gline);
	for (j=0; j<ncol.length; j++) {
	  griddoc.getElementById("cl"+gline+"|"+j).value=ncol[j];
	}
	gline++;

	for (j=0; j<tcol.length; j++) {
	  griddoc.getElementById("cl"+gline+"|"+j).value=tcol[j];
	}

	gline++;
      }
  }
}


function grid2expert() {
  var text = "";
  var griddoc = document.getElementById('gridframe').contentDocument; //window.frames["grid"].document;
  //  alert("grid2expert");
  if (isinstrumental())
    return;

  var i=0;
  //alert("maxrow is "+griddoc.getElementById("themaxrow").value);
  while (i < griddoc.getElementById("themaxrow").value)   {
    line = "";
    for (j=0; j<20; j++) {
      var cell = griddoc.getElementById("cl"+i+"|"+j).value;
      // if (cell.length > 0 || (j<20-1 &&griddoc.getElementById("cl"+i+"|"+j).value.length > 0))
      line += cell+"\t";
    }
    i++;
    if (line.length>0) {
      while (line.substring(line.length-1) == "\t")
	line = line.substring(0,line.length-1)+"\n";
      text += line;
      
      line = "";
      for (j=0; j<20; j++) {
	var cell=griddoc.getElementById("cl"+i+"|"+j).value;
	//if (cell.length > 0  || (j<20-1 &&griddoc.getElementById("cl"+i+"|"+j).value.length > 0))
	line += cell+"\t";
      }
      while (line.substring(line.length-1) == "\t")
	line = line.substring(0,line.length-1)+"\n";
      text += line;
      //      text += line.substring(0,line.length-1)+"\n";
    }
    i++; text += "\n";
  }
  document.getElementById('expertarea').value = text;
}

/*function grid_addcell(row, col) {
  var oTbl = document.getElementById('begnotes').tBodies[0];
  var trow;
  if (row == -1) {
    trow = oTbl.insertRow(oTbl.rows.length-1);
  }
  else
    trow = oTbl.rows[row];
  for (i=0; i<mincol; i++) {
    var cell = trow.insertCell(-1);
    cell.innerHTML = '<input type="text" size="10" value="" id="cl'+row+'|'+i+'">';
  }
}
*/


function editcell(row, col) {
  var text = '';
  if (navigator.appVersion.indexOf("MSIE")!=-1){
    var temp=navigator.appVersion.split("MSIE");
    var version=parseFloat(temp[1]);
    if (version < 7)
      text = '<a href="javascript:void(0);" onclick="javascript:theiframe.location.reload(true);">Please click here to work around an IE6 bug. Even better: use IE7 or Firefox!</a><br/>';
  }
  // alert("IE sucks!!!");}</script>
  //  return 'hello world<br/><script type="text/javascript">if (navigator.appVersion.indexOf("MSIE")==-1){  alert("IE sucks!!!");}</script>'; //
  return text+'<iframe src="http://meertens.musipedia.org/pu.php?ro='+row+'&co='+col+'&lyr='+(!isinstrumental()?'1':'0')+'" width="400" height="510" id="theiframe"></iframe>'; 
}

function edcell_pow(row, col) {
  pow=window.open('/pu.php?ro='+row+'&co='+col+'&pow=1&lyr='+(!isinstrumental()?'1':'0'),'edit_note','width=400,height=510,status=0,menubar=0,scrollbars=1,resizable=1');
  pow.focus();
  return false;
}


function isinstrumental() {
  //  alert("isinstr?");
  if (document.getElementById("i1").value == "N")
    return false;
  if (document.getElementById("i1").value == "Y")
    return true;
  return document.getElementById("i1").checked;
}

function preview() {
  if (inExpert) {
    if (!isinstrumental())
      grid2expert();
  }
  else
    buildExpertField();

  if (prew && prew.open && !prew.closed) prew.close();
  
  lily = document.getElementById('expertarea').value.replace(/\+/g,"%2B");

//  lily = lily.replace(/\\/g, "\\\\");
//  lily = lily.replace(/\'/g, "\\'");
  //  while (lily.match(/\t$/g)) {lily = lily.replace(/\t$/g, "");}

  prew=window.open('/preview.php?fnr='+escape(document.getElementById("firstnoterel").value)+'&lily='+escape(encode_utf8(lily))+'&key2='+escape(document.getElementById('key2').value)+'&key1='+document.getElementById("key1").value+'&time1='+document.getElementById("time1").value+'&time2='+document.getElementById("time2").value+'&pns='+(document.getElementById("pns").checked?'Y':'N')+'&ednotes='+escape(encode_utf8(document.getElementById("ednotes").value.replace(/\+/g,"%2B")))+'&minv='+(document.getElementById("minv").checked?'Y':'N')+'&strophe='+document.getElementById("strophe").value+'&NLB='+document.getElementById("NLB").value+'&m_title='+escape(encode_utf8(document.getElementById("instrtitle").value.replace(/\+/g,"%2B")))+'&instr='+(isinstrumental()?'Y':'N')+'&upbeat='+escape(document.getElementById('upbeat').value),'989c1eedc4d93ae02c02fae6636bf5e','width=900,height=650,status=0,menubar=0,scrollbars=1,resizable=1');
  prew.focus();
  return false;
}


// ------------------ HTTP request:
// to be used like: <a href="#" onclick="makeHttpRequest('test.html', 'alert');">Make a request</a>

function makeHttpRequest(url, callback_function, return_xml)
{
    var http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Unfortunatelly you browser doesn\'t support this feature.');
        return false;
    }
    http_request.onreadystatechange = function() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                if (return_xml) {
                    eval(callback_function + '(http_request.responseXML)');
                } else {
                    eval(callback_function + '(http_request.responseText)');
                }
            } else {
                alert('There was a problem with the request.(Code: ' + http_request.status + ')');
            }
        }
    }
    http_request.open('GET', url, true);
    http_request.send(null);
}


// ------------------------------------------
// tab in textarea:

function setSelectionRange(input, selectionStart, selectionEnd) {
    if (input.setSelectionRange) {
	  input.focus();
	  input.setSelectionRange(selectionStart, selectionEnd);
    }
    else if (input.createTextRange) {
	  var range = input.createTextRange();
	  range.collapse(true);
	  range.moveEnd('character', selectionEnd);
	  range.moveStart('character', selectionStart);
	  range.select();
    }
}

function replaceSelection (input, replaceString) {
    if (input.setSelectionRange) {
	  var selectionStart = input.selectionStart;
	  var selectionEnd = input.selectionEnd;
	  var scrollTop = input.scrollTop; var scrollLeft = input.scrollLeft;
	  //alert("top= "+scrollTop+", left = "+scrollLeft);
	  input.value = input.value.substring(0, selectionStart)+ replaceString + input.value.substring(selectionEnd);
	  input.scrollTop = scrollTop;
	  
	  if (selectionStart != selectionEnd){ 
		setSelectionRange(input, selectionStart, selectionStart + 	replaceString.length);
	  }else{
		setSelectionRange(input, selectionStart + replaceString.length, selectionStart + replaceString.length);
	  }
	  input.scrollLeft = scrollLeft+(scrollLeft > 100? 50:0);
    }else if (document.selection) {
	  var range = document.selection.createRange();
	  
	  if (range.parentElement() == input) {
		var isCollapsed = range.text == '';
		range.text = replaceString;
		
		if (!isCollapsed)  {
		    range.moveStart('character', -replaceString.length);
		    range.select();
		}
	  }
    }
}


// We are going to catch the TAB key so that we can use it, Hooray!
function catchTab(item,e){
    if(navigator.userAgent.match("Gecko")){
	  c=e.which;
    }else{
	  c=e.keyCode;
    }
    if(c==9){
	  replaceSelection(item,String.fromCharCode(9));
	  setTimeout("document.getElementById('"+item.id+"').focus();",0);	
	  return false;
    }
}


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();

