// JavaScript Document

//this function renders a div with a specific height
function renderDiv(height)
{
	document.write("<div style=\"height:"+ height +"px; font-size: 1px;\"></div>");
}
//end of function

function showContent(number)
{
	for(i = 1; i <= 5; i++)
	{
		closeDiv("content"+i);	
	}
	
	openDiv("content"+number);	

}//end of function 

function openPreview(active_id)
{
	//for(i = 1; i<=6 ;i++)
	//{
		/*var folder = document.getElementById("preview"+ i).style
		if (folder.display=="")
		{	
			Effect.Fade("preview"+ i);
		}
		*/
		//closeDiv("preview"+ i)
		/*closeDiv("preview"+ 1)
		closeDiv("preview"+ 2)
		closeDiv("preview"+ 3)
		closeDiv("preview"+ 4)
		closeDiv("preview"+ 5)
		closeDiv("preview"+ 6)*/
	//}
	if(active_id == 2)
	{   	
		closeDiv('preview1');
		document.getElementById('preview1').innerHTML = "<a href=\"http://globalscholar.us\"><img src=\"images/globalscholar_preview.jpg\" class=\"previewImg\" ></a>The new Global Scholar Online Courses can help you before going abroad, while abroad and after returning home to use your international learning to help make a difference... for your education, your career and your future.";
		document.getElementById('arrow_position').className = "arrow1"; 
		new Effect.Appear('preview1');	
	}
	else if(active_id == 3)
	{   	
		closeDiv('preview1');
		document.getElementById('preview1').innerHTML = "<a href=\"http://allabroad.us\"><img src=\"images/allabroad_preview.jpg\"  class=\"previewImg\"/></a>Allabroad.us was created as a resource for students, parents, faculty, and staff interested in study abroad. In it, you will find answers from our mentors to questions about study abroad and resources to help in outreach on campus and at the K-12 level to help others.";
		document.getElementById('arrow_position').className = "arrow2"; 
		new Effect.Appear('preview1');	
	}
	else if(active_id == 4)
	{   	
		closeDiv('preview1');
		document.getElementById('preview1').innerHTML = "<a href=\"http://globaled.us/plus\"><img src=\"images/plus_preview.jpg\"  class=\"previewImg\"/></a>The Project For Learning In The United States (PLUS) is an integrated international student preparation, training, and support program.  Through the PLUS Project, we are creating resources for international students before, during, and after study in the U.S.";
		document.getElementById('arrow_position').className = "arrow3"; 
		new Effect.Appear('preview1');	
	}
	else if(active_id == 5)
	{   	
		closeDiv('preview1');
		document.getElementById('preview1').innerHTML = "<a href=\"http://studentsabroad.com\"><img src=\"images/studentsabroad_preview.jpg\"  class=\"previewImg\"/></a>The Student Study Abroad Handbook provides resources and preparation tips for students considering study abroad. The General and 30 Country-Specific Handbooks help you ask the right questions and find helpful resources for international study and travel.";
		document.getElementById('arrow_position').className = "arrow4"; 
		new Effect.Appear('preview1');	
	}
	else if(active_id == 6)
	{   	
		closeDiv('preview1');
		document.getElementById('preview1').innerHTML = "<a href=\"http://globaled.us/safeti\"><img src=\"images/safeti_preview.jpg\"  class=\"previewImg\"/></a>The SAFETI (Safety Abroad First - Educational Travel Information) Clearinghouse provides resources for faculty and staff that help support study abroad program development and implementation, emphasizing issues of health and safety. ";
		document.getElementById('arrow_position').className = "arrow5"; 
		new Effect.Appear('preview1');	
	}
	
	//new Effect.Appear('preview' + active_id);	
	//new Effect.SlideDown('preview' + active_id, {duration: 1.9});	
}



