﻿// JScript File
var sabis = 
{
	vroot: "",
	_pageInit: [],
	_SearchMsg: "Search Site...",
	AppendInit: function(obj)
	{
		sabis._pageInit.push(obj);
	},
	init: function(vroot)
	{
		sabis.vroot = vroot;
		for(var i = 0; i < sabis._pageInit.length; i++)
			if("function" == typeof sabis._pageInit[i])
				sabis._pageInit[i]();
	},
	CheckSiteSearch: function (f, ac)
	{
		if("focus" == ac && f.value.Trim() == sabis._SearchMsg)
		{
			f.value = '';
			f.style.color= f.oldColor;
		}
		if ("blur" == ac && f.value.Trim() == '') 
		{
			f.oldColor = f.style.color;
			f.value = sabis._SearchMsg;
			f.style.color = "#a0a0a0";
		}
	},
	_initSiteSearch: function()
	{
		var sq = document.getElementById("SearchQuerry");
		if(sq)
		{
			sq.onfocus = new Function("sabis.CheckSiteSearch(this, 'focus');");
			sq.onblur = new Function("sabis.CheckSiteSearch(this, 'blur');");
			sq.value = "";
			sq.onblur();
			var sf = document.forms["SearchForm"];
			sf.onsubmit = function()
			{
				var err = sq.value.Trim() == sabis._SearchMsg || 
					sq.value.Trim() == "";
				if(err)
				{
					alert("Please enter your search querry!");
					sq.focus();
					return false;
				}
					
			}
		}
	}
};
function Bookmark()
{
	var url = location.href;
	var title = "The International Schools of Choueifat UAE";
	if((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
	{
		window.external.AddFavorite(url, title);
		return;
	}
	try
	{
		window.sidebar.addPanel(title, url, "");
	}
	catch(e)
	{
	    alert("Press CTRL-D or CTRL-T(Opera) to bookmark");
	}
}

function NewsStep(el, step)
{
	if(sabis.LastNewsElement == step)
		return;
	Ext.Element.DISPLAY = true;

	var oldEl = sabis.LastNewsElement;
	sabis.LastNewsElement = step;
	
	sabis.NewsEls[oldEl].switchOff({
		remove: false,
		easing: 'easeIn',
		callback: function()
		{
			sabis.NewsEls[sabis.LastNewsElement].slideIn("b", {
				callback: function()
				{
					Ext.Element.DISPLAY = false;
				}
			});
		}
	});
	if(sabis.oldNewsStepEl)
		sabis.oldNewsStepEl.removeClass("hhover");
	sabis.oldNewsStepEl = Ext.get(el);
	Ext.get(el).addClass("hhover");
}
function TestiStep(step)
{
	var dir = step == 1? "r": "l";
	if(!sabis.TestiEls)
	{
		sabis.LastTestiElement = 0;
		sabis.TestiEls = [];
		var el = Ext.get("TestiList");
		var child = el.first();
		var i = 0;
		while(child != null)
		{
			sabis.TestiEls.push(child);
			if(i > 0)
				child.setStyle("display", "none");
			child = child.next();
			i++;
		}
	}
	Ext.Element.DISPLAY = true;

	step += sabis.LastTestiElement;
	if(step >= sabis.TestiEls.length)
		step = 0;
	else if(step < 0)
		step = sabis.TestiEls.length - 1;

	var oldEl = sabis.LastTestiElement;
	sabis.LastTestiElement = step;
	
	sabis.TestiEls[oldEl].slideOut(dir, {
		remove: false,
		easing: 'easeOut',
		callback: function()
		{
			sabis.TestiEls[sabis.LastTestiElement].slideIn(dir == "r"? "l": "r",
			{
				easing: "easeOut",
				callback: function()
				{
					Ext.Element.DISPLAY = false;
				}
			});
		}
	});
}