﻿/*
    Chris Morton
    INTERMAP
    27 February 2008
    
    Last Modified: 
        20080730    AKA     Test for null content & ignore if null (quick fix for embedded)
        20080612    AKA     Test for null and try both without and with PagePrefix
        20080528    AKA     Include the PagePrefix (when embedded in a user control)
*/
var collapse = 0
var PagePrefix = 'asmMap_'

function flag(obj)
{
    dynname = obj.id.split("_")
    prefix = dynname[0]    	
    var oflag = document.getElementById(prefix + '_hidChange')    	
    oflag.value += obj.id + ','		 
}

function printerFriendly()
{
    //to support printer Friendly output
}

function collapseAll(n, a, b)
{    
    if (b == null)
    {
	    var content = document.getElementById(n)
	    if (a == null) {
		    collapse += n
	    }
	    else {
		    collapse = 1
	    }
	    var x
	    for (x=0; x<=arrsections.length-1; x++) {
		    var content = document.getElementById('c_' + arrsections[x])
		    if ((content == null) || (content == undefined)) {
		        content = document.getElementById(PagePrefix +' c_' + arrsections[x]) // Try using page prefix AKA 20080612
		    }
		    
		    if (content != null)
		    {
		        var contenttext = document.getElementById('d_' + arrsections[x])
		        var image = document.getElementById('i_' + arrsections[x])
		        if (collapse%2 == 0) {
			        content.style.display = ''
			        content.style.display = 'block'
			        contenttext.style.overflow = 'visible'
		        }
		        else {
			        content.style.display = ''
			        content.style.display = 'none'
		        }
		        if (image.getAttribute('src').search('pinon') > -1 ) {   
		            content.style.display = ''
			        content.style.display = 'block'
			        contenttext.style.overflow = 'visible'
		        }
		     }// content valid
	    }
	}
	else {
	    var content = document.getElementById(n)
	    if (a == null) {
		    collapse += n
	    }
	    else {
		    collapse = 1
	    }
	    var x
	    for (x=0; x<=arrsections.length-1; x++)
	    {
		    var content = document.getElementById('c_' + arrsections[x])
		    if ((content == null) || (content == undefined)) {
		        content = document.getElementById(PagePrefix+'c_' + arrsections[x]) // Try using page prefix AKA 20080612
		    }
		    
		    if (content != null)
		    {
		        var contenttext = document.getElementById('d_' + arrsections[x])
		        var image = document.getElementById('i_' + arrsections[x])
		        if (collapse%2 == 0) {
			        content.style.display = ''
			        content.style.display = 'block'
			        contenttext.style.overflow = 'visible'
		        }
		        else {
			        content.style.display = ''
			        content.style.display = 'none'
		        }
		        if (image.getAttribute('src').search('pinon') > -1 ) {
		            image.setAttribute('src', image.getAttribute('src').replace('pinon', 'pinoff'))
		        }
		    }
	    }
	}
}

function showhide(e, t)
{
	var contenttext = document.getElementById('c_' + e.substr(2, e.length))
	if ((contenttext == null) || (contenttext == undefined)) {
        contenttext = document.getElementById(PagePrefix + 'c_' + e.substr(2, e.length)) // Try using page prefix AKA 20080612
    }
    if ((contenttext == null) || (contenttext == undefined)) return; // Exit gracefully AKA 20080612
	
	var image = document.getElementById('i_' + e.substr(2, e.length))
	if (image.getAttribute('src').search('pinon') > -1 ) {
	    contenttext.style.display = ''
		contenttext.style.display = 'block'
		return
	}
	if (t == e && contenttext.style.display == 'block') {
		contenttext.style.display = ''
		contenttext.style.display = 'none'
		return
	}		
	collapseAll(null, e)
	if (contenttext.style.display == 'block') {
		contenttext.style.display = ''
		contenttext.style.display = 'none'
	}
	if (contenttext.style.display == 'none' || contenttext.style.display == '') {
		contenttext.style.display = ''
		contenttext.style.display = 'block'
	}
}

function changeStyle(color, object)
{    

}

function pinSection(e, p)
{
	var image = document.getElementById('i_' + e.substr(2, e.length))	
	if (image.getAttribute('src').search('pinoff') > -1 ) {
		image.setAttribute('src', p)
		showhide(e, e)
	}
	else {
		image.setAttribute('src', p.replace('pinon', 'pinoff'))
		showhide(e, e)
	}
}