//  funzioni javascript per gestione slideshow e menu


// funzione menu ILS



function updateDiv(str,xmlRef)
{

var div='content';
if(xmlRef!='hub')
{
   div='domainContent';
   if(str!='Homepage' && str!='fivePillarsofLeadership')
   {
   	  changeColorMenu(str,xmlRef);
   }
   else
   {
       if(str!='fivePillarsofLeadership')                   //5 PILLARDS AFTER ADD
       {
   	     HomePagePressed(xmlRef);
       }
       else
       {
           FivePillardsPress();
       }
   }
}
if (str=="")
  {
  document.getElementById(div).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(div).innerHTML=xmlhttp.responseText;
      if(str=='Homepage' && xmlRef=='hub')
         $(document).ready(function() {$('.slideshow').cycle({fx: 'fade' });});
      if(str=='InternationalLeadershipSemester' && xmlRef=='ILS')
      {
      	
      }
    }
  }
if(xmlRef=='hub')
{
   xmlhttp.open("GET","php/getXML.php?namepag="+str+"&xmlRef="+xmlRef,true);
   xmlhttp.send();
}

}

function starSlideshow()
{
	   $(document).ready(function() {$('.slideshow').cycle({fx: 'fade' });}); 
}

function menuManager(ID,str,xmlRef)       //ID per decidere se è del menuHUB dinamico o no..fino a 7 menu alto, 8 altro
{

   if(ID<9)   //ID==8 appartiene all'hub ma non cambia nessun tasto
   {
      menuReset();
      if(ID==1){document.getElementById('menu1').innerHTML='<img src="img/layout/menu/home-2.png">';}
      if(ID==2){document.getElementById('menu2').innerHTML='<img src="img/layout/menu/about-2.png">';}
      if(ID==3){document.getElementById('menu3').innerHTML='<img src="img/layout/menu/news-2.png">';}
      if(ID==4){document.getElementById('menu4').innerHTML='<img src="img/layout/menu/programs-2.png">';}
      if(ID==5){document.getElementById('menu5').innerHTML='<img src="img/layout/menu/calendars-2.png">';}
      if(ID==6){document.getElementById('menu6').innerHTML='<img src="img/layout/menu/campus-2.png">';}
      if(ID==7){document.getElementById('menu7').innerHTML='<img src="img/layout/menu/applynow-2.png">';}
   }
   else
   {
      hubLinking();
   }
   updateDiv(str,xmlRef);
}

function menuReset()
{
   document.getElementById('menu1').innerHTML="<a href=index.php?page=Homepage><img src='img/layout/menu/home-1.png'></a>";
	document.getElementById('menu2').innerHTML=" <a href=index.php?page=About><img src='img/layout/menu/about-1.png'></a>";
	document.getElementById('menu3').innerHTML="<a href=index.php?page=News><img src='img/layout/menu/news-1.png'></a>";
	document.getElementById('menu4').innerHTML="<a href=index.php?page=Programs><img src='img/layout/menu/programs-1.png'></a>";
	document.getElementById('menu5').innerHTML="<a href=index.php?page=Calendar><img src='img/layout/menu/calendars-1.png'></a>";
	document.getElementById('menu6').innerHTML="<a href=index.php?page=Campus><img src='img/layout/menu/campus-1.png'></a>";
	document.getElementById('menu7').innerHTML="<a href=index.php?page=Applynow><img src='img/layout/menu/applynow-1.png'></a>";	
}

function hubLinking()
{
	document.getElementById('menu1').innerHTML="<a href=../><img src='../img/layout/menu/home-1.png'></a>";
	document.getElementById('menu2').innerHTML="<a href=../index.php?page=About><img src='../img/layout/menu/about-1.png'></a>";
	document.getElementById('menu3').innerHTML="<a href=../index.php?page=News><img src='../img/layout/menu/news-1.png'></a>";
	document.getElementById('menu4').innerHTML="<a href=../index.php?page=Programs><img src='../img/layout/menu/programs-1.png'></a>";
	document.getElementById('menu5').innerHTML="<a href=../index.php?page=Calendar><img src='../img/layout/menu/calendars-1.png'></a>";
	document.getElementById('menu6').innerHTML="<a href=../index.php?page=Campus><img src='../img/layout/menu/campus-1.png'></a>";
	document.getElementById('menu7').innerHTML="<a href=../index.php?page=Applynow><img src='../img/layout/menu/applynow-1.png'></a>";
}

