 
//// only execute code if 'getElementsByTagName' and 'outerHTML' are supported
//if (document.getElementsByTagName && document.body.outerHTML) {
//    // repeat code for each affected tag
//    var tags = ['object','embed','applet'];

//    for (var i in tags) {
//        // get all elements with tag
//        var objs = document.getElementsByTagName(tags[i]);

//        for (var j=0;j < objs.length;j++) {
//            var obj = objs.item(j);

//            // find param tags within object
//            var params = obj.getElementsByTagName('param');
//            var inner = '';

//            // if there are params, but param tags can't be found within innerHTML
//            if (params.length && !/<param/i.test(obj.innerHTML))
//                // add all param tags to 'inner' string
//                for (var x=0;x < params.length;x++)
//                    inner += params.item(x).outerHTML;

//            // put 'inner' string with param tags in the middle of the outerHTML
//            obj.outerHTML = obj.outerHTML.replace('>', '>' + inner);
//        }
//    }
//}

 
 
        function go(page){ 
             window.location=page; 
        } 
        
        window.onerror = function () { return true }
function addLoadEvent(func) {
		  var oldonload = window.onload;
		  if (typeof window.onload != 'function') {
			window.onload = func;
		  } else {
			window.onload = function() {
			  if (oldonload) {
				oldonload();
			  }
			  func();
			}
		  }
		}

function isActive(text)
{
 var el = document.getElementById("buttonResult");
 if(text.length >0)
 {
  el.innerHTML = "<span style='color:red;font-size:14px;'>"+text+" is active</span>";
  el.style.visibility="visible";
 }
 else
 {
  el.innerHTML = "";
  el.style.visibility="hidden";
 }
}

function butClick(id)
{
 if(id.getStatus()=='enabled')
    id.setActive();
 else
 if(id.getStatus()=='active')
    id.unsetActive();
}

