
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// Create the XML HTTP request object. We try to be
// more cross-browser as possible.
function CreateXmlHttpReq(handler) {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}

// An handler that does nothing, used for AJAX requests that
// don't require a reply and are non-critical about error conditions.
function DummyHandler() {
    return true;
}

// Shortcut for creating a GET request and get the reply
// This few lines of code can make Ajax stuff much more trivial
// to write, and... to avoid patterns in programs is sane!
function ajaxGet(url,handler) {
    var a = new Array("placeholder");
    for (var j=2; j<arguments.length; j++) {
        a[a.length] = arguments[j];
    }
    var ajax_req = CreateXmlHttpReq(DummyHandler);
    var myhandler = function() {
        var content = ajaxOk(ajax_req);
        if (content !== false) {
            a[0] = content;
            try {
                return handler.apply(this, a);
            } catch(e) {
                return myDummyApply(handler, a);
            }
        }
    }
    ajax_req.onreadystatechange = myhandler;
    ajax_req.open("GET",url);
    ajax_req.send(null);
}

// IE 5.0 does not support the apply() method of the function object,
// we resort to this eval-based solution that sucks because it is not
// capable of preserving 'this' and is ugly as hell, but it works for us.
function myDummyApply(funcname,args) {
    var e = "funcname(";
    for (var i = 0; i < args.length; i++) {
        e += "args["+i+"]";
        if (i+1 != args.length) {
            e += ",";
        }
    }
    e += ");"
    return eval(e);
}

// Add a random parameter to the get request to avoid
// IE caching madness.
function ajaxGetRand(url,handler) {
    url += (url.indexOf("?") == -1) ? "?" : "&";
    url += "rand="+escape(Math.random());
    arguments[0] = url;
    try {
        return ajaxGet.apply(this,arguments);
    } catch(e) {
        return myDummyApply(ajaxGet,arguments);
    }
}

function ajaxOk(req) {
    if (req.readyState == 4 && req.status == 200) {
        return req.responseText;
    } else {
        return false;
    }
}

function $sethtml(html,id) {
    document.getElementById(id).innerHTML = html;
    loadLinks();
}


function live_form_submit()
{
	
	if(document.live_form.data.value != '' && document.live_form.nome_evento.value != '' && document.live_form.descrizione.value != '' && document.live_form.luogo.value != '' && document.live_form.mail.value != '')
	{
		document.live_form.submit();		
	}
	else
	{
		alert("Tutti i campi sono obbligatori");
		return false;	
	}
	
}