//menu ILS
function startmenuILS()
{
   document.getElementById('menuContentD').style.display = "block";
	document.getElementById('menu1D').style.display = "none";
	document.getElementById('menu2D').style.display = "none";
	document.getElementById('menu3D').style.display = "none";
	document.getElementById('menu4D').style.display = "none";
	document.getElementById('menu5D').style.display = "none";
	document.getElementById(oldMenuUPpress).style.display = "block";
}

function resetmenuILS()
{
	document.getElementById('menu1D').style.display = "none";
	document.getElementById('menu2D').style.display = "none";
	document.getElementById('menu3D').style.display = "none";
	document.getElementById('menu4D').style.display = "none";
	document.getElementById('menu5D').style.display = "none";
	if(oldMenuUPpress!='')
	      {
	      	         document.getElementById(oldMenuUPpress).style.display = "block";
	      }
}

var oldMenuUPpress='';

function menufuncILS(menuId)
{
   resetmenuILS();
	if(document.getElementById(menuId).style.display == "none")
	{
		
		document.getElementById(menuId).style.display = "block";
	}
}

var oldMenupress='';

function changeColorMenu(str,xmlRef)
{
    if(oldMenupress!=str)
    {
	      document.getElementById(str).style.margin= '0px   6px';
	      document.getElementById(str).style.color= 'black';
	      if(oldMenupress!='' && oldMenupress!='Homepage' && oldMenupress!='fivePillarsofLeadership')
	      {
	      	         document.getElementById(oldMenupress).style.margin= '0px 0px';
	      	         document.getElementById(oldMenupress).style.color= 'white';
	      }
	      oldMenupress=str;
	      if(xmlRef=='ILS')
	      {
	        if(str=='InternationalLeadershipSemester' || str=='SummerStudyAbroad' || str=='PreUniversityProgram' || str=='ILSQuickFacts'||str=='WhatisILS'||str=='LeadershipDevelopment'){oldMenuUPpress='menu1D';}
	        if(str=='LetterfromthePresident'||str=='Classes'||str=='Accreditation'||str=='TheCampusandUniversity'||str=='MeettheStaff' || str=='ImageSymposium'){oldMenuUPpress='menu2D';}
	        if(str=='Excellence'||str=='Authenticity'||str=='Faith'||str=='Tenacity'||str=='Teamwork'){oldMenuUPpress='menu3D';}
	        if(str=='Activities'||str=='TheRomeAdvantage'||str=='StudentQuotes'||str=='StudentVideosandblogs'||str=='HelpfulLinks'||str=='FAQS'){oldMenuUPpress='menu4D';}
	        if(str=='Requirements'||str=='Deadlines'||str=='Costs'||str=='Tuition'||str=='ApplicationForm'){oldMenuUPpress='menu5D';}
	
	        resetmenuILS();
	      }
	      if(xmlRef=='undergraduate' || xmlRef=='mba' || xmlRef=='criminology')
	      {
	        if(str=='Diploma'|| str=='AdvancedDiploma'|| str=='TopUpDegree'|| str=='AboutUs'||str=='Whoweare' ||str=='AboutUs' ||str=='WhySwissEducation'||str=='Whatwelookforinyou'||str=='VisionandMission'||str=='MBA'||str=='DualMBA'||str=='ExecutiveMBA'||str=='DistanceLearningMBA'){oldMenuUPpress='menu1D';document.getElementById('menu1D').style.display = "block";}
	        if(str=='LetterfromthePresident'||str=='Coreclassesandconcentrations'|| str=='CriminologyCoursework' ||str=='Calendar'||str=='Uniqueteachingmethodology'||str=='Accreditation'||str=='TheCampusandUniversity'||str=='Meetthestaff' || str=='ImageSymposium'){oldMenuUPpress='menu2D';document.getElementById('menu2D').style.display = "block";}
	        if(str=='EntryVisa'||str=='TheRomeAdvantage'||str=='Jobs'||str=='Testimonials'||str=='FAQS'||str=='HelpfulLinks'){oldMenuUPpress='menu3D';document.getElementById('menu3D').style.display = "block";}
	        if(str=='Requirements'||str=='ApplicationForm'||str=='Tuition Fees'|| str=='TuitionFees' || str=='MBATuitionFees'||str=='DualMBATuitionFees'||str=='ExecutiveTuitionFees'||str=='DistanceTuitionFees'){oldMenuUPpress='menu4D';document.getElementById('menu4D').style.display = "block";}
	        resetmenuUndergraduate();
	      }
	 }
}


