/*
*/

// browser detection
// var theWidth, theHeight;

var targetSWFHeight = 560;
var contentDiv;


function init(){
	contentDiv = document.getElementById("content");
	
	setVersion("flash");
}


// Window dimensions:
function getDimensions(){
	var obj = {};

	if( window.innerWidth) {
		obj.width=window.innerWidth;
	}
	else if(document.documentElement && document.documentElement.clientWidth) {
		obj.width=document.documentElement.clientWidth;
	}
	else if(document.body) {
		obj.width=document.body.clientWidth;
	}
	else {
	}

			
	if( window.innerHeight ) {
		obj.height=window.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight) {
		obj.height=document.documentElement.clientHeight;
	}
	else if(document.body) {
		obj.height=document.body.clientHeight;
	}
	else{
	}

	return obj;
}


function resizeContent() {
	
	if( getDimensions().height < targetSWFHeight ){
		newHeight = String(targetSWFHeight) + "px";
	}else{
		newHeight = "100%";
	}
	contentDiv.style.height = newHeight;
	contentDiv.style.top = "0px";
}


function adjustHeight(value) {
	targetSWFHeight = value;
	resizeContent();
}

var win_o = null;
var win_p = self;

function openPostWindow(url, width, height, sectionId, jobId, jobTitle)
{
    if (url.length == 0) { return(false); }

    window.name = 'MAIN';

    

    if (win_o && win_o.open) { win_o.close(); };

    var wl = (screen.width - width) / 2; var wt = (screen.height - height) / 2;

    win_o = window.open(url + '?sectionId=' + sectionId + '&jobId=' + jobId + '&jobTitle=' + escape(jobTitle), 'WIN_OPW', 'scrollbars=yes,toolbar=no,location=no,resizable=yes,height=' + height + ',width=' + width + ',top=' + wt + ',left=' + wl);

    if (win_o.opener) { win_o.opener = window; };

    /*
    if (win_o && win_o.open)
    {
        if (win_o.onbeforeunload)
        {
            win_o.onbeforeunload = opw_HideMask;
        }
        else
        {
            if (win_o.addEventListener) { win_o.addEventListener('beforeunload', opw_HideMask, true); };
        }

        if (win_o.focus) { win_o.focus(); };

        opw_ShowMask();
    }
    */
}
function opw_ShowMask()
{
    if (!win_p || (win_p && !win_p.open)) { return(false); };

    if (win_p.document)
    {
        if (!win_p.document.getElementById('win_o_mask'))
        {
            d = win_p.document;
            m = d.createElement('div');

            m.setAttribute('id',    'win_o_mask');
            m.setAttribute('style', 'position:absolute;filter:alpha(opacity=75);-moz-opacity:0.75;opacity: 0.75;height:auto;overflow:hidden;z-index:9999;top:0px;left:0px;background-color:#efefef;height:' + screen.height + 'px;width:100%;');

            d.body.appendChild(m);
            d.close();
        }

        win_p.document.getElementById('win_o_mask').style.visibility = 'visible';
    }
}
function opw_HideMask()
{
    if (!win_p || (win_p && !win_p.open)) { return(false); };

    if (win_p.document)
    {
        if (win_p.document.getElementById('win_o_mask'))
        {
            win_p.document.getElementById('win_o_mask').style.visibility = 'hidden';
        }
    }
}

//cookie management functions

function getexpirydate(nodays) 
{
    var UTCstring;
    Today = new Date();
    nomilli=Date.parse(Today);
    Today.setTime(nomilli+nodays*24*60*60*1000);
    UTCstring = Today.toUTCString();
    return UTCstring;
}

function getcookie(cookiename) 
{
    var cookiestring=""+document.cookie;
    var index1=cookiestring.indexOf(cookiename);
    if (index1==-1 || cookiename=="") return ""; 
    
    var index2=cookiestring.indexOf(';',index1);
    
    if (index2==-1) index2=cookiestring.length; 
        
    return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function setcookie(name,value,duration)
{
    cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
    document.cookie=cookiestring;
    if(!getcookie(name))
    {
        return false;
    }
    else
    {
        return true;
    }
}

function setVersion(verName)
{
    setcookie('HireMindsSiteVersion',verName,1);
}

//end cookie management functions

