function preview_resource_center(id){
	
	var width  = 820;
	var height = 660;
	var left   = (screen.width  - width) / 2;
	var top    = ((screen.height - height) / 2) * .5;
	window.open(webroot + 'media/index/id:' + id, 'riswindow', 'status=no, directories=no, menubar=no, resizable=yes, scrollbars=yes, toolbar=no, location=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);	

	return false;
}
	
function _generate_button(id, button) {
    var _url = 'http://rrein.rismedia.com/media/index/id:' + id;
    document.write('<a href="#" onclick="_open_resource_center(\'' + _url + '\')"><img src="http://rrein.rismedia.com/img/buttons/' + button + '" border="0" /></a>');
}

function _new_generate_button(id, button) {
    var _url = 'http://rrein.rismedia.com/media/index/id:' + id;
    document.write('<a href="#" onmouseover="http://rrein.rismedia.com/img/buttons/icon-resource2.gif" onclick="_open_resource_center(\'' + _url + '\')" ><img src="http://rrein.rismedia.com/img/buttons/' + button + '" border="0" name="rollover"/></a>');
}

function _generate_link(id, title) {
	var _url = 'http://rrein.rismedia.com/media/index/id:' + id;
     document.write('<a href="#" onclick="_open_resource_center(\'' + _url + '\')">' + title + '</a>');
}

function _custom_button(id, action, image) {
	var _url = 'http://rrein.rismedia.com/media/' + action + '/id:' + id;
	document.write('<a href="#" onclick="_open_resource_center(\'' + _url + '\')" ><img src="' + image + '" border="0" /></a>');
}

function _open_resource_center(url) {
    var width  = 820;
	var height = 660;
	var left   = (screen.width  - width) / 2;
 	var top    = ((screen.height - height) / 2) * .5;
 	window.open(url, 'top5window', 'status=no, directories=no, menubar=no, resizable=yes, scrollbars=yes, toolbar=no, location=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);	
	if (window.focus) {riswindow.focus()}
 	return false;
 		
}

function isValidEmail(email){
   var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(email);
} 

function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
} 

function addError(error) {
	$("#notice").hide();
	$("#error").html(error);
	$('#error').removeClass('hidden').addClass('visible');
}

function show_spinner() {
	$("#submit_button").hide();
	$("#spinner").fadeIn(100);
}

function hide_spinner() {
	$("#spinner").hide();
	$("#submit_button").fadeIn(100);
}

function swap_icon(dom_id){
	$("#" + dom_id).hide();
	$("#" + dom_id).attr("src", "http://rrein.rismedia.com/img/ajax-loader.gif");
	$("#" + dom_id).fadeIn(100);
}

function validateProtocol() {
	 $(".link").each( function() {	 	
	 	if($(this).val() && $(this).val().search(":") == -1){
	 		var link = "http://" + $(this).val();
	 		$(this).val(link);
	 	} 
  	});
	return false;
}

function hide_notices(){
	$("#heading").hide(); 
	$("#notice").hide(); 
	$("#error").hide();
}

//preload images
var image = new Image();
image.src = 'http://rrein.rismedia.com/img/ajax-loader.gif';


