/**
 * 
 * @version $Id: default.js 1026 2009-06-03 12:53:10Z midget $
 * 
 * @license http://www.midworld-networks.com/licenses/outsoursing.html
 * @author Dario Minnucci <dario.minnucci@midworld-networks.com>
 * @copyright Copyright 2009, Dario Minnucci
 *            <dario.minnucci@midworld-networks.com>
 * 
 * @package midworld.net
 * @subpackage javascript
 * @access public
 * 
 */

//
//
// Usage:
// center_win('property.php?cpid=a87ff679a2f3e71d9181a67b7542122c', 780, 400,
// 'location=0,status=0,scrollbars=1');
//
function center_win(url, width, height, options) {
	var centerX = (screen.width - width) / 2;
	var centerY = ((screen.height - height) / 2) - 55;

	var default_options = 'width=' + width + ',height=' + height + ',top='
			+ centerY + ',screenY=' + centerY + ',left=' + centerX
			+ ',screenX=' + centerX;

	if (options) {
		//alert( default_options +','+options  );
		window.open(url, 'centerWin', default_options + ',' + options);
	} else {
		window.open(url, 'centerWin', 'resizable=no,' + default_options);
	}
}

//
//
//
function hide_row(element) {
	document.getElementById(element).style.display = "none";
}

//
//
//
function show_row(element) {
	document.getElementById(element).style.display = "table-row";
}

//
//
//
function errorLayout() {
	var cssErrorLayout = {
		'background-color' : '#FCFCA0',
		'border-color' : '#CC0000',
		'color' : '#CC0000'
	};
	return cssErrorLayout;
}

//
//
//
function mark_element(element) {
	//alert("mark_element will be DEPRECATED soon!. Please use errorLayout() method since now!");
	document.getElementById(element).style['borderColor'] = "#CC0000";
	document.getElementById(element).style['backgroundColor'] = "#FCFCA0";
	document.getElementById(element).style['color'] = "#CC0C00";
}

//
//
//
function unmark_element(element) {
	//alert("mark_element will be DEPRECATED soon!. Please use errorLayout() method since now!");
	document.getElementById(element).style['borderColor'] = "default";
	document.getElementById(element).style['backgroundColor'] = "default";
	document.getElementById(element).style['color'] = "default";
}

//
//
//
function proxy(event, cpid) {
	alert(event + '|' + cpid);
	// document.getElementById( element ).style['borderColor'] = "default";
	// document.getElementById( element ).style['backgroundColor'] = "default";
	// document.getElementById( element ).style['color'] = "default";
}

//
// Set maxLength aon textareas
//
function setMaxLen(Object, MaxLen) {
	return (Object.value.length <= MaxLen);
}

//
// Sanitize strings
//
function sanitize(s) {
	var ns = s;

	if (ns) {
		ns = ns.gsub(/[\ \ ]/i, '\ ');
		ns = ns.gsub(/[&]/i, '&amp;');
		ns = ns.gsub(/[\+]/i, '\\+');
	}
	// alert( "old string : "+s+"\nsanitized : "+ns );

	return ns;
}
