﻿//all this needs to be crossbrowser


//
function Navigate(url) {
    location.href=url;
}


//
function NavigateNew(url) {
    window.open(url);
}


//
function AjaxIncrement(context,id) {
    if (typeof(cbaUpdateElement)=='function')
        cbaUpdateElement('divOutput','_ajax.aspx?action=inc&context='+context+'&id='+id);
}


//
function Submit() {
    document.forms[0].submit();
}


//
function GetElement(id) {    
    if(typeof(id)!='string') return id;
   
    if(document.getElementById) return document.getElementById(id);
    else if(document.all) return document.all[id];
    else return null;
}


function CancelBubble(evt)
{
    var e=(evt)?evt:window.event;
    if (window.event) {
        e.cancelBubble=true;
    } else {
        e.stopPropagation();
    }
}

//
function AttachDocumentEvent(evt, x)
{
    if (document.attachEvent)
        document.attachEvent('on'+evt,x);
    else {
        document.addEventListener(evt,x,false);
    }
}


//
function SetPage(p) {
    GetElement('hiddenPageNumber').value=p;
    document.forms[0].submit();
}


//calculate absolute (page) left of object
function AbsoluteLeft(o) {
    //el = o.parentElement; 
    el = o;   
	for (lx=0;el!=null;lx+=el.offsetLeft,el=el.offsetParent) {if (el.style.position=='absolute') {} }
	return (lx);					    
}


//calculate absolute (page) top of object
function AbsoluteTop(o) {
    el = o;
	for (ly=0;el!=null;ly+=el.offsetTop-el.scrollTop,el=el.offsetParent) {if (el.style.position=='absolute') {} }
	return (ly);				    
}

//var _x = null;
//var _y = null;
function Plot(evt,o) {
    x = evt.offsetX;
    y = evt.offsetY;
    
    //x = evt.clientX;
    //y = evt.clientY;
    
    window.status = x+','+y;
    clipboardData.setData('Text', x+','+y);
}

function SwitchLandscape(s) {
    if (s=='serviceGroup') {
        GetElement('serviceGroupLandscapeContainer').style.display='';
        GetElement('sectorGroupLandscapeContainer').style.display='none';
        
        GetElement('imgServices').src='images/landscapes/selected/services.gif';
        GetElement('imgSectors').src='images/landscapes/normal/sectors.gif';
    } else {
        GetElement('serviceGroupLandscapeContainer').style.display='none';
        GetElement('sectorGroupLandscapeContainer').style.display='';
        
        GetElement('imgServices').src='images/landscapes/normal/services.gif';
        GetElement('imgSectors').src='images/landscapes/selected/sectors.gif';
    }
}

function Highlight(o,v,id){
    o.firstChild.firstChild.firstChild.firstChild.firstChild.src=eval(v + '_imgH' + id + '.src');   
    o.firstChild.lastChild.firstChild.style.backgroundColor='rgb(0,70,127)';
}

function Unhighlight(o,v,id) {
    o.firstChild.firstChild.firstChild.firstChild.firstChild.src=eval(v + '_imgN' + id + '.src');    
    o.firstChild.lastChild.firstChild.style.backgroundColor=o.getAttribute('exp_RGB');
}