function ProductsLoad(protectCategoryID,Edited,evt)

		{  
		    if (BrowserDetect.browser != 'Firefox'){
		        if (!event) event = window.event; 
                event.cancelBubble = true; 
            }
	        //if (e.stopPropagation) e.stopPropagation();
			if (isNaN(protectCategoryID))
				CategoryID = 0;
			ob_post.AddParam("pageID", protectCategoryID);
			ob_post.AddParam("Edited", Edited);
			ob_post.post(null, "GetCategoryContent", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
			//ob_post.UpdateAllPanels();
						
		}
		
function ProductsLoad2(protectCategoryID,evt)

		{  
		    if (BrowserDetect.browser != 'Firefox'){
		        if (!event) event = window.event; 
                event.cancelBubble = true; 
            }
	        //if (e.stopPropagation) e.stopPropagation();
			if (isNaN(protectCategoryID))
				CategoryID = 0;
			ob_post.AddParam("cID", protectCategoryID);
			ob_post.post(null, "LoadCategoryContent", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
			//ob_post.UpdateAllPanels();
						
		}
		
function OnChange(dropdown,pageid,calid,schoolid)
{
    var myindex  = dropdown.selectedIndex
    ob_post.AddParam("_viewID", myindex);
    ob_post.AddParam("_pageID", pageid);
    ob_post.AddParam("_calID", calid);
     ob_post.AddParam("_schoolID", schoolid);
	ob_post.post(null, "ChangeCalendar", function(){});
	ob_post.UpdatePanel("CallbackPanel1");
}


function DeleteCalendar(calid,pageid)

		{ 
		var answer = confirm ("Are you sure?.  This action cannot be undone.")

        if (answer){
            alert("Calendar Deleted");
			ob_post.AddParam("calendarID", calid);
			ob_post.AddParam("pageID", pageid);
			ob_post.post(null, "DeleteCalendar", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
			}
			
		}		
		
		
		
function ChangeCalendar(calid)

		{  alert(calid);
		alert(document.getElementById('drpView').value);
			ob_post.AddParam("calendarID", calid);
			ob_post.post(null, "ChangeCalendar", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
		}	
		
function SaveCart(calid)

		{  
		
			
			ob_post.post(null, "SaveCart1", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
		}			
		
		
function finishProductsLoad() {
	ob_post.UpdatePanel("CallbackPanel1");
}	
		
function Tab_OnClick(id)
{

ProductsLoad(id,"False");

}

function Cell_OnClick(evtargs)
{
alert(evtargs);
cellLoad(evtargs);

}

function cellLoad(evtargs)

		{  
//		    if (BrowserDetect.browser != 'Firefox'){
//		        if (!event) event = window.event; 
//                event.cancelBubble = true; 
//            }
//	        //if (e.stopPropagation) e.stopPropagation();
//			if (isNaN(protectCategoryID))
//				CategoryID = 0;
//			ob_post.AddParam("pageID", protectCategoryID);
//			ob_post.AddParam("Edited", Edited);
//			ob_post.post(null, "GetCategoryContent", function(){});
//			ob_post.UpdatePanel("CallbackPanel1");
			//ob_post.UpdateAllPanels();
						
		}
		
function eventsreLoad(protectCategoryID,Edited,viewid)
		{ 
		
			if (isNaN(protectCategoryID))
				CategoryID = 0;
			ob_post.AddParam("pageID", protectCategoryID);
			ob_post.AddParam("Edited", Edited);
			ob_post.AddParam("_viewID", viewid);
			ob_post.post(null, "GetCategoryContent", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
		}		
function eventfull_OnClick(id,viewid)

{  	   
eventsreLoad(id,"False",viewid);
}

function panelsLoad(protectCategoryID,Edited)
		{ 
		
			if (isNaN(protectCategoryID))
				CategoryID = 0;
			ob_post.AddParam("pageID", protectCategoryID);
			ob_post.AddParam("Edited", Edited);
			ob_post.post(null, "GetCategoryContent", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
		}

function TabReLoad()
		{
			ob_post.post(null, "LoadTabs", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
		}
function panel_OnClick(id)
{  	       panelsLoad(id,"False");
}

function ApproveItem()
		{
			ob_post.post(null, "ApproveItem", function(){});
		}

function aprint(id,arch)
{   
	       showPopWinMAP('print/printarticle.aspx?id='+ id +'&arch=1', 630, 375, null);
}

function aprintevent(id)
{   
	       showPopWinMAP('print/printevent.aspx?id='+ id + '', 630, 375, null);
}




function popItScroll(theLink){ 
	window.open(theLink,null,'height=800,width=700,scrollbars=yes,resizable=yes'); 
	
}
function showIt(theBox){
    if(theBox.style.display==""){
        theBox.style.display="none";
    }else{
        theBox.style.display="";
   
    }
}
function toggleIt(theBox){
    if(theBox.style.display=="none"){
        new Effect.Appear(theBox);
    }else{
        new Effect.Fade(theBox);
   
    }
}
function insertlink()
{
  var ctrl = document.getElementById("txtMainText");
  var saveText = ctrl.value;
  ctrl.focus();
  var range = document.selection.createRange();
  var specialchar = String.fromCharCode(1);
  range.text = specialchar;
  var pos = ctrl.value.indexOf(specialchar);
  ctrl.value = saveText;
  range = ctrl.createTextRange();
  range.move('character', pos);
  range.select();
  range.text = "{LINK}" + document.getElementById("txtLinkText").value + "{$LINK}" + document.getElementById("txtLinkTitleText").value + "{!LINK}";
  document.getElementById("txtMainText").focus();
  window.event.returnValue = false;
}

function insertpagelink(pageID)
{
  var ctrl = document.getElementById("txtMainText");
  var saveText = ctrl.value;
  ctrl.focus();
  var range = document.selection.createRange();
  var specialchar = String.fromCharCode(1);
  range.text = specialchar;
  var pos = ctrl.value.indexOf(specialchar);
  ctrl.value = saveText;
  range = ctrl.createTextRange();
  range.move('character', pos);
  range.select();
  range.text = "{PAGE}" + document.getElementById("drpPageSelect").value + "{$PAGE}" + document.getElementById("txtLinkTitleText").value + "{!PAGE}";
  document.getElementById("txtMainText").focus();
  window.event.returnValue = false;
}

function GetVideo(videoID,pageID)
		{

			ob_post.AddParam("videoID", videoID);
			ob_post.AddParam("pageID", pageID);
			ob_post.post(null, "GetVideo", function(){});
			ob_post.UpdatePanel("CallbackPanel1");

		}
function GetAudio(audioID,pageID)
		{

			ob_post.AddParam("audioID", audioID);
			ob_post.AddParam("pageID", pageID);
			ob_post.post(null, "GetAudio", function(){});
			ob_post.UpdatePanel("CallbackPanel1");

		}
function GetNewsArticle(newsID,pageID)
		{
			if (isNaN(newsID))
				CategoryID = 0;
			ob_post.AddParam("newsID", newsID);
			ob_post.AddParam("pageID", pageID);
			ob_post.post(null, "GetNewsArticle", function(){});
			ob_post.UpdatePanel("CallbackPanel1");

		}
function GetFullEvent(eventid,viewid,pageid)

		{ 
			ob_post.AddParam("eventID", eventid);
			ob_post.AddParam("_viewID", viewid);
			ob_post.AddParam("_pageID", pageid);
			ob_post.post(null, "GetFullEvent", function(){});
			ob_post.UpdatePanel("CallbackPanel1");
		}			
function GetEvent(eventID)
		{
			if (isNaN(eventID))
				CategoryID = 0;
			ob_post.AddParam("eventID", eventID);
			ob_post.post(null, "GetEvent", function(){});
			ob_post.UpdatePanel("CallbackPanel1");

		}function GetAllNews(pageID,Status,schoolID)
		{
			if (isNaN(pageID))
				CategoryID = 0;
			ob_post.AddParam("pageID", pageID);
			ob_post.AddParam("Status", Status);
			ob_post.AddParam("schoolID", schoolID);
			ob_post.post(null, "GetAllNews", function(){});
			ob_post.UpdatePanel("CallbackPanel1");

		}	
		
		function GetAllNewsArticle(newsID,pageID)
		{
			if (isNaN(newsID))
				CategoryID = 0;
			ob_post.AddParam("newsID", newsID);
			ob_post.AddParam("pageID", pageID);
			ob_post.post(null, "GetAllNewsArticle", function(){});
			ob_post.UpdatePanel("CallbackPanel1");

		}	
		
		
			function modal_popup(page,id)
	{
		/* create an AJAX request */
		var ajax = _.ajax();
		var rID=id;

		ajax.removeAllFields();
		ajax.addField("id",rID);

		ajax.oncomplete=ajax_complete;
		ajax.onerror=ajax_error;

		g_Modal.show("<img  src='6.gif' alt='' title='' />");

		g_Modal.disableClose();

		/* Post data to the server. */
		ajax.get(page);

		/* Stop event propagation. */
		//new EventObject(evt).cancelDefaultAction();
	}
	
		function document_dblclick(evt,id)
	{
		
	}
		
			
		function window_resize(evt)
	{
		adjustHeight();
	}

	function adjustHeight()
	{
		var intWindowHeight=WindowObject.getInnerDimension().getY();
		var dynModalBG=new DynamicLayer("ModalBG");
		var intModalHeight=dynModalBG.getHeight();

		if(intModalHeight<intWindowHeight)
		{
			dynModalBG.setHeight(intWindowHeight);
		}
	}

	function addExtensionsForOpera()
	{
		/* classes for opera */
		var ModalBG=new CBObject("ModalBG").getObject();
		if(typeof(window.opera)!="undefined")
		{
			ModalBG.className="modalOpera";
		}
	}

	function attachOpacityCSS()
	{

		var opacityCSS = document.createElement("link");
		opacityCSS.type="text/css";
		opacityCSS.rel="stylesheet";
		opacityCSS.href="Opacity.css";
		document.getElementsByTagName("head")[0].appendChild(opacityCSS);
	}

	function doc_dblclick(evt,id)
	{
		/* create an AJAX request */
		var ajax = _.ajax();
		var rID=id;

		ajax.removeAllFields();
		ajax.addField("id",rID);

		ajax.oncomplete=ajax_complete;
		ajax.onerror=ajax_error;

		g_Modal.show("<img  src='6.gif' alt='' title='' />");

		g_Modal.disableClose();

		/* Post data to the server. */
		ajax.get("admin/AdminRouteNews.aspx");

		/* Stop event propagation. */
		new EventObject(evt).cancelDefaultAction();
	}
	
	

	/* Triggered when a successful AJAX response comes from the server.*/
	function ajax_complete(strResponseText,objResponseXML)
	{  
	
		g_Modal.show(strResponseText);
		
		/* Re-activate close button. */
		g_Modal.enableClose();
	}

	/* Triggered when server generates an error. */
	function ajax_error(intStatus,strStatusText)
	{
		g_Modal.show("Error code: ["+ intStatus+ "] error message: [" + 
			strStatusText + "].");

		/* Re-activate close button. */
		g_Modal.enableClose();
	}
	function SaveNewsArticle(newsID,pageID)
		{alert("HH");
			if (isNaN(newsID))
				CategoryID = 0;
			ob_post.AddParam("newsID", newsID);
			ob_post.AddParam("xid", pageID);
			ob_post.post("adminroutenews.aspx", "SaveNewsArticle", function(){});
			//ob_post.UpdatePanel("CallbackPanel1");

		}
		
		
		
		
		
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
		
		