function validate()
{
	x=document.myForm
	at=x.emailaddress.value.indexOf("@")
	name=x.name.value
	email=x.emailaddress.value
	phone=x.phone.value
	confirms = x.confirms.value
	
	if (at==-1) 
	{
	 	alert("Not a valid e-mail!")
	 	document.getElementById("emailaddress").focus();
		return false;
	}
	
	if (email.length < 1 || email == "Enter Your Email Address")
	{
		alert("email adress is required")
	 	document.getElementById("emailaddress").focus();
		return false;
	}
	
	if (name.length < 1 || name == "Enter Your Fullname")
	{
	 	alert("name is required")
	 	document.getElementById("name").focus();
		return false;
	}
	
	if (phone.length < 1 || phone == "Enter Your Phone Number")
	{
		alert("phone number is required")
		document.getElementById("phone").focus();
		return false;
	}
	
	if(confirms.length < 1 || confirms == "Enter the Confirmation Characters")
	{
		alert("Please verify the security code")
		document.getElementById("confirms").focus();
		return false;
	}
	
	return true;
	 
}

function openDiv(id)
{
	var folder = document.getElementById(id).style
	if (folder.display=="none")
	{	
		folder.display=""
	}
}//end of function

function closeDiv(id)
{
	var folder = document.getElementById(id).style
	if (folder.display=="")
	{	
		folder.display="none"
	}
}//end of function

function spantitle(id)
{
						
	var folder = document.getElementById(id).style
	if (folder.display=="none")
	{	
		folder.display=""
	}
	else
	{	
		folder.display="none"
	}		
}//end of function

/* AJAX function begins  */


function createXMLHttpRequest() {
    try {return new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {}
    try {return new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}
    try {return new XMLHttpRequest();} catch(e) {}
    return null;
}//end of function 

function postAndFetchXml(url, content, handler) 
{
   
	
	var xmlhttp = createXMLHttpRequest();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

   xmlhttp.onreadystatechange = function() 
   {
        
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            handler(xmlhttp.responseXML);
        }
    };
	//alert(url);
	//alert(content);

    xmlhttp.open('POST', url);	
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(content);
	
}//end of function 


function postAndFetch(url, content, handler) 
{
	
	var xmlhttp = createXMLHttpRequest();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

  
	   //indicator.innerHTML="<div><img src='images/indicator.gif'></div>";
   
   xmlhttp.onreadystatechange = function() 
   {
        
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
            handler(xmlhttp.responseText);
        }
    };

    xmlhttp.open('POST', url, true);	
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(content);
	
}//end of function 


function postAndFetchResponse(url, content, handler, area_id) 
{
	
	var xmlhttp = createXMLHttpRequest();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

  
	   //indicator.innerHTML="<div><img src='images/indicator.gif'></div>";
   
   xmlhttp.onreadystatechange = function() 
   {
        
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
            handler(xmlhttp.responseText, area_id);
        }
    };

    xmlhttp.open('POST', url, true);	
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(content);
	
}//end of function 

function generalHandlerWrite(Text, area_id)
{
	
	//alert(Text);
	var str= Text;
	
	var content = Text
	//alert(holder);
	
	var updateform = document.getElementById(area_id);
	   updateform.innerHTML=content;
}

function generalHandler(Text)
{
	
	//alert(Text);
	var str= Text;
	
	var content = Text
	//alert(holder);
	
	var updateform = document.getElementById(area_id);
	   updateform.innerHTML=content;
}

function generalHandler_reorder(Text, area_id)
{
	
	//alert(Text);
	
	var content = Text
	//alert(holder);
	
	var updateform = document.getElementById(area_id);
	   updateform.innerHTML=content;
	make_list('module_list');
}




function updateHTML(id, content)
{
	var updateform = document.getElementById(id);
	   updateform.innerHTML=content;	
}

function updateValue(id, input)
{
	var updateform = document.getElementById(id);
	   updateform.value= input;	
}//end of function 


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];}}
}


