﻿

/* Common Javascript functions handling and DHTML object manipulation */

var isNN = document.layers ? true : false;
var isIE = document.all ? true : false;
var selectedCRITERIA = new Array();
var selectedValues = new Array();
var personJoinUpdate = false;
var openBusinessAreas = false;
var hlpCriWinWidth = 200;
var singleSearchWord = "-";
var installWindow;
var pageURI = document.location.toString(); /* current page */
var aspxFile = pageURI.split("/")[pageURI.split("/").length-1].split(".")[0].toLowerCase();
if (aspxFile.length == 0)
{
    aspxFile = "default";
}


function dipetidii(sBox){
    singleSearchWord = sBox.value;

}

function setBlockLayer(){

    var bLayer = new getObj("blockLayer");
    
    var mainSaveButton = new getObj("ctl00_Content_SCI_saveSearch");
    mainSaveButton.obj.disabled = true;

}

function enableRestList(cbToQuery, cbToCheck)
{    
    if (cbToQuery.checked)
    {   
        cbToCheck.parentNode.setAttribute("disabled","");
        cbToCheck.disabled = false;        
    }
    else
    {
        cbToCheck.checked = false;
        cbToCheck.disabled = true;
    }
}

function isOptionSelected(divID, message)
{
	var D = new getObj(divID).obj;
	// 
	if(D.selectedIndex != 0)
	    return true
	alert(message);
    return false;
}

function areAnyCBChecked(divID, message, scrollTo, dimmeli)
{
    if(!new getObj(divID).obj)
        return false;
	var D = new getObj(divID).obj;
	// Get all inputs
	var inputs = D.getElementsByTagName('input');
	// Loop through input elements
	for(var t=0;t<inputs.length;t++){
		if(!inputs[t].disabled && ((inputs[t].type=="checkbox") || inputs[t].type=="radio" || inputs[t].type=="radiobutton") && inputs[t].checked){
	        if(scrollTo)
	            if(scrollTo == "top")
	                window.scrollTo(0,0);
	        /* Ajax postback hack */
	        var dimmeli = new getObj('ctl00_Content_progress');
	        if(dimmeli.obj){
	            dimmeli.style.display = 'block';
	        }
		    return true;
		}
    }
    alert(message);
    return false;
    
}

function enableAllChildObjects(ID, enable, strTagName)
{
    if(!new getObj(divID).obj)
        return false;
	var D = new getObj(divID).obj;
	// Get all inputs
	var objects = D.getElementsByTagName(strTagName);
	// Loop through input elements
	for(var t=0;t<objects.length;t++){
		if(!inputs[t].disabled && ((inputs[t].type=="checkbox") || inputs[t].type=="radio" || inputs[t].type=="radiobutton") && inputs[t].checked){
	        if(scrollTo)
	            if(scrollTo == "top")
	                window.scrollTo(0,0);
		    return true;
		}
    }
    alert(message);
    return false;
    
}


function closeSelections(id)
{
    Selections.ClearSelections();
    showDiv(id);
}

function selectAllOptions(id)
{
var ref = document.getElementById(id);

for(i=0; i<ref.options.length; i++)
ref.options[i].selected = true;
}

