(function () { var getParam = function (name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); }; var getQueryString = function () { var prefix = encodeURIComponent("jobid") + '='; var pars = location.search.substring(1).split(/[&;]/g); for (var i = pars.length; i-- > 0; ) { if (pars[i].lastIndexOf(prefix, 0) !== -1) { pars.splice(i, 1); } } return pars.join('&'); }; var getParentWindowLocation = function() { var parent = window.location.href; var hash = parent.indexOf('#'); return (hash > 0) ? parent.substring(0, hash) : parent; }; var CVWIFrame = { navigate: function (idIFrame, customer) { var tJobId = getParam("jobid"); var tIframe = document.getElementById(idIFrame); //Redirect to jobdescription when a jobId is found in the querystring. if (tJobId) { var queryString = getQueryString(); if(queryString) { queryString = "&" + queryString; } tIframe.src = window.location.protocol + '//www.cvwarehouse.com/' + customer + '/jobsite/jobdescription.aspx?id=' + tJobId + queryString + '&parent=' + encodeURIComponent(getParentWindowLocation()); } else { var src = tIframe.getAttribute('data-src'); tIframe.src = src ? src + '&parent=' + encodeURIComponent(window.location.href) : window.location.protocol +'//www.cvwarehouse.com/' + customer + '/jobsite/joblist.aspx?parent=' + encodeURIComponent(window.location.href); } }, resizeIFrame: function(idIFrame, height) { document.getElementById(idIFrame).height = parseInt(height); document.getElementById(idIFrame).width = '100%'; } } if (!window.CVWIFrame) { window.CVWIFrame = CVWIFrame; } })(); var resizeCVWIFrameWrapper = function(height) { CVWIFrame.resizeIFrame('cvwarehouseIFrame', height); } var iframeId = "cvwarehouseIFrame"; var client = "freeiframe"; if (!!window.attachEvent) { window.attachEvent('onload', function () { CVWIFrame.navigate(iframeId, client); }); } else if (!!window.addEventListener) { window.addEventListener('load', function () { CVWIFrame.navigate(iframeId, client); }, false); } else { document.addEventListener('load', function () { CVWIFrame.navigate(iframeId, client); }, false); }