﻿function OpenPopUp(width, height, name, url)
{
	win_width = width;
	win_height = height;
	top_x = (screen.width - win_width) / 2;
	top_y = (screen.height - win_height) / 2 - 30;
	var win = window.open(url, name, 'scrollbars=yes,status=no,resizable=no,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
	win.focus();
}

function EditTextBlock(id)
{
	win_width = 800;
	win_height = 600;
	top_x = (screen.width - win_width) / 2;
	top_y = (screen.height - win_height) / 2 - 30;
	window.open('/framework/TextEdit.aspx?block=' + id, 'text' + id, 'scrollbars=no,status=no,resizable=yes,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
}

function PageAdd()
{
	win_width = 550;
	win_height = 600;
	top_x = (screen.width - win_width) / 2;
	top_y = (screen.height - win_height) / 2 - 30;
	window.open('/framework/PageEdit.aspx', 'page', 'scrollbars=yes,status=no,resizable=no,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
}

function EditPage(id)
{
	win_width = 550;
	win_height = 600;
	top_x = (screen.width - win_width) / 2;
	top_y = (screen.height - win_height) / 2 - 30;
	window.open('/framework/PageEdit.aspx?id=' + id, 'page' + id, 'scrollbars=yes,status=no,resizable=no,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
}

function PhraseAdd(lang)
{
	win_width = 500;
	win_height = 250;
	top_x = (screen.width - win_width) / 2;
	top_y = (screen.height - win_height) / 2 - 30;
	window.open('/framework/PhraseEdit.aspx?lang=' + lang, 'phrasenew', 'scrollbars=yes,status=no,resizable=no,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
}

function PhraseDiscover(name)
{
	win_width = 500;
	win_height = 250;
	top_x = (screen.width - win_width) / 2;
	top_y = (screen.height - win_height) / 2 - 30;
	window.open('/framework/PhraseEdit.aspx?lang=' + lang, 'phrasenew', 'scrollbars=yes,status=no,resizable=no,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
}

function EditPhrase(id)
{
	win_width = 500;
	win_height = 250;
	top_x = (screen.width - win_width) / 2;
	top_y = (screen.height - win_height) / 2 - 30;
	window.open('/framework/PhraseEdit.aspx?id=' + id, 'phrase' + id, 'scrollbars=yes,status=no,resizable=no,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
}

function ManagePageSet(group_id, lang_name)
{
	win_width = 800;
	win_height = 600;
	top_x = (screen.width - win_width) / 2;
	top_y = (screen.height - win_height) / 2 - 30;
	window.open('/framework/ManagePageSet.aspx?group=' + group_id + '&lang=' + lang_name, 'group' + group_id, 'scrollbars=yes,status=no,resizable=no,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
}

//function ClassifierEdit(ClassifierName)
//{
//	win_width = 400;
//	win_height = 500;
//	top_x = (screen.width - win_width) / 2;
//	top_y = (screen.height - win_height) / 2 - 30;
//	window.open('/admin/ClassifierEdit.aspx?name=' + ClassifierName, 'name' + ClassifierName, 'scrollbars=yes,status=no,resizable=no,left='+top_x+',top='+top_y+',width='+win_width+',height='+win_height+'');	
//}

function HighlightRow(theRow, theRowNum, theAction, theDefaultColor, thePointerColor)
{
	var theCells = null;

	// 1. Pointer and mark feature are disabled or the browser can't get the
	//    row -> exits
	if (thePointerColor == '' || typeof(theRow.style) == 'undefined')
		return false;

	// 2. Gets the current row and exits if the browser can't get it
	if (typeof(document.getElementsByTagName) != 'undefined')
	{
		theCells = theRow.getElementsByTagName('td');
		//alert(theRow);
	}
	else if (typeof(theRow.cells) != 'undefined')
	{
		theCells = theRow.cells;
	}
	else
	{
		return false;
	}

	// 3. Gets the current color...
	var rowCellsCnt  = theCells.length;
	var domDetect    = null;
	var currentColor = null;
	var newColor     = null;
	// 3.1 ... with DOM compatible browsers except Opera that does not return
	//         valid values with "getAttribute"
	if (typeof(window.opera) == 'undefined'	&& typeof(theCells[0].getAttribute) != 'undefined')
	{
		currentColor = theCells[0].getAttribute('bgcolor');
		domDetect    = true;
	}
	// 3.2 ... with other browsers
	else
	{
		currentColor = theCells[0].style.backgroundColor;
		domDetect    = false;
	} // end 3

	// 4. Defines the new color
	// 4.1 Current color is the default one
//	if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase())
//	{
		if (theAction == 'over')
			newColor = thePointerColor;
//	}
//	// 4.1.2 Current color is the pointer one
//	else if (currentColor.toLowerCase() == thePointerColor.toLowerCase())
//	{
		if (theAction == 'out')
		{
			newColor = theDefaultColor;
		}
//	}
	// end 4
//alert(newColor);
	// 5. Sets the new color...
	if (newColor)
	{
		var c = null;
		// 5.1 ... with DOM compatible browsers except Opera
		if (domDetect)
		{//alert(rowCellsCnt);
			for (c = 0; c < rowCellsCnt; c++)
			{
				theCells[c].style.backgroundColor = newColor;
				//theCells[c].setAttribute('bgcolor', newColor, 0);
			} // end for
		}
		// 5.2 ... with other browsers
		else
		{
			for (c = 0; c < rowCellsCnt; c++)
			{
				theCells[c].style.backgroundColor = newColor;
			}
		}
	} // end 5

	return true;
} // end of the 'HighlightRow()' function
 
function HighlightCell(theCell, theRowNum, theAction, theDefaultColor, thePointerColor)
{
	var domDetect    = null;
	var currentColor = null;
	var newColor     = null;
	// 3.1 ... with DOM compatible browsers except Opera that does not return
	//         valid values with "getAttribute"
	if (typeof(window.opera) == 'undefined'	&& typeof(theCell.getAttribute) != 'undefined')
	{
		currentColor = theCell.getAttribute('bgcolor');
		domDetect    = true;
	}
	// 3.2 ... with other browsers
	else
	{
		currentColor = theCell.style.backgroundColor;
		domDetect    = false;
	} // end 3

	// 4. Defines the new color
	// 4.1 Current color is the default one
//	if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase())
//	{
		if (theAction == 'over')
			newColor = thePointerColor;
//	}
//	// 4.1.2 Current color is the pointer one
//	else if (currentColor.toLowerCase() == thePointerColor.toLowerCase())
//	{
		if (theAction == 'out')
		{
			newColor = theDefaultColor;
		}
//	}
	// end 4
//alert(newColor);
	// 5. Sets the new color...
	if (newColor)
	{
		var c = null;
		// 5.1 ... with DOM compatible browsers except Opera
		if (domDetect)
		{
			theCell.style.backgroundColor = newColor;
		}
		// 5.2 ... with other browsers
		else
		{
			theCell.style.backgroundColor = newColor;
		}
	} // end 5

	return true;
} // end of the 'HighlightCell()' function