/// <summary>
/// Move layer to specified position</summary>
/// <param name="OBJ">Javascript Object</param>
/// <param name="posX">Horizontal position X in pixels, Integer</param>
/// <param name="posY">Vertical position Y in pixels, Integer</param>
function moveLayer(OBJ,posX,posY){
	if(OBJ != undefined){
		OBJ.style.left=posX+'px';
		OBJ.style.top=posY+'px';
	}

}
/// <summary>
/// Show or hide layer</summary>
/// <param name="divId">ID of object to be manipulated. String</param>
/// <param name="action">"show" or something else, String</param>
function showDiv(divId,action,IFrameTrick){

	if(!new getObj(divId).obj)
		window.status =divId + ' does not exist';

	if(!IFrameTrick)
		var trickIt = false;
	else
		var trickIt = true;

	if(trickIt){
			// IE NEEDS Iframe BEHIND LAYER IN ORdER TO SHOW IT OVER SELECT LIST
			var IfrRef = document.getElementById('dummyIframe'); 
			
	}
	if(action=='show'){
		new getObj(divId).style.display='block';
		if(trickIt){
			var saveLayer = new getObj(divId);
			IfrRef.style.width = saveLayer.obj.offsetWidth; 
			IfrRef.style.height = saveLayer.obj.offsetHeight; 
			IfrRef.style.top = saveLayer.style.top; 
			IfrRef.style.left = saveLayer.style.left; 
			IfrRef.style.zindex = saveLayer.style.zindex - 1; 
			IfrRef.style.display = "block"; 
		}
	}else{
		new getObj(divId).style.display='none';
		if(trickIt){
			IfrRef.style.width = "0px"; 
			IfrRef.style.height = "0px"; 
			IfrRef.style.top = "0px"; 
			IfrRef.style.left = "0px"; 
			IfrRef.style.zindex = -1; 
			IfrRef.style.display = "none"; 
		}
	}
}
/// <summary>
/// Checks whether object is within horizontal boundaries of Browser window</summary>
/// <param name="obj">Javascript Object</param>
/// <param name="offSet">optional user specified offset</param>
/// <returns>positive Integer if object is inside, otherwise value is negative</returns>
function isInsideWindowX(obj,offSet){

	if(offSet == "")
		offSet = 0
	var objRight = parseInt(findPosX(obj))+parseInt(obj.offsetWidth)+parseInt(offSet);
	var W = document.body.clientWidth+document.body.scrollLeft;
	if(objRight>W)
		return W-objRight;
	else
	    return objRight;
}

/// <summary>
/// Checks whether object is within vertical boundaries of Browser window</summary>
/// <param name="obj">Javascript Object</param>
/// <param name="offSet">optional user specified offset</param>
/// <returns>positive Integer if object is inside, otherwise value is negative</returns>
function isInsideWindowY(obj,offSet){

	if(offSet == "")
		offSet = 0
	var objVertical = parseInt(findPosY(obj))+parseInt(obj.offsetHeight);
	var H = document.body.clientHeight+document.body.scrollTop - offSet;
	if(objVertical>H)
		return H-objVertical;
	else
		return 0;
}

