﻿////Initialize Accordion:
//ddaccordion.init1({
//headerclass: "Headerclass", //Shared CSS class name of headers group
//contentclass: "details", //Shared CSS class name of contents group
//collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
//defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
//onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
//animatedefault: true, //Should contents open by default be animated into view?
//persiststate: false, //persist state of opened contents within browser session?
//toggleclass: ["", "HeaderclassOpen"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
//togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
//animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
//revealtype: "click"
//})

function init1()
{
    hints_prepareImages();
}

function swapButton(obj)
{
   if(obj.className == 'ButtonJobList')
   {
        obj.className = 'ButtonJobListOver';
   }
   else
   {
        obj.className = 'ButtonJobList';
   }
}

function swapButton2(obj) {
    if (obj.className == 'TextDecorationUnderline') {
        obj.className = 'TextDecorationNone';
    }
    else {
        obj.className = 'TextDecorationUnderline';
    }
}

function showCompanyDesc( tmpEvent, objId, strTitle, strUrl )
{
	modalShow(strTitle, strUrl, 600, 400);		
}

function blockEmployer( companyId, windowCaption )
{	
	modalShow(windowCaption?windowCaption:'Block Employer','PouUpBlockEmployer.aspx?CompanyId=' + companyId, 600, 120);
}

function hints_prepareImages()
{
	var inputs = document.getElementsByTagName("td");        
    
    if( inputs != null)
    {
		for (var i=0; i<inputs.length; i++)
		{
			if (inputs[i].className == "bottomTd")
			{
				inputs[i].onmouseover = function ()
				{
					hints_Show_Image(this, this.getElementsByTagName("div")[1]);
				}
				
				inputs[i].onmouseout = function ()
				{
					hints_Hide_Image(this, this.getElementsByTagName("div")[1]);
				}
			}
		}
	}
}

function hints_Show_Image( objParent, object )
{
    object.style.display = "inline";

    try
    {
		showMenu( objParent.id, object.id, null, true );

		object.style.top = (Number(object.style.top.replace('px','')) - objParent.parentNode.offsetHeight - object.offsetHeight + 10).toString() + 'px';				
		//object.style.left = (Number(object.style.left.replace('px','')) + 17).toString() + 'px';		
		object.style.right = (document.body.clientWidth - Number(object.style.left.replace('px',''))-70).toString() + 'px';		
		object.style.left = '';
    }
    catch(e)
    {
		hints_Hide_Image( objParent, object )
        return;
    }
}

function hints_Hide_Image( obj, hintsObj )
{
    hintsObj.style.display = "none";
}
//function OpenDesc(trHeader, imgImgId, trDescription, lblJobTitlePID, lblLocationID, lnkCompNameID, lblPostedID, lnkApplyID)

function OpenDesc(trHeader,imgApplyId,imgImgId,trDescription,lblJobTitlePID,lblLocationID,lnkCompNameID,lblPostedID)
{
    objImg = document.getElementById(imgImgId);
    objImgApply = document.getElementById(imgApplyId);    
    objDescription = document.getElementById(trDescription);  
    lblJobTitleP = document.getElementById(lblJobTitlePID);
    lblLocation = document.getElementById(lblLocationID);
    lnkCompName = document.getElementById(lnkCompNameID);
    lblPosted=document.getElementById(lblPostedID);
    //lnkApply = document.getElementById(lnkApplyID);

    if (trHeader.className == "jc_tableLightPink" || trHeader.className == "jc_tablePink" || trHeader.className == "jc_tableWhite" || trHeader.className == "jc_tableGray")
    //if (objImg.src.indexOf("arrow_small.png") >= 0)
    {
        ResetAllElements();
        ResetAllImages();               
       // objImg.src ="../Cultures/Images/arrow-open.gif";
        objImg.src = GetImgUrl() + "/arrow_small1.png";
        objImgApply.src = GetImgUrl() + "/apply.png";
        objDescription.style.display = "";
        if (trHeader.className == "jc_tableLightPink") {
            trHeader.className = "jc_tableDarkGrayAfterLightPink";
        }
        if (trHeader.className == "jc_tablePink") {
            trHeader.className = "jc_tableDarkGrayAfterPink";
        }
        if (trHeader.className == "jc_tableWhite") {
            trHeader.className = "jc_tableDarkGrayAfterWhite";
        }
        if (trHeader.className == "jc_tableGray") {
            trHeader.className = "jc_tableDarkGrayAfterGray";
        }
        lblJobTitleP.style.color="white";
        lblLocation.style.color="white";
        if(lnkCompName!=null)
            lnkCompName.style.color="white";
        lblPosted.style.color="white";
        //lnkApply.style.color="white";
    }
    else
    {
        if (trHeader.className == "jc_tableDarkGrayAfterLightPink" || trHeader.className == "jc_tableDarkGrayAfterPink" || trHeader.className == "jc_tableDarkGrayAfterGray" || trHeader.className == "jc_tableDarkGrayAfterWhite") {
            ResetAllImages();
            // objImg.src ="../Cultures/Images/arrow-close.gif";
            objImg.src = GetImgUrl() + "/arrow_small3.png";
            objImgApply.src = GetImgUrl() + "/apply.png";
            objDescription.style.display = "none";
            if (trHeader.className == "jc_tableDarkGrayAfterLightPink") {
                trHeader.className = "jc_tableLightPink";
                lblJobTitleP.style.color = "#732c72";
            }
            if (trHeader.className == "jc_tableDarkGrayAfterPink") {
                trHeader.className = "jc_tablePink";
                lblJobTitleP.style.color = "#732c72";
            }
            if (trHeader.className == "jc_tableDarkGrayAfterGray") {
                trHeader.className = "jc_tableGray";
                lblJobTitleP.style.color = "#424242";
            }
            if (trHeader.className == "jc_tableDarkGrayAfterWhite") {
                trHeader.className = "jc_tableWhite";
                lblJobTitleP.style.color = "#424242";
            }
            
            lblLocation.style.color = "#4b4a4a";
            if (lnkCompName != null)
                lnkCompName.style.color = "gray";
            lblPosted.style.color = "#4b4a4a";
            //lnkApply.style.color="#A274DF";
        }
    }   
}   
function GetImgUrl()
{    
    return "/Cultures/Images";
}

