var RB;
if(!window.rb_site) {
    window.rb_site = 'www.resumebucket.com';
}
if(!window.partner_logo) {
    window.partner_logo = '';
}
if(!window.rb) {
    window.rb = {};
}
/* haha.ua is the same as YAHOO.env.ua. Its staright from YUI library. Thanks Yahoo */
var haha = {};
haha.ua = function() {
    var o={
        ie:0,
        opera:0,
        gecko:0,
        webkit: 0,
        mobile: null,
        air: 0
    };
    var ua=navigator.userAgent, m;
    if ((/KHTML/).test(ua)) {
        o.webkit=1;
    }
    m=ua.match(/AppleWebKit\/([^\s]*)/);
    if (m&&m[1]) {
        o.webkit=parseFloat(m[1]);
        if (/ Mobile\//.test(ua)) {
            o.mobile = "Apple"; // iPhone or iPod Touch
        } else {
            m=ua.match(/NokiaN[^\/]*/);
            if (m) {
                o.mobile = m[0]; // Nokia N-series, ex: NokiaN95
            }
        }
        m=ua.match(/AdobeAIR\/([^\s]*)/);
        if (m) {
            o.air = m[0]; // Adobe AIR 1.0 or better
        }
    }
    if (!o.webkit) { // not webkit
        m=ua.match(/Opera[\s\/]([^\s]*)/);
        if (m&&m[1]) {
            o.opera=parseFloat(m[1]);
            m=ua.match(/Opera Mini[^;]*/);
            if (m) {
                o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
            }
        } else { // not opera or webkit
            m=ua.match(/MSIE\s([^;]*)/);
            if (m&&m[1]) {
                o.ie=parseFloat(m[1]);
            } else { // not opera, webkit, or ie
                m=ua.match(/Gecko\/([^\s]*)/);
                if (m) {
                    o.gecko=1; // Gecko detected, look for revision
                    m=ua.match(/rv:([^\s\)]*)/);
                    if (m&&m[1]) {
                        o.gecko=parseFloat(m[1]);
                    }
                }
            }
        }
    }
    
    return o;
}();
var isOpera = haha.ua.opera, isSafari = haha.ua.webkit, isGecko = haha.ua.gecko, isIE = haha.ua.ie;
(function(){
if(!partner_site) { return; }
var rb = {
    h: 620,
    w: 850,
    partner: partner_site,
    get: function(el) { if(rb.isstr(el)) { return document.getElementById(el); } return el; },
    show: function (id) { var e = rb.get(id); if(e){ e.style.display = 'block'; } },
    hide: function (id) { var e = rb.get(id); if(e){ e.style.display = 'none'; } },
    isstr: function(o) { return typeof o === 'string'; },
    setIFrameSource: function() {
        var url = 'http://' +  rb_site + '/partner_signup/' + rb.partner + '?';
        var f;
        var fields = [];
        for(f in window.rb) {
            if(window.rb.hasOwnProperty(f)) {
                url += f + '=' + encodeURIComponent(window.rb[f]) + '&'; 
                fields[fields.length] = f;
            }
        }
        url += 'fields=' + encodeURIComponent(fields.join(','));
        rb.iframe.setAttribute("src", url);
    },
    maskScreen: function() {
        rb.screen_mask.style.display = 'block';
    },
    unmaskScreen: function() {
        rb.screen_mask.style.display = 'none';
    },
    showForm: function() {
				rb.getObjects( 'none' );
				rb.maskScreen();
        rb.show(rb.div);
    },
    hideForm: function() {
				rb.getObjects( '' );
				rb.unmaskScreen();
        rb.hide(rb.div);
    },
	getObjects: function( view ) {
			var flashers = document.getElementsByTagName( 'object' );
			for (var i=0; i<flashers.length; i++) {
				flashers[i].style.display = view;
			}
	},
    getDocumentHeight: function() {
        var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;
        var h = Math.max(scrollHeight, rb.getViewportHeight());
        return h;
    },
    getDocumentWidth: function() {
        var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth;
        var w = Math.max(scrollWidth, rb.getViewportWidth());
        return w;
    },
    getViewportHeight: function() {
        var height = self.innerHeight; // Safari, Opera
        var mode = document.compatMode;
        if ( (mode || isIE) && !isOpera ) { // IE, Gecko
            height = (mode == 'CSS1Compat') ?
                    document.documentElement.clientHeight : // Standards
                    document.body.clientHeight; // Quirks
        }
        return height;
    },
    getViewportWidth: function() {
        var width = self.innerWidth;  // Safari
        var mode = document.compatMode;
        if (mode || isIE) { // IE, Gecko, Opera
            width = (mode == 'CSS1Compat') ?
                    document.documentElement.clientWidth : // Standards
                    document.body.clientWidth; // Quirks
        }
        return width;
    },
	buildCorners: function( pos ) {
			// build the top-left corner
			var tl = new Array();
			tl[0] = document.createElement( 'div' );
			tl[0].id = pos;
			tl[0].className = 'c ';
			
			for (var i=1; i<=5; i++) {
				tl[i] = document.createElement( 'b' );
				tl[i].className = 'c'+i;
				tl[0].appendChild( tl[i] );
			}
			rb.div.appendChild( tl[0] );
	},
    getStyle: function( elem, name ) {
        if(elem.style[name])
            return elem.style[name];
        else if(elem.currentStyle)
            return elem.currentStyle;
        else if(document.defaultView && document.defaultView.getComputedStyle) {
            name = name.replace(/([A-Z])/g, "-$1");
            name = name.toLowerCase();
            var s = document.defaultView.getComputedStyle(elem, "");
            return s && s.getPropertyValue(name);
        }
        else
            return null;
    },
    getHeight: function( elem ) {
        return parseInt( rb.getStyle(elem, 'height') );
    },
    getWidth: function( elem ) {
        return parseInt( rb.getStyle(elem, 'width') );
    },
    centerElement: function( elem ) {
        if(!elem)
            return;
        var w = rb.getWidth(elem);
        var h = rb.getHeight(elem);

        var top = rb.scrollY() + ( rb.getViewportHeight()/2 ) - ( h/2 );
        if( top < 0 ) top = 0;

        var left = rb.scrollX() + ( rb.getViewportWidth()/2 ) - ( w/2 );
        if( left < 0 ) left = 0;
        elem.style.top = top + 'px';
        elem.style.left = left + 'px';
    },
    scrollX: function() {
        var de = document.documentElement;
        return self.pageXOffset || ( de && de.scrollLeft ) || document.body.scrollLeft;
    },
    scrollY: function() {
        var de = document.documentElement;
        return self.pageYOffset || ( de && de.scrollTop ) || document.body.scrollTop;
    },

    setTimesShown: function(numTimes) {

	var date = new Date();
	var name = 'timesShown';
	date.setTime(date.getTime()+(1000*60*60));
	var expires = "; expires="+date.toGMTString();
	document.cookie = name+"="+numTimes+expires+"; path=/";

/*	var cookie_date = new Date ( );  // current date & time
	cookie_date.setTime ( cookie_date.getTime() + 3600 );
	document.cookie = 'timesShown=' + numTimes + '; expires=' + cookie_date.toGMTString() + ';';
*/


    },
    getTimesShown: function() {
        var results = document.cookie.match ( '(^|;) ?' + 'timesShown' + '=([^;]*)(;|$)' );
        if (results) {
            return (unescape(results[2]));
        }
        else {
            return 0;
        }
    },
    init: function() {
        var sm = document.createElement('div');
        sm.setAttribute("id", "rb-screen-mask");
        document.body.appendChild(sm);
        sm.style.width = rb.getDocumentWidth() + "px";
        sm.style.height = rb.getDocumentHeight() + "px";
        rb.screen_mask = sm;
        var iframe;
        if (document.all){
            iframe = document.createElement('<iframe onload="RB.showForm();"></iframe>');
        }
        else if (document.getElementById) {
            iframe = document.createElement('iframe');
            iframe.onload=function(){RB.showForm();}
        }
        iframe.setAttribute("name", 'rbif');
        iframe.setAttribute("id", 'rbif');
        iframe.setAttribute("scrolling", "no");
        iframe.setAttribute("frameBorder", "0");
        iframe.style.border = 'none';
        iframe.style.width = (rb.w-28) + 'px';
        iframe.style.height = (rb.h-55) + 'px';
        iframe.style.border = 'none';
        iframe.style.overflow = 'hidden';
        rb.iframe = iframe;
        rb.setIFrameSource();

        var div = document.createElement("div");
        div.className = 'rb-pp';

        
        var bod = document.createElement('div');
        bod.className = 'rb-pp-bod';
        div.appendChild(bod);
        
        var head = document.createElement('div');
        head.className = 'rb-pp-head';
		head.style.background = 'url(' + partner_logo +') no-repeat top left';
        head.innerHTML = '<span onclick="RB.hideForm();" class="pp-close"><a href="javascript: RB.hideForm();" style="float:right;font: 12px Lucida Grande, Sans-serif;padding-right:38px;color:#000000;text-decoration:none;">No Thank You</span>';
        bod.appendChild(head);
				
        div.style.position = 'absolute';
        div.style.display = 'none';
        div.style.width = rb.w + 'px';
        div.style.height = rb.h + 'px';
        
        rb.centerElement(div);
				
        document.body.appendChild(div);
        bod.appendChild(rb.iframe);
        var foot = document.createElement('div');
        foot.className = 'rb-pp-foot';
        div.appendChild(foot);
	//foot.textAlign='right';
	//foot.innerHTML = '<a style="float:right;" href="javascript: RB.hideForm();">No thanks.</a>';

	    rb.div = div;			

/*
        var backdiv = document.createElement("div");
        backdiv.className = 'rb-bglayer';
        backdiv.appendChild(bod);
        backdiv.style.position = 'absolute';
        backdiv.style.display = 'none';
        backdiv.style.width = '100%';
        backdiv.style.height = '100%';
	backdiv.style.background-color = '#999999';
	backdiv.style.zIndex = '100';
*/

	    rb.buildCorners( 'tl' );
        //window.onresize = window.onscroll = function() { rb.centerElement(div); }
    }
};
RB = rb;
RB.timesShown = rb.getTimesShown();
RB.showPanel = function(){
    if(RB.timesShown>1) {
	return;
    }
    if(!rb.div) {
        rb.init(); 
    }
    else {
        // i am lazy i dont want to check if use submitted or not
        // so reset the src 
        rb.setIFrameSource(); 
    }
    RB.timesShown++;
    rb.setTimesShown(RB.timesShown);
    return false;
}
anchor_class_elem = anchor_class_elem || 'a';
var a_el;
if(anchor_class_elem && anchor_class) {
    var anchors = document.getElementsByTagName(anchor_class_elem);
    var c = '';
    var reg = new RegExp("\\b" + anchor_class + "\\b");
    for(var i = 0; i < anchors.length; i++) {
        var a = anchors[i];
        c = ( a && a.className ) ? a.className : '';
        if (c && c.match(reg) ) {
            anchors[i].onclick = function(val) {
                return function() {
                    if(!RB.timesShown) {
                        RB.showPanel();
                        return false;
                    }
                }
            }(i); 
        }
    }
}
else if(anchor_id && rb.get(anchor_id)) {
    a_el = rb.get(anchor_id);
}
else if(rb.get('rb_id')) { a_el = rb.get('rb_id'); }
else { return; }
if(a_el) {
    a_el.style.cursor = 'pointer';
    a_el.onclick = RB.showPanel;
}
})();