/// <summary>
/// Find object horizontal position</summary>
/// <param name="obj">Javascript Object</param>
/// <returns>position in pixels from the left within the current document. Integer</returns>
function findPosX(obj)
{
	var curleft = 0;
	if(obj){
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
				
	}
	return curleft;

}
/// <summary>
/// Find object vertical position</summary>
/// <param name="obj">Javascript Object</param>
/// <returns>position in pixels from the top within the current document. Integer</returns>
function findPosY(obj)
{
	var curtop = 0;

	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getObj(name)
{
  if (document.getElementById && name !="")
  {
  
  	if(document.getElementById(name)){
	  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}else{
	    self.status = 'ID ' + name + ' does not exist';
		return new Object();
	}
  }
  else if (document.all && name !="")
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers && name !="")
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
function findImage(name, doc) {
	var i, img;
	for (i = 0; i < doc.images.length; i++)
	if (doc.images[i].name == name)
	    return doc.images[i];
	for (i = 0; i < doc.layers.length; i++)
	if ((img = findImage(name, doc.layers[i].document)) != null) {
	    img.container = doc.layers[i];

	    return img;
	}
	return null;
}

function getImage(name) {
	if (isNN) {
	return findImage(name, document);
	}
	if (isIE){
	return eval('document.all.' + name);
	}else if (document.images) {
	return eval('document.images.' + name);
	}	

	else{
		return document.getElementById(name);
	}
	return null;
}
function getImagePageLeft(img) {
	  var x, obj;
	  if (isNN) {
	    if (img.container != null)
	      return img.container.pageX + img.x;
	    else
	      return img.x;
	  }
	  if (isIE || document.images) {
	    x = 0;
	    obj = img;
	    while (obj.offsetParent != null) {
	      x += obj.offsetLeft;
	      obj = obj.offsetParent;
	    }
	    x += obj.offsetLeft;
	    return x;
	  }

	  return -1;
	}

	function getImagePageTop(img) {
	  var y, obj;
	  if (isNN) {
	    if (img.container != null)
	      return img.container.pageY + img.y;
	    else
	      return img.y;
	  }
	  if (isIE || document.images) {
	    y = 0;
	    obj = img;
	    while (obj.offsetParent != null) {
	      y += obj.offsetTop;
	      obj = obj.offsetParent;
	    }
	    y += obj.offsetTop;
	    return y;
	  }
	  return -1;
	}
	
function showCodes(){

    var info = new getObj("tgINFO").obj;
    var texts = info.getElementsByTagName("i");
    var codes = info.getElementsByTagName("label");
    for(i=0;i<texts.length;i++)
        texts[i].style.display="none";
    for(i=0;i<codes.length;i++)
        codes[i].style.display="block";

    
}
function showTexts(){

    var info = new getObj("tgINFO").obj;
    var texts = info.getElementsByTagName("i");
    var codes = info.getElementsByTagName("label");
    for(i=0;i<texts.length;i++)
        texts[i].style.display="block";
    for(i=0;i<codes.length;i++)
        codes[i].style.display="none";


}
function cursorHelp_on(obj,divClass,helpText,zindexLayer,position){
	
	if(helpText != ""){
	    
		var helpWin = new getObj("helpWindow").obj;
        helpWin.setAttribute("onclick","showDiv('helpWindow','hide');");        
		helpWin.className = divClass;
		helpWin.innerHTML = helpText;
		if(zindexLayer){
			helpWin.style.zindex = zindexLayer.style.zindex+100;
		}
	    if(position && position=="down"){
	            helpWin.style.width = obj.offsetWidth;
	    	    moveLayer(helpWin,findPosX(obj),findPosY(obj)+obj.offsetHeight);
	    }else{
		    if(isInsideWindowX(obj,hlpCriWinWidth)<0){
			    moveLayer(helpWin,findPosX(obj)-hlpCriWinWidth,findPosY(obj));
		    }else{
			    moveLayer(helpWin,findPosX(obj)+obj.offsetWidth+3,findPosY(obj)+3);			
		    }
		}
		showDiv(helpWin.id,"show");
		
		var insideY = isInsideWindowY(helpWin);
		
		if(insideY<0){
			moveLayer(helpWin,findPosX(helpWin),findPosY(helpWin)+insideY);
		}
	}
}
function cursorHelp_off(obj){

	showDiv('helpWindow','hide',false);
	obj.style.backgroundColor = "";
	obj.style.cursor = "";
	

}
function showWinMe(){
	self.focus()
}

/// <summary>
/// Read attribute attr value from querystring
/// </summary>
function querystring(attr){
	// @attr As String
	if(!attr)
		attr = "";
	var urli = document.location.toString();
	this.exists = false;
	this.value = "";
	var VALUES = new Array();
	var KEYS = new Array();
	var VALS = new Array();
	if(urli.indexOf("?") != -1){
		var Qs = urli.split("?")[1].split("#");
		var qs = Qs.join("").split("&");
		for(k=0;k<qs.length;k++){
			var atKey = qs[k].split("=")[0];
			var atVal = qs[k].split("=")[1];
			if(atVal != ""){
				VALUES.push(atKey + "=" + atVal);
				KEYS.push(atKey);				
				VALS.push(atVal);
			}
			if(atKey.toLowerCase() == attr.toLowerCase()){
				this.exists = true;
				this.value = atVal;
			}			
		}
	}
	this.values = VALUES;
	this.keys = KEYS;
	this.vals = VALS;
}


function isUndefined(){

	return undefined;

}


function countChecked(obj){

	var chCount = 0;
	for(var t=0;t<obj.length;t++){
		if(obj[t].checked && !obj[t].disabled)
			chCount=chCount+1;
	}

	return chCount;

}

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 '';
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}


function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function



function isInArray(ID, arr, partly){
	/* CHECKS IF ID IS FOUND FROM ARRAY arr */
	var exact="true";
	if(partly)
		exact="false"
	var ttt=-1;
	var ARR = arr;
	if(exact=="true"){
		for(var j=0;j<ARR.length;j++){
			if(ID==ARR[j]){
				ttt= j;
				break;
			}
		}
	}else{
		for(var j=0;j<ARR.length;j++){
			if(ID.indexOf(ARR[j])!=-1){
				ttt= j;			
				break;
			}
		}	
	}
	return ttt;
}


