/*
	* showRows() / hideRows() are functions that hide/show tablerows
	8/01/2009 - MJ
*/

function showRows(selector)
{
	var rows = $(selector);
	rows.show();
}

function hideRows(selector)
{
	var rows = $(selector);
	rows.hide();
}

function showPopup(selector)
{
	centreFakePopup(selector);
	$(selector).fadeIn(1000);
}

function closePopup(selector)
{
	$(selector).fadeOut(1000);
}

function centreFakePopup(selector)
{
	var width = parseInt($("body").width());
	var height = parseInt($("body").height());
	var x = width - parseInt($(selector).width());
	var y = height - parseInt($(selector).height());

	var promo = $(selector + " img");
	var img = promo[0];	

	if( img ) {
		var w = img.width;
		var h = img.height;		
		$(selector).css("width", w);
		$(selector).css("height", "10%");
	}

	x = x/2;
	y = y/2;	
	$(selector).css("left", x);
	$(selector).css("top", y);		
}

function isValidEmail(value)
{
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$");
	value = String(value);
	return !(!r1.test(value) && !r2.test(value));
}

function parseXMLDocResult(result) {    
	var xmlDoc;    
	if (typeof result == "string") {        
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");        
		xmlDoc.async = "false";        
		xmlDoc.loadXML(result);    
	} else {        
		xmlDoc = result;    
	}    
	return xmlDoc;
}
