$(function(){
	var width = 425;
	var height = 600;
	var left = (screen.width/2)-(width/2);
	var top = (screen.height/2)-(height/2);								   

	var element = document.getElementsByTagName('a');

	
	/*for(i=0; i<element.length; i++){
	//	console.log('element : ' , element[i].rel)
		if(element[i].rel == 'popup'){
	    	element[i].onclick = function(){
				console.log(element[i].rel);
				openWindow(element[i].href , width , height , left , top);
				return false;
			}
	    }
	}*/

	
		$('a[rel="popup"]').click(function(){
			openWindow(this.href , width , height , left , top);
			return false;
		});
	
});

function openWindow(url, w , h, x, y){
	var default_w = 400;
	var default_h = 500;
	
	var screen_w = screen.width;
	var screen_h = screen.height;
	
	var wW = (w != null) ? w : default_w;
	var wH = (h != null) ? h : default_h;
	
	var wX = (x != null) ? x : Math.round(screen_w / 2 - (wW / 2));
	var wY = (y != null) ? y : Math.round(screen_h / 2 - (wH / 2));
	
	popup = window.open(url, 'RonCacique', 'resizable=0,scrollbars=yes,status=0,location=0,toolbar=0,menubar=0,width=' + wW + ',height=' + wH + ',screenX=' + wX + ',screenY=' + wY + ',left=' + wX + ',top=' + wY + '');
}