function closeRemoteCriteria(){
	var crWindow = new getObj("criteriaWindow").obj;
	document.body.removeChild(crWindow);
}


function callToServer(URL,indexi) {

	ranDomStr=Math.random();
	ranDomStr=ranDomStr*10000000000000000000;	
	var RSIExtra = "";
	if(indexi){
		RSIExtra = indexi;
		if(IFrameObj)
			IFrameObj = null;
	}else
		RSIExtra="";
		
	
	
	if(!URL.indexOf("rnd=")!=-1){
		if(URL.indexOf("?")!=-1)
				URL = URL + "&rnd=" + ranDomStr;
		else
				URL = URL + "?rnd=" + ranDomStr;
	}
  if (!document.createElement) {return true};
  var IFrameDoc;  
  
  if (!IFrameObj && document.createElement) {
  
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
    var tempIFrame=document.createElement('iframe');
    tempIFrame.setAttribute('id','RSIFrame'+RSIExtra);
    tempIFrame.setAttribute('src','javascript:false');
    tempIFrame.style.border='0px';
    tempIFrame.style.width='0px';
    tempIFrame.style.height='0px';
    
    IFrameObj = document.body.appendChild(tempIFrame);
	
  
    if (document.frames) {
      // this is for IE5 Mac, because it will only
      // allow access to the document object
      // of the IFrame if we access it through
      // the document.frames array
      IFrameObj = document.frames['RSIFrame'+RSIExtra];
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer("'+URL + '")',10);    
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  IFrameDoc.location.replace(URL);
  
  return false;
}
function callToStatServer(URL) {
  if (!document.createElement) {return true};
  var IFrameDoc;  
  if (!IFrameObj && document.createElement) {

    var tempIFrame=document.createElement('iframe');
    tempIFrame.setAttribute('id','StatIFrame');
    
    tempIFrame.style.border='0px';
    tempIFrame.style.width='0px';
    tempIFrame.style.height='0px';
    IFrameObj = document.body.appendChild(tempIFrame);
  
    if (document.frames) {
      IFrameObj = document.frames['StatIFrame'];
    }
  }
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    setTimeout('callToStatServer("' + URL + '")',10);
    return false;
  }
  if (IFrameObj.contentDocument) {    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {  // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  IFrameDoc.location.replace(URL);
  return false;
}


/*  POPUPMENU FUNCTION */
function popupMenu(parentObj){

	var menuDiv = new getObj("popupmenu");
	
	parentObj.onclick = function(e){
			popupShow(menuDiv,parentObj);
	}
	// popupmenu text Paragraph <P>
	var divi = new getObj("popupRow_delete");
	if(divi.obj && new getObj("TR_"+menuDiv.obj.IIDEE).obj){
		divi.obj.getElementsByTagName("a").innerHTML = new getObj("TR_"+menuDiv.obj.IIDEE).obj.getElementsByTagName("strong")[0].innerHTML;
	}
}
function popupHide(menuDiv){
	
		showDiv(menuDiv.id,'hide');
		moveLayer(menuDiv,-100,-200);
		menuDiv.IIDEE="";
}

function popupShow(menuDiv,parentObj){
		
		var trClass = new getObj("TR_"+parentObj.id.split("_")[1]).obj.className;
		if(trClass == "deletedRow")	// do not show the popup if row is deleted
			return;
			
		if((menuDiv.obj.IIDEE == parentObj.id.split("_")[1] && menuDiv.style.display=="none")
				||
				(menuDiv.obj.IIDEE != parentObj.id.split("_")[1] && menuDiv.style.display=="block")
				||
				(!menuDiv.obj.IIDEE)
				||
				(menuDiv.obj.IIDEE=="")){
			var X = findPosX(parentObj);
			var Y = findPosY(parentObj) + parentObj.offsetHeight + 5;
			moveLayer(menuDiv.obj,X,Y);
			menuDiv.obj.IIDEE = parentObj.id.split("_")[1];	
			showDiv(menuDiv.obj.id,'show');
		}else{
			popupHide(menuDiv.obj);
		}
}

function handleMenu(e,oM)
{
	oMenu	= oM;
	var e	= (document.all)?window.event:e;

	if (e.type == 'mouseover' || e.type == 'click')
	{
		setOver(true);
		handleTimeout();
	}
	else
	{
		handleTimeout();
		toOver	= setTimeout('setOver(false)',300);
	}
}

function setOver(bIsOver,menuDiv)
{
	var showIt	= (bIsOver)?"show":"hide";
	showDiv(menuDiv.obj.id,showIt);
}




function setUserlanguage(language){
	createCookie("UIlang",language,265);
	var pageURI = document.location.toString(); /* current page */
	document.location=pageURI;
}

function isVisible(el, root)
{
    if (root.style.visibility == 'none')
        return false;
    var parent = el.parent;
    while(parent != null || parent != root)
    {
        
        el = el.parent;
    }
    return true;
}

function checkCheckBoxes(checkValue, divId, o){

	var D = new getObj(divId).obj;
	if(o)   // If object has been passed, use it
	    D = o;
	
	// Get all inputs
	var inputs = D.getElementsByTagName('input');
	
	// Loop through input elements
	for(var t=0;t<inputs.length;t++){
		if(!inputs[t].disabled && (inputs[t].type=="checkbox" || inputs[t].type=="radio" || inputs[t].type=="radiobutton"))
		{
			inputs[t].checked=checkValue;
		}
	}
	
}

function checkUnder(obj, o){

    alert(obj.getElementsByTagName('span')[0]);
    // Save value to dom
    if(!obj.chk || obj.chk==false)
        obj.chk = true;
    else
        obj.chk = false;
        
	var D = obj;
	if(o)   // If object has been passed, use it
	    D = o;
	
	// Get all inputs
	var inputs = D.getElementsByTagName('input');
	
	// Loop through input elements
	for(var t=0;t<inputs.length;t++){
		if(!inputs[t].disabled && (inputs[t].type=="checkbox" || inputs[t].type=="radio" || inputs[t].type=="radiobutton") )
			inputs[t].checked=obj.chk;
	}
	
}


function mnClick(chk){
    // TODO ADD logic for hierarchy clicks
    
}


/* COOKIES */

var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (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=/";
		this[name] = value;
	},
	erase: function (name) {
		this.create(name,'',-1);
		this[name] = undefined;
	}
};

Cookies.init();

/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

/* Crieria disable */
function disbleCriteria(critDiv, positionDiv)
{
	    div = new getObj(critDiv);
	    divPos = new getObj(positionDiv);
	    if(!div.obj)
		    window.status =divId + ' does not exist';
		else
		{
	        var tr = div.obj.parentNode.parentNode;
	        div.style.width = "720px";
	        div.style.top = (divPos.obj.offsetTop - 2) + "px";
	        div.style.left = (divPos.obj.offsetLeft - 3) + "px";
	        div.style.display="block";
	    }
}

function disableUncheckCb(tocheck, ids)
{
    cbToCheck = document.getElementById(tocheck);
    var cbIds = ids.split(',');
    for (var i=0;i<cbIds.length;i++) {
        var cbID = cbIds[i];
        cb = document.getElementById(cbID);
        cb.disabled = cbToCheck.checked;
        if (cbToCheck.checked)
            cb.checked = false;
    }
}

function hideErrorWindow()
{
    toHideArr = getElementsByClassName(document, "div", "GLPErrorWindow");
    if (toHideArr.length > 0)
        toHideArr[0].style.display="none";
    toShowArr = getElementsByClassName(document, "div", "GLPsideBarTableDiv");
    for(i=0;i<toShowArr.length; i++)
    {
        toShowArr[i].style.display="block";
    }
}
function closeError()
{
    toHideArr = getElementsByClassName(document, "div", "ErrorWindow");
    if (toHideArr.length > 0)
        toHideArr[0].style.display="none";
}

function showTutorial()
{
    window.open("/tutorial.aspx", "tutorial","location=0,status=0,scrollbars=0,width=800,height=640"); 
}

function checkFlash()
{
    var version = deconcept.SWFObjectUtil.getPlayerVersion();
    if (version['major'] > 0)
    {
         window.location.reload();
         self.focus();
         if (!installWindow.closed)
            installWindow.close();
    }
    else
        setTimeout('checkFlash()', 1000);
}
    

function showFI()
{
    setTimeout('checkFlash()', 1000)
    installWindow = window.open("http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash");
    return false;
}

function companyPrint()
{
    createCookie("printCompany", "now", 1);
    __doPostBack('ctl00$Content$CompanyData1$mnu','vwAll');
}

function checkPrintCookieOnLoad()
{
    if (readCookie("printCompany") == "now")
    {
       window.print();
    }
    eraseCookie("printCompany");
}


function checkPrintCookie()
{
//    if (readCookie("printCompany") == "now")
//    {
//       window.print();
//    }
//    eraseCookie("printCompany");
}


function showActiveBLC(sizeCheckBoxId, lineOfBisnessCheckBoxId, div0Id, div1Id, div2Id, div3Id)
{
 
    // Set the button value
    
    var cbSizeFilter = document.getElementById(sizeCheckBoxId);
	var cbLineOfBisnessFilter = document.getElementById(lineOfBisnessCheckBoxId);
	
	if(cbSizeFilter  == null || cbLineOfBisnessFilter == null)
	    alert('cant find checkBoxs!');
	
	var divArray = new Array(div0Id,div1Id,div2Id,div3Id );
	
	
	
	var filteringLevel = getFilteringLevel (cbSizeFilter, cbLineOfBisnessFilter)
	
	for (i = 0; i < divArray.length; ++i)
    {
        if (i == filteringLevel)
            showDiv(divArray[i],'show');
        else
            showDiv(divArray[i],'hide');
    }
}


function getFilteringLevel (cbSizeFilter, cbLineOfBisnessFilter)
{

   var FILTERING_TARGETGROUP = 0;
    var FILTERING_TARGETGROUP_SIZE = 1;
    var FILTERING_TARGETGROUP_LINE_OF_BISNESS = 2;
    var FILTERING_TARGETGROUP_LINE_OF_BISNESS_AND_SIZE = 3;
    
         if (!cbSizeFilter.checked && !cbLineOfBisnessFilter.checked)
            return FILTERING_TARGETGROUP;

        if (cbSizeFilter.checked)
        {
            if (cbLineOfBisnessFilter.checked)
                return FILTERING_TARGETGROUP_LINE_OF_BISNESS_AND_SIZE;
            else
                return FILTERING_TARGETGROUP_SIZE;
        }
        else
            return FILTERING_TARGETGROUP_LINE_OF_BISNESS;
}

// shows/hides div
// check all checkboxes on show div
// Unchecks all checkboxes on hide div
//function HLcbUpdate(cb, div, cbadd, abremove, cbmodify)
//{
//    if (cb.checked)
//    {
//        showDiv(div,'hide');
//        cbadd.checked = abremove.checked = cbmodify.checked = true;
//    }
//    else
//    {
//        showDiv(div,'show');
//        cbadd.checked = abremove.checked = cbmodify.checked = false;
//    }
//}

function HLcbUpdate(cb, div)
{
    if (cb.checked)
    {
        showDiv(div,'hide');
    }
    else
    {
        showDiv(div,'show');
    }
}

 function removeBorderImage()
{
    showDiv('imageFrame','hide',false);
}
 function moveBorderImage(obj)
{
    var imageFrame = new getObj("imageFrame").obj;
    var link = new getObj("imgFrameHref").obj;
    link.href = obj.href;
    moveLayer(imageFrame,findPosX(obj),findPosY(obj));
    showDiv('imageFrame','show',false);
}

// interval needs to be like "0:30" = mm:ss (not working version yet!)
function autoReload(updateInterval)
{

    if (document.images){
        var parseUpdateInterval=updateInterval.split(":")
        parseUpdateInterval=parseUpdateInterval[0]*60+parseUpdateInterval[1]*1
    }
    else
    return
    if (parseUpdateInterval==1)
        window.location.reload()
    else
    { 
        parseUpdateInterval-=1
        curmin=Math.floor(parseUpdateInterval/60)
        cursec=parseUpdateInterval%60
        if (curmin!=0)
            curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
        else
            curtime=cursec+" seconds left until page refresh!"
        window.status=curtime
        setTimeout("beginrefresh()",1000)
    }
}


var win=null;
function popupWindow(mypage,myname,w,h,pos,infocus)
{
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();
}

//window.onload=beginrefresh
