var boolFormDataChanged = false;
var boolPreventTableResize = false;
var intCurrResizeColumnId = -1;
var intDragStartPosition = 0;
var boolResizing = false;
var boolBrowseExpanded = true;
var intBrowsePreviousSize = 0;
var intLeftBound = 174;
var	intRightBound = 0;
var strOldPageLink;

function apply_form()
{
	window.onbeforeunload=null;
	document.getElementById('save_quit').value='';
}

function save_form()
{
	window.onbeforeunload=null;
	document.getElementById('save_quit').value='yes';
}

function cancel_form(boolCloseWindow)
{
	if (boolCloseWindow)
	{
		if ( window.opener != undefined )
			window.close();
	}
}

function revert_form()
{
}

function delete_selected()
{
	if(confirm("Are you sure you want to delete selected records?"))
	{
		document.getElementById('multi_record_action').value = 'delete_selected';
		document.getElementById('cdbadminlist_form').submit();
	}
}

function toggle_select_all(objCheckbox)
{
	for (var i=0; i < cdbadminlist_form.elements.length; i++)
	{
		var objElement = cdbadminlist_form.elements[i];

		if(objElement.name.substring(0,6) == 'MULTI_')
		{
			document.getElementById(objElement.id).checked = objCheckbox.checked;
			
		}
	}
}

function disable_submit_buttons()
{
	document.getElementById('apply_button').disabled = true;
	document.getElementById('save_button').disabled = true;
}

function is_form_data_changed()
{
	return boolFormDataChanged;
}

function set_form_data_changed()
{
	boolFormDataChanged = true;
}

function is_preview_ok()
{
	if(is_form_data_changed())
	{
		return confirm("You did not save the changes.\nThe page you are about to view will not reflect unsaved changes.\nWould you like to view this page anyway?");
	}
	else return true;
}

function handle_unload()
{
	if(is_form_data_changed())
		return "You did not save the changes!";
	else return;
}

function highlight_list_row(objRow, strColor)
{
	objRow.style.backgroundColor = strColor;
}

function test_func()
{}