function ResetAllImages()
{
    objs=window.document.getElementsByTagName('img');
    
    for (var i=0; i<objs.length; i++)
    {
        if (objs[i].src.indexOf("arrow_small1.png") >= 0)
        {
            objs[i].src = GetImgUrl() + "/arrow_small3.png";
        }    
    }
}
function ResetAllLabels()
{
    objs=window.document.getElementsByTagName('label');
    for (var i=0; i<objs.length; i++)
    {
        if(objs[i].id.indexOf("lblJobTitleP")>=0)
        {
            objs[i].style.color="#000066";
        }
        if(objs[i].id.indexOf("lblLocation")>=0)
        {
            objs[i].style.color="gray";
        }        
    }      
}
function ResetAllSpans()
{
    objs=window.document.getElementsByTagName('span');
    for (var i=0; i<objs.length; i++)
    {
        if(objs[i].id.indexOf("lblLocation")>=0 || objs[i].id.indexOf("lblPosted")>=0)
        {
            objs[i].style.color="gray";
        }         
    }      
}
function ResetAllAnchors()
{
    objs=window.document.getElementsByTagName('a');
    
    for (var i=0; i<objs.length; i++)
    {
//        if(objs[i].id.indexOf("lnkApply")>=0)
//        {
//            objs[i].style.color ="#A274DF";
//        }          
        if(objs[i].id.indexOf("lnkCompName")>=0 )
        {
            objs[i].style.color ="gray";
        }
    }
}
function ResetAllElements()
{
    //debugger;
    objs=window.document.getElementsByTagName('tr');
    
    for (var i=0; i<objs.length; i++)
    {
        if(objs[i].id.indexOf("trDescription")>=0)
        {
            objs[i].style.display="none";
        }          
        if(objs[i].id.indexOf("trHeader")>=0)
        {
            if (objs[i].className == "jc_tableDarkGrayAfterLightPink") {
                objs[i].className = "jc_tableLightPink";
                objs[i].getElementsByTagName('label')[0].style.color = "#732c72";
            }
            if (objs[i].className == "jc_tableDarkGrayAfterPink") {
                objs[i].className = "jc_tablePink";
                objs[i].getElementsByTagName('label')[0].style.color = "#732c72";
            }
            if (objs[i].className == "jc_tableDarkGrayAfterGray") {
                objs[i].className = "jc_tableGray";
                objs[i].getElementsByTagName('label')[0].style.color = "#424242";
            }
            if (objs[i].className == "jc_tableDarkGrayAfterWhite") {
                objs[i].className = "jc_tableWhite";
                objs[i].getElementsByTagName('label')[0].style.color = "#424242";
            }
            for (var j = 0; j < objs[i].cells.length; j++) {
                if (objs[i].cells[j].innerHTML.indexOf("lblLocation") >= 0) {
                    objs[i].cells[j].getElementsByTagName('SPAN')[0].style.color = "#4b4a4a";
                }
                if (objs[i].cells[j].innerHTML.indexOf("lnkCompName") >= 0) {
                    objs[i].cells[j].getElementsByTagName('a')[0].style.color = "gray";
                }
                if (objs[i].cells[j].innerHTML.indexOf("lblPosted") >= 0) {
                    objs[i].cells[j].getElementsByTagName('SPAN')[0].style.color = "#4b4a4a";
                }
                if (objs[i].cells[j].innerHTML.indexOf("imgImg") >= 0) {
                    objs[i].cells[j].src = GetImgUrl() + "/arrow_small3.png";
                }
            }
            
        }         
    }     
    //ResetAllLabels();
    //ResetAllSpans();
    //ResetAllAnchors();
}
