var HR_WEB_ROOT = 'https://recruit.hr-on.com/';
/*
* Parses a string to an object containing the individual url components and the query.
*
*/
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
if ($1) uri[o.q.name][$1] = $2;
});
return uri;
};
/*
* Concatenates an object from the above function back to a usable url.
*
*/
function concatUri(u){
q = [];
for(i in u.queryKey){
q.push(i+'='+u.queryKey[i]);
}
return (u.protocol ? u.protocol+'://' : '')
+ (u.host ? u.host : '')
+ (u.path ? u.path : '')
+ (q.length ? '?'+q.join('&'):'');
}
function concatQueryString(query){
var q = [];
var i;
for(i in query){
q.push(i+'='+query[i]);
}
return q.join('&')
}
parseUri.options = {
strictMode: false,
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
q: {
name: "queryKey",
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
}
};
if(window.location.href.search(/vaerk\.(net|com)\//) > -1){
setTimeout(function() {
try {
document.getElementById('hrskyen').style.marginBottom = "-55px";
} catch(e) {
setTimeout(arguments.callee,100);
}
},100);
}
if(window.location.href.search(/(&|\?)teststage/) > -1){
HR_WEB_ROOT = 'http://servertest.hr-skyen.dk/';
}
if(window.location.href.search(/(&|\?)demostage/) > -1){
HR_WEB_ROOT = 'http://demo.hr-skyen.dk/';
}
////Debugging purposes mostly.Ie9 in IE7 mode can't stringify JSON. DomHelpers.requiresJSON does not seem to load
//json2.js as desired. Trying this alternative.
if(
navigator.userAgent.indexOf('MSIE') > -1 &&
(
navigator.userAgent.indexOf('MSIE 7.0') > -1
|| (document.documentMode && document.documentMode <= 7)
|| navigator.userAgent.indexOf('MSIE 6.0') > -1
)
) document.writeln('');
//document.writeln('');
function HRSkyen(opt){
//Holds options
var options = opt;
//log statistics for job views.
try {
if ( opt.search )
var locationsearch = opt.search;
else
var locationsearch = unescape(location.search);
} catch (e) {
var locationsearch = unescape(location.search);
}
if ( /show-job[|\|\/·N][0-9]+/.test(locationsearch) ) {
if(window.hrSkyenJobDisplayed){
/*Prevent execution if another frame has already loaded a job.*/
return;
}
try {
var jobid = locationsearch.match(/=show-job[|\|\/·N][0-9]+/);
jobid = jobid[0].replace(/[^0-9]/g,'');
var referrer = document.referrer ? document.referrer : "hidden";
if ( referrer == 'hidden' && locationsearch.match(/\?c=8/) ) {
referrer = 'http://www.jobnet.dk/';
}//if
if ( !opt.disablestatistics ) {
var stat = new Image();
stat.src = HR_WEB_ROOT + "jobpostings-statistics.php?companyid=" + options.companyId + "&jobid=" + jobid + "&referrer=" + escape(referrer) + "&linkref=" + getUrlParameter('linkref');
if (locationsearch.indexOf('forcereferrer') !== -1) {
stat.src += "&forcereferrer=" + getUrlParameter('forcereferrer');
}
}
} catch(e) {}
/* Ensure that only one frame loads jobpostings. */
try {
if ( opt.multiload )
window.hrSkyenJobDisplayed = false;
else
window.hrSkyenJobDisplayed = true;
} catch (e) {
window.hrSkyenJobDisplayed = true;
}
}//if
/*
* Throw exceptions on bad config.
*/
if(!options.container)
throw "Please specify a valid DOM id in options.container";
if(typeof(options.container) == "string"){
options.container = document.getElementById(options.container);
}
if(!options.queryKey) options.queryKey = 'hr-cloud';
if(!options.companyId || !parseInt(options.companyId))
throw "Please specify a valid company id in options.companyId";
if(!options.locale) options.locale = '';
//check for locale in query string and overwrite if any
var qlocale = locationsearch.match(/locale=([a-z]{2}_[A-Z]{2})/);
try {
if ( qlocale[1].length == 5 ) {
options.locale = qlocale[1];
}
} catch (e) {
}
var sd = locationsearch.match(/sd=1/);
if (sd) {
options.persistent['sd'] = 1;
}
options.persistent['locale'] = options.locale;
//If no default action is specified in options then just list jobs.
if(!options.action) options.action = 'list-jobs';
//If no width is specified fallback to the container width
if(typeof(options.width) == "undefined") options.width = '100%';
if(!options.params) options.params = {};
//Holds persistent GET parameters (All pages will have these sent with the request!)
var persistent = [];
//Store settings in the persistent data array, these data are carried through in every action performed in frame.
var p;
var i;
var v;
//For future use you can send additional persistent data in the options object.
if(!options.persistent){
options.persistent = {};
}
//Add the standard persistent data.
options.persistent['companyid'] = options.companyId;
options.persistent['xdmframe'] = 1;
if ( locationsearch.match(/editcv/) ) {
options.persistent['locationsearch'] = locationsearch;
}
options.persistent['linkref'] = getUrlParameter('linkref');
if(getUrlParameter('expandform') !== false) {
options.persistent['expandform'] = 1;
}
//Build an array with the data, suitable for concatting with join into a useable querystring.
if(options.persistent){
p = options.persistent;
for(i in p){
v = p[i];
if(v.constructor == Array) v = v.join(',');
persistent.push(i+'='+encodeURIComponent(v));
}
}
persistent.push('metaTitle='+encodeURIComponent(document.title));
if(!options.redirectWindow){
options.redirectWindow = window;
}
/*
* Helper functions
*/
function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1));
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam) {
return sParameterName[1];
}
}
return false
}
//Gets current scroll position on the document body
function getScrollXY() {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
//Netscape compliant
scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//DOM compliant
scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
return {x: scrOfX, y:scrOfY};
}
/*
* gets the offset for the popups in the frame
*/
function getOffsetTop(obj) {
var parentEl = obj;
var pScroll = 0;
var offsetTop = 0;
while (parentEl!=null){
if(parentEl.scrollTop > 0){
pScroll += parentEl.scrollTop;
parentEl = null;
} else {
offsetTop += parentEl.offsetTop;
parentEl = parentEl.offsetParent;
}
}
return (getScrollXY().y + pScroll) - offsetTop;
}
var hrBaseUrl;
var scrollUpdInterval;
var iframeElem;
options.container.innerHTML = '';
//Initialize the XDM RPC socket.
var XDMRpc = new easyXDM.Rpc({
props: {allowTransparency: true, allow: "microphone; camera", style: {width: (typeof(options.width) == "number" ? options.width+'px' : options.width),overflow:'hidden',border:'none'}},
swf: HR_WEB_ROOT + 'js/easyXDM/easyxdm.swf',
remote: HR_WEB_ROOT + 'frame-api/xdm_frame.php?'+
'persistent='+
encodeURIComponent(persistent.join('&'))+
'&companyid='+options.companyId,
container: options.container,
onReady: function(){
iframeElem = options.container.getElementsByTagName('iframe')[0];
//Send URL and channel info for later use in preview / joburls / redirects etc.
var referer = parseUri(options.redirectWindow.location.href);
delete referer.queryKey[options.queryKey];
//Since options contains cyclic elements and we want to send it through XDM
//We must make a new instance of options, without cyclic elements
var tmpOpts = {
params:options.params,
persistent:options.persistent,
companyId:options.companyId,
queryKey:options.queryKey,
action:options.action,
width:options.width,
locale:options.locale
};
XDMRpc.sendChannelInfo(concatUri(referer),tmpOpts);
//If a hr-cloud parameter is specified in the current location
//Then load that action / url, else load the default action from options.
u = parseUri(options.redirectWindow.location.href);
if(u.queryKey[options.queryKey]){
XDMRpc.loadContentUrl(decodeURIComponent(u.queryKey[options.queryKey]),true);
} else {
XDMRpc.loadContentUrl(options.action);
}
// On show-job page and if the setReferrer function exists in xdm_frame.js
if(jobid && typeof XDMRpc.setReferrer != "undefined") {
XDMRpc.setReferrer(referrer);
}
//HACK - temporary make admiral hotel ( companyid 75 ) transparent - we need the spanish webbureau
if(options.allowtransparency || options.companyId == 75 || options.companyId == 35 ) {
iframeElem.setAttribute('allowtransparency','true');
}
//Continuously send new scroll offset to the framed page, this is used later to reposition any dialogues that may appear.
var lastScroll = -1;
var updateScrollFunc = function(){
var offset = getOffsetTop(options.container);
if(lastScroll != offset)
XDMRpc.setScroll(offset > 0 ? offset : 0);
lastScroll = offset;
}
scrollUpdInterval = setInterval(updateScrollFunc,1000);
}
},
{
local: {
setSize:function(newSize){
if(iframeElem)
iframeElem.style.height = (newSize+20)+'px';
},
setUrl:function(newUrl, absolute){
absolute = (typeof absolute !== 'undefined' && typeof absolute !== 'function') ? true : false;
//Get action name from url
relativeUrl = newUrl.match(new RegExp('(frame-api/pages/|'+hrBaseUrl+')(.*)'));
//If url is external redirect on top window.
if(!relativeUrl || absolute) top.location.href = newUrl;
else relativeUrl = relativeUrl[2];
var action = relativeUrl.split('/')[0];
var newParsedUrl = parseUri(relativeUrl);
for(var i in options.persistent){
delete newParsedUrl.queryKey[i];
}
for(var i in options.params[action]){
delete newParsedUrl.queryKey[i];
}
if(options.actionurl){
u = parseUri(options.actionurl);
} else {
u = parseUri(options.redirectWindow.location.href);
}
u.queryKey[options.queryKey] = encodeURIComponent(concatUri(newParsedUrl).replace('/','|'));
u.queryKey[options.queryKey] = encodeURIComponent(concatUri(newParsedUrl).replace('·','|'));
options.redirectWindow.location.href = concatUri(u);
},
scrollToTop:function(){
scroll(0,0);
},
setHrBaseUrl:function(url){
hrBaseUrl = url;
},
setTitle: function(title){
try {
if ( options.multiload ) {} else {document.title = title;}
} catch (e) {document.title = title;}
},
scrollToContainer: function() {
document.getElementById(container).scrollIntoView();
},
scrollToId: function(id, pos) {
document.getElementById(id).scrollIntoView();
if (pos) {
window.scrollBy(0, pos);
}
},
scrollToClass: function(className, index) {
var index = index || 0;
document.getElementsByClassName(className)[index].scrollIntoView();
},
scrollToPos: function(pos){
window.scrollBy(0, pos);
},
removeElem: function(selector) {
document.querySelector(selector).outerHTML = ''
},
setTitles: function(title) {
XDMRpc.setTitle(title);
document.querySelector('[id^="easyXDM_"]').setAttribute('title', title);
}
},
remote: {
loadContentUrl:{},
setScroll:{},
sendChannelInfo:{},
setTitle:{},
setReferrer:{}
}
});
}
var getScript = function(source, callback) {
var script = document.createElement('script');
var prior = document.getElementsByTagName('script')[0];
script.async = 1;
script.onload = script.onreadystatechange = function(_, isAbort) {
if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
script.onload = script.onreadystatechange = null;
script = undefined;
if (!isAbort) if (callback) callback();
}
};
script.src = source;
prior.parentNode.insertBefore(script, prior);
};