function getCheckedValue(radioObj)
{
	if(!radioObj)
		return "";
	var radioLength = radioObj.childNodes.length;

	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	
	for(var i = 0; i < radioLength; i++)
	{
		if(radioObj[i].checked)
		{
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue)
{
	if(!radioObj)
		return;

	var radioLength = radioObj.length;

	if(radioLength == undefined)
	{alert(radioObj.value);
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++)
	{
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString())
		{
			radioObj[i].checked = true;
		}
	}
}


function expand_collapse_browse(intColumnId)
{
	strColumnName = "column_"+intColumnId;
	
	if(boolBrowseExpanded)
	{
		intBrowsePreviousSize = document.getElementById(strColumnName).width;
		document.getElementById(strColumnName).width = 1;
		document.getElementById("slider").style.left = intLeftBound;
		document.getElementById("browse_expand_collapse_button").src='core/assets/images/adm/pluroweb-b-browse-expand.gif';
		boolBrowseExpanded = false;
	}
	else
	{
		document.getElementById(strColumnName).width = intBrowsePreviousSize;
		document.getElementById("slider").style.left = parseInt(intLeftBound) + parseInt(intBrowsePreviousSize);
		document.getElementById("browse_expand_collapse_button").src='core/assets/images/adm/pluroweb-b-browse-collapse.gif';
		boolBrowseExpanded = true;
	}
}

function start_resize(objEvent, intColumnId, intLeftBound)
{
	document.getElementById('resize_cover_layer').style.display = 'block';
	intDragStartPosition = parseInt(document.getElementById("slider").style.left);

	document.onmouseup = stop_resize;
	document.onmousemove = do_drag;

	intCurrResizeColumnId = intColumnId;
//	if (objEvent) intDragStartPosition = objEvent.clientX;
//	else intDragStartPosition = window.event.clientX;
	return false;
}

function stop_resize(objEvent)
{
	if(!boolBrowseExpanded)
	{
		boolBrowseExpanded = true;
		document.getElementById("browse_expand_collapse_button").src='assets/images/gui/pluroweb-b-browse-collapse.gif';
	}

	intRightBound = document.body.clientWidth - 200;

	document.onmousemove = null;
	document.onmouseup = null;
	
/*	if (objEvent)
	{ intDragEndPosition = objEvent.clientX; }
	else { intDragEndPosition = window.event.clientX; }*/

	intDragEndPosition = parseInt(document.getElementById("slider").style.left);
	intNewWidth = parseInt(intDragEndPosition - intDragStartPosition) + parseInt(document.getElementById("column_"+intCurrResizeColumnId).width);

	if(intNewWidth >= 1)
	{
		document.getElementById("column_"+intCurrResizeColumnId).width = intNewWidth;
		intDragStartPosition = intDragEndPosition;
	}

	document.getElementById('resize_cover_layer').style.display = 'none';
	return false;
}

function do_drag(objEvent)
{
	intRightBound = document.body.clientWidth - 200;

	if (objEvent)
	{ intCurrPos = objEvent.clientX; }
	else { intCurrPos = window.event.clientX; }

	if(intCurrPos < intLeftBound) intCurrPos = intLeftBound;
	if(intCurrPos > intRightBound) intCurrPos = intRightBound;

	document.getElementById("slider").style.left = intCurrPos;
	return false;
}



var intRestWidth = null;
var intRestHeight = null;

function resize_table_new()
{
	if(document.getElementById('total_[[intSectionCounter]]_row'))
		intHeightOffset = document.getElementById('total_[[intSectionCounter]]_row').scrollHeight;
	else
		intHeightOffset = 0;

	if(BrowserDetect.browser == 'Firefox')
	{
		intWidthOffsetDiv = 0;
		intHeightOffsetDiv = 0;
		intWidthOffsetTable = 0;
		intHeightOffsetTable = -39;
	}
	else if(BrowserDetect.browser == 'Explorer')
	{
		intWidthOffsetDiv = 17;
		intHeightOffsetDiv = 17;
		intWidthOffsetTable = -17;
		intHeightOffsetTable = 17;
	}
	else
	{
		intWidthOffsetDiv = 0;
		intHeightOffsetDiv = 0;
		intWidthOffsetTable = -17;
		intHeightOffsetTable = 0;
	}

	// adjust width
	if(intRestWidth === null)
	{
//		if(document.getElementById('cdbadminlist_div').clientWidth)
//			intOriginalDivWidth = document.getElementById('cdbadminlist_div').clientWidth;
//		else 
//			intOriginalDivWidth = document.getElementById('cdbadminlist_div').scrollWidth;

		if(document.getElementById('cdbadminlist_container_td').offsetWidth > document.getElementById('cdbadminlist_div').scrollWidth)
			intOriginalDivWidth = document.getElementById('cdbadminlist_container_td').offsetWidth;
		else 
			intOriginalDivWidth = document.getElementById('cdbadminlist_div').scrollWidth;


		intRestWidth = document.body.scrollWidth - intOriginalDivWidth;
	}

	intAvailableWidth = document.body.clientWidth - intRestWidth;

	if(intAvailableWidth + intWidthOffsetTable >= 0)
	{
		document.getElementById('cdbadminlist_div').style.width = intAvailableWidth;
		document.getElementById('cdbadminlist_main_table').style.width = intAvailableWidth + intWidthOffsetTable;
		document.getElementById('cdbadminlist_main_table_tbody').style.width = intAvailableWidth + intWidthOffsetTable;
		document.getElementById('cdbadminlist_main_table_thead').style.width = intAvailableWidth + intWidthOffsetTable;
	}

	// adjust height
	if(intRestHeight === null || BrowserDetect.browser != 'Explorer')
	{
		if(document.getElementById('cdbadminlist_container_td').offsetHeight > document.getElementById('cdbadminlist_div').scrollHeight)
			intOriginalDivHeight = document.getElementById('cdbadminlist_container_td').offsetHeight;
		else 
			intOriginalDivHeight = document.getElementById('cdbadminlist_div').scrollHeight;

		intRestHeight = document.body.scrollHeight - intOriginalDivHeight;
	}

	intAvailableHeight = document.body.clientHeight - intRestHeight;

	if(intAvailableHeight > 100)
	{
		document.getElementById('cdbadminlist_div').style.height = intAvailableHeight;
	}
	else
	{
		document.getElementById('cdbadminlist_div').style.height = 400;
	}

	if(document.getElementById('cdbadminlist_main_table_tbody').scrollHeight > intAvailableHeight)
	{
		if(BrowserDetect.browser != 'Explorer')
		{
			document.getElementById('cdbadminlist_main_table').style.height =		intAvailableHeight + intHeightOffsetTable;
			document.getElementById('cdbadminlist_main_table_tbody').style.height = intAvailableHeight + intHeightOffsetTable;
		}
	}
	else
	{
		document.getElementById('cdbadminlist_main_table').style.height			=  '';
		document.getElementById('cdbadminlist_main_table_tbody').style.height	=  '';
	}
}


function resize_slider()
{
	if(document.getElementById('slider'))
	{
		document.getElementById('slider').style.height = document.body.clientHeight - 45;
	}
}


function resize_table()
{
	return;
	if(!boolPreventTableResize)
	{
		if(detect_browser()!='msie') document.getElementById('row_div').style.height = window.innerHeight-document.getElementById('list_header_cell').scrollHeight-20;

		objHeadTable = document.getElementById('head_table');
		objRowTable = document.getElementById('row_table');	
  
		// check if table contains any rows
		if(objRowTable.rows[0])
		{
			// iterate through columns in the row table
			for (var i = 0; i < objRowTable.rows[0].cells.length; i++)
			{
				intWidth = objRowTable.rows[0].cells[i].offsetWidth;
				if ( intWidth != 0 )
					objHeadTable.rows[0].cells[i].style.width = intWidth;
			}
		}
	}
	return false;
}


function toggle_menu_div(strMenuDivId)
{
	objMenuDiv = document.getElementById('menu_div_'+strMenuDivId);
	objExClolImg = document.getElementById('excol_img_'+strMenuDivId);
	
	if(objMenuDiv.style.display == 'block')
	{
		objMenuDiv.style.display = 'none';
		objExClolImg.src = 'assets/images/gui/pluroweb-b-expand.gif';
	}
	else
	{
		objMenuDiv.style.display = 'block';
		objExClolImg.src = 'assets/images/gui/pluroweb-b-collapse.gif';
	}
}

function link_mouseover(strLinkTableId)
{
	return;
	objLinkTableId = document.getElementById('menu_link_table_' + strLinkTableId);
	objLinkTableId.className = 'table_link_ov';
}

function link_mouseout(strLinkTableId)
{
	return;
	objLinkTableId = document.getElementById('menu_link_table_' + strLinkTableId);
	objLinkTableId.className = 'table_link';
}


function toggle_div(strDivId)
{
	objDiv = document.getElementById(strDivId);

	if(objDiv.style.display=='block')
	{
		objDiv.style.display='none';
	}
	else
	{
		objDiv.style.display='block';
	}
}

function show_help(x, y, name, message)
{
	document.getElementById('help_message').style.left = x-210;
	document.getElementById('help_message').style.top = y-10;
	document.getElementById('help_message').innerHTML = '<table width="100%"  border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF" style="border:1px solid #134596; font-size: 11px;">  <tr><td bgcolor="#134596" style="color:#FFFFFF"><b>'+name+'</b></td></tr><tr><td>'+message+'</td></tr></table>';
	document.getElementById('help_message').style.visibility = 'visible';
}

function hide_help()
{
	document.getElementById('help_message').style.visibility = 'hidden';
}

function show_row_quick_preview(intRowCounter)
{
	objQuickPreview = document.getElementById('row_quick_preview_' + intRowCounter);
	if ( objQuickPreview != undefined )
	{
		objQuickPreview.style.left = xMousePos+20;
		objQuickPreview.style.top  = yMousePos-90;
		objQuickPreview.style.display = 'block';
	}
}

function hide_row_quick_preview(intRowCounter)
{
	objQuickPreview = document.getElementById('row_quick_preview_' + intRowCounter);
	if ( objQuickPreview != undefined )
		objQuickPreview.style.display = 'none';
}

var strOldPageLink = null;
function auto_generate_page_handle()
{
	if(document.getElementById('autolink').checked)
	{
		strOldPageLink = document.getElementById('new_page_handle').value;
		generate_page_handle();
	}
	else
	{
		if ( strOldPageLink == undefined )
			strOldPageLink = '';
		document.getElementById('new_page_handle').value = strOldPageLink;
	}	
}

function generate_page_handle()
{
	set_form_data_changed();
	//if ( document.getElementById('new_page_handle').value )
	//{
	//	if (confirm("Change current page link?"))
	//	{
			//date = new Date();
			strPageName = document.getElementById('page_title').value.toLowerCase();
			strPageName = strPageName.replace(/\s/g, '-');

			strPageName = strPageName.replace(/[^a-z0-9\-]*/gi, '');
			document.getElementById('new_page_handle').value = strPageName;// + '-' + date.getYear() +  zero_fill(date.getMonth(), 2) +  zero_fill(date.getDay(),2) + zero_fill(date.getHours(), 2) + zero_fill(date.getMinutes(), 2) + zero_fill(date.getSeconds(), 2);
			
			process_input_blur(document.getElementById('new_page_handle'));
//			alert(strPageName);
			document.getElementById('link_current_page_handle').value = document.getElementById('new_page_handle').value;
//			alert(document.getElementById('link_current_page_handle').value);
			document.getElementById('link_current_page_handle_human').value = document.getElementById('page_title').value;

			document.getElementById('link_body').value = document.getElementById('page_title').value;
			document.getElementById('link_body_on').value = document.getElementById('page_title').value;

	//	}
	//}
}

function generate_product_detail_page_handle()
{
	if ( document.getElementById('prod_page').value == '' )
	{
		date = new Date();

		str = document.getElementById('prod_sname').value.toLowerCase();
		str = str.replace(' ', '-');
		str = str.replace(/[^a-z0-9\-]*/gi, '');
		document.getElementById('prod_page').value = str + '-' + date.getYear() +  zero_fill(date.getMonth(), 2) +  zero_fill(date.getDay(),2) + zero_fill(date.getHours(), 2) + zero_fill(date.getMinutes(), 2) + zero_fill(date.getSeconds(), 2);
	}
}

function generate_product_detail_title()
{
	if ( document.getElementById('page_metatag_title').value == '' )
		document.getElementById('page_metatag_title').value = document.getElementById('prod_sname').value;
}

function generate_product_detail_page_handle_addscreen()
{
	date = new Date();

	str = document.getElementById('prod_sname').value.toLowerCase();
	str = str.replace(' ', '-');
	str = str.replace(/[^a-z0-9\-]*/gi, '');
	document.getElementById('prod_page').value = str + '-' + date.getYear() +  zero_fill(date.getMonth(), 2) +  zero_fill(date.getDay(),2) + zero_fill(date.getHours(), 2) + zero_fill(date.getMinutes(), 2) + zero_fill(date.getSeconds(), 2);
}

function generate_product_detail_title_addscreen()
{
	document.getElementById('page_metatag_title').value = document.getElementById('prod_sname').value;
}
function zero_fill(str, len)
{
	str = str.toString();
	var ret = '';
	if ( str.length < len )
	{
		for ( var i=0; i< len-str.length; i++ )
			ret = ret + '0';
			
		ret = ret + str;
	}
	
	if ( ret == '' )
		ret = str;
	
	return ret;
}

function clear_field_value(strFieldId)
{
	if ( strFieldId != '' )
	{
		objField = document.getElementById(strFieldId);
		if ( objField != undefined )
			objField.value = '';
	}
}

function generate_link_name()
{
	if ( get_checked_radio_value(document.forms[0].link_to_type) == 'page_handle' )
		strValue = document.getElementById('link_to_page_handle_human').value;
	else
		strValue = document.getElementById('link_url').value;
		
	document.getElementById('link_name').value = strValue;
	document.getElementById('link_body').value = strValue;
	document.getElementById('link_body_on').value = strValue;
}

function generate_link_name_from_page_title()
{
	strValue = document.getElementById('page_title').value;
		
	document.getElementById('link_name').value = strValue;
	document.getElementById('link_body').value = strValue;
	document.getElementById('link_body_on').value = strValue;
}

function prefil_menu_link_body()
{
	if ( document.getElementById('link_body').value == '' )
	{
		document.getElementById('link_body').value		= document.getElementById('link_name').value;
		document.getElementById('link_body_on').value	= document.getElementById('link_name').value;
	}
}

function generate_page_title()
{
	if ( document.getElementById('page_title').value == '' )
	{
		document.getElementById('page_name').value = document.getElementById('page_title').value;
	}
}

function preview_page_url(url, linkpre, linkpost)
{
	if ( document.getElementById('page_handle').value != '' ) 
		document.getElementById('page_link').innerHTML = url + linkpre + document.getElementById('page_handle').value + linkpost;
}

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
		
		//if(typeof(window.document.body)!="undefined" && typeof(document)!="undefined")
		//{
		//	xMousePos = window.event.x+document.body.scrollLeft;
		//	yMousePos = window.event.y+document.body.scrollTop;
		//	xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
		//	yMousePosMax = document.body.clientHeight+document.body.scrollTop;
		//}
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}


