// ISA SharePoint JavaScript
// Author: Daniel Reed
// Copyright(c) 2007 ISA Technologies. All rights reserved.
 
	function  printProperties(obj) {
		var output = "" ;
		for (var prop in obj) {
			output += prop + " = " + obj[prop] + "\n" ;
		}
		alert(output);
	}
	
	//determine what browser style to get css
	var cssRules;
	if (document.all) {
		cssRules = 'rules';
	}
	else if (document.getElementById) {
		cssRules = 'cssRules';
	}
	
	//endswith function
	function endsWith(str, s){
		var reg = new RegExp(s + "$");
		return reg.test(str);
	}
	
	//get an attribute from one of the vivid css files
	function getStylesheetRule0(stylesheet, id){
		//look in each stylesheet
		for (var i = 0; i < stylesheet[cssRules].length; i++) {
			if(stylesheet[cssRules][i].selectorText == id ){
				var rule = stylesheet[cssRules][i];
				return rule;
			}
		}
		//look in stylesheet children
		for (var j = 0; j < stylesheet.imports.length; j++) {
			var importRule = getStylesheetRule0(stylesheet.imports[j], id);
			
			if(importRule !=null){
				return importRule ;
			}
		}
	}
	
	function getStylesheetRule(id){
		for (var i = 0; i < document.styleSheets.length; i++){
			var stylesheet = document.styleSheets[i];
			var att = getStylesheetRule0(stylesheet, id);
			if(att!=null){
				return att;
			}	
		}
	}
		
	function getRight(id){
		var rule = getStylesheetRule(id);
		var right = rule.style.right;
		if(right!=null && endsWith(right, "px")){
			return  parseInt(right.substring(0, right.length-2));
		}
		return 0;
	}

	
	   
	function offsetDiv(id){
		//check if the right bar exists
		var rightBar= document.getElementById("MSOTlPn_MainTD");
		
		if(rightBar!=null){
			//get the object's right position. Make this a parameter if it becomes too slow
			var offset = getRight("#"+id);
			//add the offset of the right bar
			offset += rightBar.offsetWidth;
			
			//reposition
			var div = document.getElementById(id);
			if(div!=null){
				div.style.right = offset +"px";
			} 
		}
		
 
	}

	//if a page is in 'Modify Shared Web Part' mode, find certain absolute divs and move them
	function adjustDivs(){  
		offsetDiv("siteactions");
		offsetDiv("services");
	}

	function popitup(url) {
	    newwindow = window.open(url,'name','height=600,width=500');
	    if (window.focus) {
	    	newwindow.focus();
	    }
	}
	
	var baseScalar; 

	function changeFontSize(id, scalar){
				if (baseScalar==null) { 
					// try to get from the cookie
					baseScalar = readCookie('cook1');
					if (baseScalar==null) { baseScalar = 1;}
				}
				if (scalar==null) { scalar = 1; }
				baseScalar = baseScalar * scalar;
				createCookie('cook1', baseScalar, 0);
				scalar = baseScalar;

				var size;

               var div = document.getElementById(id);
               if(div!=null){
                     size = 100;
                     div.style.fontSize = "" + (size * scalar) + "%"
               }
    }
                
     function fontSmall(){
               changeFontSize("contentPading", .80);
                }
                
     function fontLarge(){
               changeFontSize("contentPading", 1.25);               
                }
                
                

    function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

	//
	// Increase default multi-line text box width to 550px
	// Call increaseRTBoxBy(width) to override
	//
	function increaseRTBoxBy(CustomWidth)
	{
	  var CustomFrames = document.getElementsByTagName("IFRAME");
	  for (var i1 =0; i1<CustomFrames.length; i1++){
	   var oFrame = CustomFrames[i1];
	   if (oFrame.title == "Rich Text Editor"){
	   oFrame.style.width = CustomWidth;
	   var oToolbar = oFrame.parentElement.previousSibling;
	   if (oToolbar.className.indexOf(" rtetoolbar") == -1) oToolbar = oToolbar.previousSibling;
	   oToolbar.style.width = CustomWidth;
	   }}
	}
	function increaseRTBox()
	{
	   increaseRTBoxBy(550);
	}

                