function handleEvent(mouseMove) 
{
	document.getElementById('floatbox').style.left = (mouseMove.screenX + 20)+"px";
	document.getElementById('floatbox').style.top = (mouseMove.screenY - 120)+"px";
}

function FloatBoxHandle(visible, text)
{
	if(visible == 1)
	{
		document.getElementById('floatbox').style.visibility = 'visible';
	}
	else
	{
		document.getElementById('floatbox').style.visibility = 'hidden';
	}
	document.getElementById('floatbox').innerHTML = text;
}
// confirm whatever action
function ConfirmAction(question, relocate)
{
	if(confirm(question))
	{
		window.location = relocate;
	}
}
// *confirm whatever action

// highlight a comment (to see replyto)
function HighlightComment(id, on)
{
	if(on == true)
	{
		document.getElementById(id).style.background = '#EEE';
	}
	else
	{
		document.getElementById(id).style.background = 'none';
	}
}
// *highlight a comment (to see replyto)
// quote a comment
function Quote(statement, commentField)
{
	location = '#form';
	document.getElementById(commentField).value = statement;
}
// *quote a comment

//Search functions
function ActivateBox(searchbox, value)
{
	document.getElementById(searchbox).style.color = '#333';
	if(document.getElementById(searchbox).value == value)
	{
		document.getElementById(searchbox).value = '';
	}
}
function DeactivateBox(searchbox, value)
{
	document.getElementById(searchbox).style.textAlign = 'center';
	if(document.getElementById(searchbox).value == '')
	{
		document.getElementById(searchbox).style.color = '#AAA';
		document.getElementById(searchbox).value = value;
	}
}
//*Searcj fimctopms

// Rating star handeling
function StarHandle(articleId, starNum)
{
	for(b = 0; b <= 9; b++)
	{
		document.getElementById('article'+articleId+'star'+(b)).src = 'http://profilefort.com/images/star.png';
	}
	for(b = 0; b <= 9; b++)
	{
		document.getElementById('article'+articleId+'star'+(starNum - b)).src = 'http://profilefort.com/images/star-active.png';
		if((starNum % 10) - b == 0)
		{
			break;
		}
	}
}
function StarReset(articleId, articleRating)
{
	if(document.getElementById('article'+articleId+'star'+(b)).src != 'http://profilefort.com/images/star-disabled.png')
	{
		for(b = 0; b <= 9; b++)
		{
			document.getElementById('article'+articleId+'star'+(b)).src = 'http://profilefort.com/images/star.png';
		}
		for(c = 0; c < articleRating; c++)
		{
			document.getElementById('article'+articleId+'star'+(c)).src = 'http://profilefort.com/images/star-active.png';
		}
	}
}
//* Rating star handeling

// Admin menu handeling
function ExpandMenu()	
{
	document.getElementById('admin-menu').style.visibility = 'visible';
}

function CollapseMenu()
{
	document.getElementById('admin-menu').style.visibility = 'hidden';
}
//* Admin menu handeling

// style update needed (ONLY IE7) in case of rating stars shown above profiles
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();

//Browser name: BrowserDetect.browser
//Browser version: BrowserDetect.version
//OS name: BrowserDetect.OS

function IE7optimize()
{
	if((BrowserDetect.browser == 'Explorer' && BrowserDetect.version <= '7') && document.getElementById('profile_pic_info'))
	{
		// IE7 not compatible with stars above pictures
		//alert('Sorry - rendering is not precise');
		for(var y = 1; y <= 10000; y++)
		{
			if(document.getElementById(y))
			{
				document.getElementById(y).style.visibility = 'hidden';
			}
			else
			{
				break;
			}
		}
	}
}
//* style update needed (ONLY IE7) in case of rating stars shown above profiles

// needed in about - textx in pictures rendered bad
function OperaOptimize()
{
	if((BrowserDetect.browser == 'Opera') && document.getElementById('operahide1'))
	{
		document.getElementById('operahide1').style.visibility = 'hidden';
		document.getElementById('operahide2').style.visibility = 'hidden';
		document.getElementById('operahide3').style.visibility = 'hidden';
	}
}


// Profile composing wizard
function OpenProfileWizard(wizard, tab)
{
	document.getElementById(wizard).style.visibility = 'visible';
	document.getElementById("cover").style.visibility = 'visible';
	
	OpenTab(tab);
}

function CloseProfileWizard(wizard)
{
	document.getElementById(wizard).style.visibility = 'hidden';
	document.getElementById("cover").style.visibility = 'hidden';
	
	OpenTab(0); // to hide all wizard window
}

function FinishWizard(wizard, begin, end)
{
	// copy all textareas into the original one
	document.getElementById('maintext').value = '';
	document.getElementById('imagetext').value = '';
	document.getElementById('spectext').value = '';
	for(var i = begin; i <= end; i++)
	{
		if(document.getElementById('wizardtext'+i))
		{
			if(i != 2 && i != 12)
			{
				if(i == 1 || i == 11) // 1 and 11 are about texts the other are specification texts
				{
					document.getElementById('maintext').value += document.getElementById('wizardtext'+i).value;
				}
				else if(i == 3 || i == 13)
				{
					document.getElementById('imagetext').value += document.getElementById('wizardtext'+i).value;
				}
				else
				{
					document.getElementById('spectext').value += document.getElementById('wizardtext'+i).value;
				}
			}
		}
	}
	CloseProfileWizard(wizard);
}
function CopyImageText(from, to)
{
	var copytext = document.getElementById(from).value;
	//document.getElementById(to).value += '[-][link]'+copytext+'[img]'+copytext+'[/img][/link][/]';
	document.getElementById(to).value += copytext+'\n';
}
function DisplayImage(source, img)
{
	document.getElementById(img).src = document.getElementById(source).value;
	document.getElementById('prev'+img).src = document.getElementById(source).value; // also preview on the main page not only in the wizard
}
function OpenTab(x)
{
	// handle tabs in profile wizard
	for(var i = 0; i <= 32; i++)
	{
		if(document.getElementById('tab'+i))
		{
			document.getElementById('tab'+i).style.color = '#999';
			document.getElementById('wizardtext'+i).style.visibility = 'hidden';
			document.getElementById('wizardtext'+i).style.position = 'absolute';
		}
	}
	document.getElementById('tab'+x).style.color = '#000';
	document.getElementById('wizardtext'+x).style.visibility = 'visible';
	document.getElementById('wizardtext'+x).style.position = 'relative';
}
// *Profile composing wizard