function float_to_money(input, boolIgnoreCents, intPrecision)
{
	if ( intPrecision == undefined )
		intPrecision = 2;
		
	input = input.toString();
	input = input.replace(/[^0-9\.]*/gi, '');

	if ( input )
	{
		money = input.split('.');
		if ( money[0].length == 0 )
			dolars = '0';
		else
			dolars = money[0];
	
		if ( boolIgnoreCents )
			return dolars;
			
		if (money.length > 1)
			cents = money[1];
		else
		{
			if ( intPrecision == 4 )
				cents = '0000';
			else
				cents = '00';
		}
			
		if ( intPrecision == 4 )
		{
			switch ( cents.length )
			{
				case 0:
					cents = '0000';
					break;
				case 1:
					cents = cents + '000';
					break;
				case 2:
					cents = cents + '00';
					break;
				case 3:
					cents = cents + '0';
					break;
			}
			
			if ( cents.length > 4)
				cents = cents.substr(0, 4);
		}
		else
		{
			if (cents.length == 0)
				cents = '00';
			if (cents.length == 1)
				cents = cents + '0';
			if ( cents.length > 2)
				cents = cents.substr(0, 2);
		}
			
		return dolars + '.' + cents;
	}
	else
		return '';
}

function loadingScreen()
{
	objInputFields = document.getElementsByTagName('SELECT');
	for ( i=0; i<objInputFields.length; i++)
		objInputFields[i].disabled = true;
	
	objBody = document.body;
	objLayer = document.createElement("DIV");
	
	objLayer.style.position 	= "absolute";
	objLayer.style.visibility 	= "visible";
	objLayer.style.left			= "0px";
	objLayer.style.top			= "0px";
	objLayer.style.height		= "100%";
	
	objLayer.innerHTML = '<div style="z-index:1; filter:alpha(opacity=80); -moz-opacity:0.8; opacity:0.8; background-color:#FFFFFF; width:100%; height:100%"><div style="z-index:2; height:100%; filter:alpha(opacity=100); -moz-opacity:1.0; opacity:1.0; position:relative"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="middle"><table width="300" align="center" border="0" cellspacing="0" cellpadding="20" style="border:3px solid #00084A" bgcolor="#CEE5FF"><tr><td align="center"><font color="#00084A" size="4" face="Arial, Helvetica, sans-serif"><b>Please wait. Loading... </b></font></td></tr></table></td></tr></table></div></div>';
	
	objBody.appendChild(objLayer);
}

