/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
var id='';
var code='';
var thispage='';
var letter='';
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();
/* -------------------------- */
/* INSERT */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;

//Individual Ajax functions for different purposes
//************************************************

//Search Function for AEC CCAF Codes
function showCourseCatalog(str) 
{
		//alert(id.length+' - '+code.length);
		// Optional: Show a waiting message in the layer with ID login_response
		document.getElementById('CourseLinks').innerHTML = "Loading Catalog  <img src=\'../../../images/ajax-loaderred.gif\' />"
		// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
		//var id=  encodeURI(id);
		//var code=  encodeURI(code);
		// Set te random number to add to URL request
		nocache = Math.random();
		var url = 'scripts/getlinks.php?q='+str+'&nocache = '+nocache;
		// Pass the login variables like URL variable
		http.open('get', url);
		http.onreadystatechange = returnLinks;
		http.send(null);
}

function returnLinks()
{
	if(http.readyState == 4)
		{ 
		response = http.responseText;
		//response holds the name and ID returned from 'insertFaculty.php'
		//and it is displayed on the page by the 'Go' button
		document.getElementById('CourseLinks').innerHTML = response;
		}
}
/*//Search Function for Course Codes
function showCourseCatalog1(str) 
{
		//alert(id.length+' - '+code.length);
		// Optional: Show a waiting message in the layer with ID login_response
		document.getElementById('CourseLinks1').innerHTML = "Loading Catalog  <img src=\'../../../images/ajax-loaderred.gif\' />"
		// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
		//var id=  encodeURI(id);
		//var code=  encodeURI(code);
		// Set te random number to add to URL request
		nocache = Math.random();
		var url = 'scripts/getlinks_course.php?q='+str+'&nocache = '+nocache;
		// Pass the login variables like URL variable
		http.open('get', url);
		http.onreadystatechange = returnLinks1;
		http.send(null);
}

function returnLinks1()
{
	if(http.readyState == 4)
		{ 
		response = http.responseText;
		//response holds the name and ID returned from 'insertFaculty.php'
		//and it is displayed on the page by the 'Go' button
		document.getElementById('CourseLinks1').innerHTML = response;
		}
}*/
//Save funtion for temp table
function SaveSelection(id, code, course, credits, ace, ccaf, description) 
{
		//alert(id.length+' - '+code.length);
		// Optional: Show a waiting message in the layer with ID login_response
		document.getElementById('Selection').innerHTML = "Loading Catalog  <img src=\'../../images/ajax-loaderred.gif\' />"
		// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
		//var id=  encodeURI(id);
		//var code=  encodeURI(code);
		// Set te random number to add to URL request
		nocache = Math.random();
		var url = 'scripts/save.php?id='+id+'&code='+code+'&course='+course+'&credits='+credits+'&ace='+ace+'&ccaf='+ccaf+'&description='+description+'&nocache = '+nocache;
		// Pass the login variables like URL variable
		http.open('get', url);
		http.onreadystatechange = returnSaves;
		http.send(null);
}

function returnSaves()
{
	if(http.readyState == 4)
		{ 
		response = http.responseText;
		//response holds the name and ID returned from 'insertFaculty.php'
		//and it is displayed on the page by the 'Go' button
		document.getElementById('Selection').innerHTML = response;
		}
}
//popup for tuts
function popup1(url)
{
	window.open(url,'name','height=525,width=920,toolbar=none,menubar=none,location=none,scrollbars=no,resizable=no')
}
function returnpopup(){
	if(http.readyState == 4)
	{
		response = http.reponseText
		document.getElementsByClassName('main').innerHTML = reponse;
	}
}

//about window
  function outsideWindow(className,title,url) {
	  //alert (url)
    var win = new Window("", {className: className, top:40, left:50, width:600, height:400, title:title,url:url,
                          maximizable: false, minimizable: true});
    win.setDestroyOnClose();
	win.showCenter();
    win.show();
	http.onreadystatechange = returnoutsideWindow;
  }
  function returnoutsideWindow() {
    if(http.readyState == 4)
		{ 
		
		response = http.responseText;
		//response holds the name and ID returned from 'insertFaculty.php'
		//and it is displayed on the page by the 'Go' button
		document.getElementById('container').innerHTML = response;
		}
  }
//customize site
function custom(){
//alert ('bg_color');
window.open("http://www.richardorobinson.com/portfolio/home.php?cus=yes","main");
}

//Delete function for temp table
function theme(str) 
{
window.location ='scripts/theme.php?theme='+str+'&nocache='+nocache;
}

function add(caption, url, httplink)
{
	window.location ='scripts/add.php?caption='+caption+'&url='+url+'&httplink='+httplink+'&nocache='+nocache;
}
function add1(caption, url, httplink)
{
	window.location ='scripts/add.php?caption='+caption+'&url='+url+'&httplink='+httplink+'&nocache='+nocache;
}
function add2(caption, url, httplink)
{
	window.location ='scripts/add.php?caption='+caption+'&url='+url+'&httplink='+httplink+'&nocache='+nocache;
}
function add3(caption, url, httplink)
{
	window.location ='scripts/add.php?caption='+caption+'&url='+url+'&httplink='+httplink+'&nocache='+nocache;
}
function add4(caption, url, httplink)
{
	window.location ='scripts/add.php?caption='+caption+'&url='+url+'&httplink='+httplink+'&nocache='+nocache;
}
function deletepic(id)
{
	window.location ='scripts/delete.php?id='+id+'&nocache='+nocache;
}
