/*
Title: 		
Author: 	
Update: 	
*/

/*******************************************
Working Storage
*******************************************/

/******************************************
Load event 
******************************************/

//Subscribe Initialization functions to the window.onload event
//i.e. addLoadEvent(_setExpandableSectioin);
//addLoadEvent(urchin);


function ShowHide(clsName, clsOthers)
{
    $('href' + clsName).className = "SelectedCCD";
    var divs = document.getElementsByClassName(clsName);
    if(divs.length > 0)
    {
        divs[0].style.display = 'block';
    }
        
    var arrclsOthers = clsOthers.split("?");
    arrclsOthers.each(function(clsOther)
    {
        var divOthers = document.getElementsByClassName(clsOther);
        if(divOthers.length > 0)
        {
            if(divOthers[0].style.display == 'block' || divOthers[0].style.display == '')
            {
                
                divOthers[0].style.display = 'none';
                $('href' + clsOther).className = "DeselectedCCD";
            }
        }
    });
}

function ShowHideBatch(clsName, clsOthers,clsNameP, clsOthersP)
{
    ShowHide(clsName, clsOthers);
   $('href' + clsNameP).className = "SelectedBatch";
    var divs = document.getElementsByClassName(clsNameP);
    if(divs.length > 0)
    {
        divs[0].style.display = 'block';
    }
        
    var arrclsOthersP = clsOthersP.split("?");
    arrclsOthersP.each(function(clsOtherP)
    {
        var divOthers = document.getElementsByClassName(clsOtherP);
        if(divOthers.length > 0)
        {
            if(divOthers[0].style.display == 'block' || divOthers[0].style.display == '')
            {
                
                divOthers[0].style.display = 'none';
                $('href' + clsOtherP).className = "DeSelectedBatch";
            }
        }
    });
}

/* ---------------------------------------
	doNothing
	This function does nothing.
	Use it when you need to call javascript but nothig should happen
--------------------------------------- */
function doNothing()
{
    return;
}
/* ---------------------------------------
	addLoadEvent
	This function shall be used to subscribe event handlers to the onload event
	of the window object.
--------------------------------------- */
function addLoadEvent(func)
{
	//get a pointer to the first handler
	var oldonload = window.onload;
	//if the event has no subscribers
	if (typeof window.onload != 'function')
		window.onload = func;	//subscribe the func handler
	//otherwise, queue it up
	else
	{
		window.onload = function(){
			oldonload();
			func();			
		}
	}
}


//private functions
/*--------------------------------------------------------
	_show(tag)
	Removes the hidden class from the tag's class list 
	and sets its expanded attribute to 'yes'
--------------------------------------------------------*/
function _show(tag)
{
    removeElementFromClass(tag, "hidden");
    //tag.className = '';
    tag.setAttribute("expanded", "yes");
}
/*--------------------------------------------------------
	_hide(tag)
	Adds the hidden class to the tag's class list 
	and sets its expanded attribute to 'no'
--------------------------------------------------------*/
function _hide(tag)
{
    addElementToClass(tag, "hidden");
    //tag.className = "hidden";
    tag.setAttribute("expanded", "no");
}
//--------------------------------------------------------//
/*--------------------------------------------------------
	showHide(id)
	This function hides or displays the contents of a given tag.
	Such tag must have the attribute 'expanded'.
--------------------------------------------------------*/
function showHide(id)
{
    var expandableSection = document.getElementById(id);
    if (root.getAttribute("expanded") == "no")
        _show(expandableSection);
    else
        _hide(expandableSection);
}
/*--------------------------------------------------------
	showHide(id, cmd)
	This function implements the show and hide commands
	to hide or display the contents of a given tag.
	Such tag must have the attribute 'expanded'.
--------------------------------------------------------*/
function showHide(id, cmd)
{
    var expandableSection = document.getElementById(id);
    if (cmd == "show")
        _show(expandableSection);
    else
        _hide(expandableSection);
}

//--------------------------------------------------------//
//////Print
//--------------------------------------------------------//
function printpage()
{	    
    window.print();
}

function setCookie(name,value,days) {
    if(navigator.cookieEnabled == true) {
        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 getCookie(name) {
    if(navigator.cookieEnabled == true){
	    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;
}