var row_selection = Array();
function highlight(obj, table_id, id, action, original_color, new_color)
{
	if ( row_selection[table_id] == undefined )
		row_selection[table_id] = Array();
		
	if (action == 'click')
	{
		if (row_selection[table_id][id] == undefined)
		{
			obj.style.backgroundColor = new_color;
			row_selection[table_id][id] = 1;
			if ( document.getElementById(id) != undefined )
				document.getElementById(id).checked = true;
		} else {
			obj.style.backgroundColor = original_color;
			row_selection[table_id][id] = undefined;
			if ( document.getElementById(id) != undefined )
				document.getElementById(id).checked = false;
		}
	}
	
	if (action == 'over')
	{
		if (row_selection[table_id][id] == undefined)
			obj.style.backgroundColor = new_color;
	}
	
	if (action == 'out')
	{
		if (row_selection[table_id][id] == undefined)
			obj.style.backgroundColor = original_color;
	}
}

function update_field_on_advanced_tab(objSource, strFieldType)
{
	// regular mapping
	strTargetId = objSource.id;
	strTargetId = strTargetId.replace('_simple', '');
	objTarget = document.getElementById(strTargetId);
	objTarget.value = objSource.value;
	process_input_blur(objTarget);
	
	// additional mapping per field
	switch(strFieldType)
	{
		case 'directory_type_name':
			document.getElementById('prod_sname').value = objSource.value;
			process_input_blur(document.getElementById('prod_sname'));
			generate_product_detail_page_handle();
			process_input_blur(document.getElementById('prod_page'));
			break;
	}
}

function update_field_on_simple_tab(objSource, strFieldType)
{
	// regular mapping
	strTargetId = objSource.id + '_simple';
	objTarget = document.getElementById(strTargetId);
	objTarget.value = objSource.value;
	process_input_blur(objTarget);
	
	// additional mapping per field
	switch(strFieldType)
	{
	}
}

function display_sort_order_disabled_message()
{
	alert('Please sort by Order column to enable this feature.');
	return false;
}

function tab_disabled_upon_add(strMessage)
{
	if ( strMessage != undefined )
		alert(strMessage);
	else
		alert('This tab is disabled upon adding process. Please save to continue');
		
	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: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			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.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

BrowserDetect.init();

