/*

$(document).ready(function()
	{
		// Set specific variable to represent all iframe tags.
		var iFrames = document.getElementsByTagName('iframe.popForm');

		// Resize heights.
		function iResize()
		{
			// Iterate through all iframes in the page.
			for (var i = 0, j = iFrames.length; i < j; i++)
			{
				// Set inline style to equal the body height of the iframed content.
				iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';
			}
		}

		// Check if browser is Safari or Opera.
		if ($.browser.safari || $.browser.opera)
		{
			// Start timer when loaded.
			$('iframe').load(function()
				{
					setTimeout(iResize, 0);
				}
			);

			// Safari and Opera need a kick-start.
			for (var i = 0, j = iFrames.length; i < j; i++)
			{
				var iSource = iFrames[i].src;
				iFrames[i].src = '';
				iFrames[i].src = iSource;
			}
		}
		else
		{
			// For other good browsers.
			$('iframe').load(function()
				{
					// Set inline style to equal the body height of the iframed content.
					this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
				}
			);
		}
	}
);
*/

pubUnBlock = function(){
	$.unblockUI();
};


function blocker(divToShow){
	var myElement = '#' + divToShow;
	var elementWidth = $(myElement).width();
	var documentWidth = $(document).width();
	var frameHeight = $(myElement).height();
    $.blockUI({
		message: $(myElement),
		css: {
			padding:	0,
			margin:		0,
			width:		elementWidth + 'px',
			top:		'15%',
			left:		(documentWidth-elementWidth)/2 + 'px',
			height:		'520px'
		},
		success: printit
	});
}

function printit(e){
	console.log('here')
}

function submitForm(thisForm){
	$('#form1').validate()
}

// get search engine and keys

if (null == $.cookie('refEngine')) {

    var refSource = "Other";
    var refURL = document.referrer;
    
    if (refURL != "") {
        if (refURL.search(/www.google/i) != -1) {
            refSource = "Google";
            getKW('q=', refURL, refSource);
        }
        
        if (refURL.search(/search.msn/i) != -1) {
            refSource = "MSN";
            getKW('q=', refURL, refSource);
        }
        
        if (refURL.search(/search.yahoo/i) != -1) {
            refSource = "Yahoo";
            getKW('p=', refURL, refSource);
        }
        
        if (refURL.search(/www.ask/i) != -1) {
            refSource = "Ask.com";
            getKW('q=', refURL, refSource);
        }
        
        if (refURL.search(/search.aol/i) != -1) {
            refSource = "AOL";
            getKW('query=', refURL, refSource);
        }
        
        if (refURL.search(/search.live/i) != -1) {
            refSource = "Live";
            getKW('q=', refURL, refSource);
        }
    }
    else {
        $.cookie('refEngine', 'Other', {
            expires: 365,
            path: '/'
        });
        $.cookie('refKeywords', 'NA', {
            expires: 365,
            path: '/'
        });
    }
}

function getKW(sVar, refURL, refSource){
    var startPoint = refURL.search(sVar);
    var endPoint = refURL.indexOf('&', startPoint);
    var kw = refURL.substr(startPoint + 2, ((endPoint - startPoint) - 2))
    kw = kw.replace(/\+/g, " ");
    $.cookie('refEngine', refSource, {
        expires: 365,
        path: '/'
    });
    $.cookie('refKeywords', kw, {
        expires: 365,
        path: '/'
    });
}



// Macromedia Functions
function MM_changeProp(objId, x, theProp, theValue){ //v9.0
    var obj = null;
    with (document) {
        if (getElementById) 
            obj = getElementById(objId);
    }
    if (obj) {
        if (theValue == true || theValue == false) 
            eval("obj.style." + theProp + "=" + theValue);
        else 
            eval("obj.style." + theProp + "='" + theValue + "'");
    }
}

// urchin tracking for inside body
function utSend(btnName){
    var trackString = btnName + thisPage;
    urchinTracker(trackString);
}


// Cookies
function cookieIt(btnName){
    var trackString = btnName + thisPage;
    if (!get_cookie("btnClick")) {
        set_cookie("btnClick", trackString);
    }
    else {
        delete_cookie("btnClick");
        set_cookie("btnClick", trackString, '', '', '', '/');
    }
}

function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure){
    var cookie_string = name + "=" + escape(value);
    if (exp_y) {
        var expires = new Date(exp_y, exp_m, exp_d);
        cookie_string += "; expires=" + expires.toGMTString();
    }
    if (path) 
        cookie_string += "; path=" + escape(path);
    if (domain) 
        cookie_string += "; domain=" + escape(domain);
    if (secure) 
        cookie_string += "; secure";
    document.cookie = cookie_string;
}

function delete_cookie(cookie_name){
    var cookie_date = new Date(); // current date & time
    cookie_date.setTime(cookie_date.getTime() - 1);
    document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function get_cookie(cookie_name){
    var results = document.cookie.match(cookie_name);
    if (results) 
        return (unescape(results[1]));
    else 
        return null;
}

// Expandit

function expandit(objname, image){
    var folder = '';
    curobj = objname + 'info';
    imgobj = objname + 'img';
    folder = getObjectRef(curobj).style;
    if (folder.display == "none") {
        folder.display = "";
        getObjectRef(imgobj).src = "spacer.gif";
    }
    else {
        folder.display = "none"
        getObjectRef(imgobj).src = "spacer.gif";
    }
}

function getObjectRef(n, d){

    //based off MM_findObj v4.01
    //n: String
    //d: Document (for netscape4 recursion)
    
    var p, i, x;
    
    if (!d) 
        d = document;
    
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) 
        x = d.all[n];
    
    for (i = 0; !x && i < d.forms.length; i++) 
        x = d.forms[i][n];
    
    for (i = 0; !x && d.layers && i < d.layers.length; i++) 
        x = getObjectRef(n, d.layers[i].document);
    
    if (!x && d.getElementById) 
        x = d.getElementById(n);
    
    return x;
}