//menu Undergraduate
function startmenuUndergraduate()
{
   document.getElementById('menuContentD').style.display = "block";
	document.getElementById('menu1D').style.display = "none";
	document.getElementById('menu2D').style.display = "none";
	document.getElementById('menu3D').style.display = "none";
	document.getElementById('menu4D').style.display = "none";
	document.getElementById(oldMenuUPpress).style.display = "block";
}



function resetmenuUndergraduate()
{
	document.getElementById('menu1D').style.display = "none";
	document.getElementById('menu2D').style.display = "none";
	document.getElementById('menu3D').style.display = "none";
	document.getElementById('menu4D').style.display = "none";
	if(oldMenuUPpress!='')
	      {
	      	         document.getElementById(oldMenuUPpress).style.display = "block";
	      }
}

var oldMenuUPpressUndergraduate='';

function menufuncUndergraduate(menuId)
{
   resetmenuUndergraduate();
	if(document.getElementById(menuId).style.display == "none")
	{
		
		document.getElementById(menuId).style.display = "block";
	}
}

var oldMenupressUndergraduate='';

function HomePagePressed(xmlRef)
{
       if(xmlRef!='ILS')
       {
       	oldMenuUPpress = 'menu1D';
         resetmenuUndergraduate();
	      if(oldMenupress!='')
	      {
	         document.getElementById(oldMenupress).style.margin= '0px 0px';
	         document.getElementById(oldMenupress).style.color= 'white';
	      }
	    }
	    else
	    {
	      oldMenuUPpress = 'menu1D';
         resetmenuILS();
	      if(oldMenupress!='' && oldMenupress!='fivePillarsofLeadership' )
	      {
	         document.getElementById(oldMenupress).style.margin= '0px 0px';
	         document.getElementById(oldMenupress).style.color= 'white';
	      }
	    }
	    oldMenupress='Homepage';
}


function FivePillardsPress()
{
	      oldMenuUPpress = 'menu3D';
         resetmenuILS();
	      if(oldMenupress!='' && oldMenupress!='Homepage')
	      {
	         document.getElementById(oldMenupress).style.margin= '0px 0px';
	         document.getElementById(oldMenupress).style.color= 'white';
	      }
	      oldMenupress='fivePillarsofLeadership';
}

function slideMBA(pos)
{
	     document.getElementById('choose1').style.display= "none";
	     document.getElementById('choose2').style.display= "none";
	     document.getElementById('choose3').style.display= "none";
	     document.getElementById('choose4').style.display= "none";
	     document.getElementById('choose5').style.display= "none";
	     document.getElementById('choose6').style.display= "none";
	     if(pos==1)
	     {
	     	       document.getElementById('choose1').style.display= "block";
	     }
	     if(pos==2)
	     {
	     	       document.getElementById('choose2').style.display= "block";
	     }
	     if(pos==3)
	     {
	     	       document.getElementById('choose3').style.display= "block";
	     }
	     if(pos==4)
	     {
	     	       document.getElementById('choose4').style.display= "block";
	     }
	     if(pos==5)
	     {
	     	       document.getElementById('choose5').style.display= "block";
	     }
	     if(pos==6)
	     {
	     	       document.getElementById('choose6').style.display= "block";
	     }
}

function learnMore()
{
   document.getElementById('learnMore').style.display= "block";
}
function SurveyMonkeyILS()
{
	      window.open('http://www.surveymonkey.com/s.aspx?sm=g1JxeCCtVzxc8edATZEb7Q%3d%3d', 'surveywindow', 'height=350,width=500,scrollbars=yes,resizable=yes,status=yes');
}
function SurveyMonkeyMBA()
{
	      window.open('http://www.surveymonkey.com/s/KCFFXTD', 'surveywindow', 'height=350,width=500,scrollbars=yes,resizable=yes,status=yes'); 
}