hs.graphicsDir = 'highslide/graphics/';
hs.outlineType = 'rounded-white';
window.onload = function() {
   hs.preloadImages(5);
}
	function myGetElementById(id_name)
	{
		if (document.getElementById && !window.opera)
		{
		  var obj = document.getElementById(id_name);         
		}
		else if(document.all)
		{
		  var obj = document.all.id_name;
		}   	
		
		return obj;		
	}

	function refreshfocus()
	{
		if(myGetElementById('focus_container') != null)
		{
			ajaxGet('refreshfocus.html',$sethtml,'focus_container');
		}
	}

	function sendmailinglist(div_id, input_id, tomail)
	{
		var obj = myGetElementById(input_id);
		var mail = obj.value;
		
		ajaxGet('add_to_mailinglist.php?tomail='+tomail+'&mail='+mail);

		toggleVisibility(div_id, "switch");
		
		alert("Grazie per esserti iscritto alla mailing list di Roma Rock School!");
	}
      
    	function toggleVisibility(id_name, action)
    	{
			var obj = myGetElementById(id_name);
			
			if(action=="switch")
			{
				if(obj.style.visibility == "hidden" || obj.style.visibility == "")
				{
					obj.style.visibility="visible";
				}
				else
				{
					obj.style.visibility="hidden";
				}
			}
			else if (action=="hidden")
			{
				obj.style.visibility="hidden";
			}
			else
			{
				obj.style.visibility="visible";
			}  
	}
	
	

		
	function set_prof_contents(contents)
	{
		var container_desc_prof = myGetElementById('prof_contents');
		
		container_desc_prof.innerHTML = contents;
	}
	
	function change_button_image(name)
	{
		var diploma_professionale_button = myGetElementById("diploma_professionale_button");
		var coach_certificate_button = myGetElementById("coach_certificate_button");
		var giornalismo_musicale_button = myGetElementById("giornalismo_musicale_button");
		
		if(name == 'diploma_professionale')
		{
			document[name+'_image'].src = 'images/diploma_professionale_sel.jpg';
			document['coach_certificate_image'].src = 'images/coach_certificate_up.jpg';
			document['giornalismo_musicale_image'].src = 'images/giornalismo_musicale_up.jpg';
			
			diploma_professionale_button.onmouseout = new Function('');
			diploma_professionale_button.onmouseover = new Function('');
											
			coach_certificate_button.onmouseout = new Function('MM_swapImgRestore()');
			coach_certificate_button.onmouseover = new Function("MM_swapImage('coach_certificate','','images/coach_certificate_roll.jpg',1)");
											
			giornalismo_musicale_button.onmouseout = new Function('MM_swapImgRestore()');
			giornalismo_musicale_button.onmouseover = new Function("MM_swapImage('giornalismo_musicale','','images/giornalismo_musicale_roll.jpg',1)");			
		}
		else if(name == 'coach_certificate')
		{
			document[name+'_image'].src = 'images/coach_certificate_sel.jpg';
			document['diploma_professionale_image'].src = 'images/diploma_professionale_up.jpg';
			document['giornalismo_musicale_image'].src = 'images/giornalismo_musicale_up.jpg';

			diploma_professionale_button.onmouseout = new Function('MM_swapImgRestore()');
			diploma_professionale_button.onmouseover = new Function("MM_swapImage('diploma_professionale','','images/diploma_professionale_roll.jpg',1)");

			coach_certificate_button.onmouseout = new Function('');
			coach_certificate_button.onmouseover = new Function('');
			
			giornalismo_musicale_button.onmouseout = new Function('MM_swapImgRestore()');
			giornalismo_musicale_button.onmouseover = new Function("MM_swapImage('giornalismo_musicale','','images/giornalismo_musicale_roll.jpg',1)");			
		}
		else if(name == 'giornalismo_musicale')
		{
			document[name+'_image'].src = 'images/giornalismo_musicale_sel.jpg';
			document['coach_certificate_image'].src = 'images/coach_certificate_up.jpg';
			document['diploma_professionale_image'].src = 'images/diploma_professionale_up.jpg';
			
			diploma_professionale_button.onmouseout = new Function('MM_swapImgRestore()');
			diploma_professionale_button.onmouseover = new Function("MM_swapImage('diploma_professionale','','images/diploma_professionale_roll.jpg',1)");

			coach_certificate_button.onmouseout = new Function('MM_swapImgRestore()');
			coach_certificate_button.onmouseover = new Function("MM_swapImage('coach_certificate','','images/coach_certificate_roll.jpg',1)");
			
			giornalismo_musicale_button.onmouseout = new Function('');
			giornalismo_musicale_button.onmouseover = new Function('');		
		} 
	}
		    	
		    	
		    	
function loadLinks()
{
    var temp = document.getElementsByTagName("a");
    //alert(temp.length);
        for (i=0;i< temp.length;i++) {
        		//alert(temp[i].onclick);
        		if(!temp[i].onclick)
        		{
        			//alert(temp[i].onclick);
            	temp[i].onclick = clicky;
            }
        }
}
function clicky() {
   
    //var blah = this.innerHTML;
		//alert(this.href);
		//alert(this.target);

		var myRegExp = /www.romarockschool.com/;
		var myRegExp2 = /.html/;
		var string1 = this.href;
		var matchPos1 = string1.search(myRegExp);
		var matchPos2 = string1.search(myRegExp2);
		
		if(matchPos1 != -1 && matchPos2 != -1)
		{
			//alert("There was a match at position " + matchPos1); 
			var is_internal = 1;
			
			//if(this.target == '_blank')
			//{
			//	this.href = this.href;
				//var is_blank = 1;
			//}
			//else
			//{
			//	var is_blank = 0;	
			//}
		}
		else
		{
			//alert("There was no match in the first string");
			var is_internal = 0;
		}
		
		if(is_internal)
		{
			ajaxGet(this.href,$sethtml,'site_container');
			return false;			
		}
}    	