var affiliateId = 4036;
var numberOfAds = 1;
var ipms_style = 0;
var ipms_instance = 0;

var menuShown = new Array(2);
var pause = 0;
var googleShown = 0;
var ticktock = 0;
var userticktock = 0;
var opacity = 0;

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_reloadPage(init) {//reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_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];}
}

function preloadImages() {
var imagesToLoad = ["border_2nd_page.gif","border.gif","title.jpg","login_bg.jpg","login_bg_over.jpg","top_acc.jpg","btm_acc.jpg","input_bg.gif","green_button.jpg","green_button_over.jpg","divhead.jpg","buttons.jpg"]

for (var i = 0; i < imagesToLoad.length; i++) {
MM_preloadImages('/' + path_to_theme + '/images/' + imagesToLoad[i]);
}
}

function popupSearch(id) {
window.open('/' + path_to_theme + '/windowads.php?ad=' + id, 'popupSearch', 'width=385,height=350,scrollbars=1,resizable=1');
}

function menuShow(menutype,id) {
var temp = (menutype == "bysubject") ? 1 : 0;

// Hide
for (var i = 1; i < 255 && document.getElementById(menutype + i); i++) { }
var lastItem = i-1;

for (i = 1; i <= lastItem; i++) {
if (i != id)
document.getElementById(menutype + i).style.display = 'none';
}

if (menuShown[temp] == menutype + id) {
document.getElementById(menutype + id).style.display = 'none';
menuShown[temp] = 0;
return;
}

// Show
eval("document.getElementById(menutype + id).style.display = 'block'");
menuShown[temp] = menutype + id;
//eval("setTimeout('menuShown[" + temp + "] = \"" + menutype + id + "\";', 20)");
}

function googleMenu(id,timeout) {
if (timeout != 0 && ticktock == 1) timeout--;
else if (ticktock == 1) {
document.getElementById('google' + id).style.display = 'none';
eval("document.getElementById('googlelink" + id + "').style.background = '#005995'");
eval("document.getElementById('googlelink" + id + "').style.color = '#FFFFFF'");
ticktock = 0;
googleShown = 0;
return;
}
if (timeout == 10 && googleShown != id) {
googleShown = id;
for (var i = 1; i < 255 && document.getElementById('google' + i); i++) { }
var lastItem = i-1;

for (i = 1; i <= lastItem; i++) {
if (i != id) {
document.getElementById('google' + i).style.display = 'none';
opacity = 0;
eval("document.getElementById('googlelink" + i + "').style.background = '#005995'");
eval("document.getElementById('googlelink" + i + "').style.color = '#FFFFFF'");
}
}
document.getElementById('google' + id).style.display = 'block';
eval("document.getElementById('googlelink" + id + "').style.background = '#8DC54C'");
eval("document.getElementById('googlelink" + id + "').style.color = '#000000'");
}
if (ticktock == 1)
eval("setTimeout('googleMenu(" + id + "," + timeout + ")',30)");
}

function userMenu(id,timeout) {
if (!document.getElementById('accountlink') || !document.getElementById('loglink')) return;
if (timeout != 0 && userticktock == 1) timeout--;
else if (userticktock == 1) {
//menuFade('myaccountmenu',0);
document.getElementById('myaccountmenu').style.display = 'none';

if (id == 'accountlink0')
document.getElementById('accountlink').style.backgroundImage = 'url(/' + path_to_theme + '/images/login_bg.jpg)';
else if (id == 'accountlink1')
document.getElementById('accountlink').style.backgroundImage = 'url(/' + path_to_theme + '/images/green_button.jpg)';

userticktock = 0;
return;
}
if (timeout == 10 && opacity == 0) {
document.getElementById('myaccountmenu').style.display = 'block';
//menuFade('myaccountmenu',1);
}
if (userticktock == 1)
eval("setTimeout('userMenu(\"" + id + "\"," + timeout + ")',40)");
}

function menuFade(obj,mode) {
document.getElementById(obj).style.opacity = '.' + opacity;
document.getElementById(obj).style.filter = 'alpha(opacity=' + opacity + ')';
if (mode == 1) {
if (opacity == 85)
return;
opacity += 17;
}
else {
if (opacity == 0) {
document.getElementById(obj).style.display = 'none';
return;
}
opacity -= 17;
}
eval("setTimeout('menuFade(\""+ obj +"\"," + mode + ")',30)");
}

function randomize(delay,current) {
if (pause == 0) {
for (var i = 1; i < 255 && document.getElementById('school' + i); i++) { }
var lastItem = i-1;

do {
var random_school = Math.floor(Math.random() * lastItem) + 1;
} while (random_school == current);

for (i = 1; i <= lastItem; i++) {
if (i != random_school)
document.getElementById('school' + i).style.display = 'none';
}
document.getElementById('school' + random_school).style.display = 'block';
}

if (delay) {
eval("setTimeout('randomize(' + delay + ',' + random_school + ')',delay)");
}
}

function urlToggle(id,url) {
if (!document.getElementById(id))
document.location = url;
var elem = document.getElementById(id);
if (elem.style.display != "block")
elem.style.display = "block";
else
elem.style.display = "none";
}

function chooseCriteria() {
var criterias = new Array("destination","level","subject","concentration","school");
for (i = 0; i < criterias.length; i++) {
document.getElementById(criterias[i]).style.display = "none";
}
var criteriaSelected = document.getElementById("criteria").value;
document.getElementById(criteriaSelected).style.display = "block";
}

function validate(id) {
if (document.getElementById(id).value != "select")
document.location = document.getElementById(id).value;
}



var http_request = false;

function makeRequest(url,request) {

http_request = false;

if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}

if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = updateTarget;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
http_request.send('id=' + request);

document.getElementById("ipms_select").disabled = true;
}

function updateTarget() {

if (http_request.readyState == 4) {
if (http_request.status == 200) {
var code = http_request.responseText;
var allpairs = code.split("|");

var elem = document.getElementById("schools");
elem.innerHTML = "";

var selections = '<select id="ipms_select" name="ipms_select" style="width: 264px"><option value="">Show all</option>';
for (i = 0; i < allpairs.length; i++) {
var pair = allpairs[i].split("=");
var text = pair[0];
var value = pair[1];
if (typeof value != "undefined")
selections = selections + '<option value="'+ value +'">'+ text +'</option>';
}

selections = selections + '</select>';

elem.innerHTML = selections;
document.getElementById("ipms_select").disabled = false;
}
else {
alert('There was a problem with the request.');
}
}

} 