// JavaScript Document
function elementFocus() { 
$(this).css({'border' : '1px solid #FF860D'});
//$(this).val('');
}

function elementBlur() { 
$(this).css({'border' : '1px solid #CCCCCC'});
//if ($(this).val() == '') { $(this).val($(this).attr('rel')); }
}

function field_isemail(field) 
{ 
	email = $(field).val();
	filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) 
	{
  		// Yay! valid
  		return true;
	}
	else
  	{
		return false;
	}
}

function validate() { 
	// alert("validate");
	var errorheader;
	var errormsg = new Array();
	var errorflag = false;
	
	
	if ($("input[name = 'user_name']").val() == "") { 
		errormsg[0] = '<h2 class="errormsg">Please enter your Name</h2>';
		errorflag = true;
	}
	
	if ( ($("input[name = 'user_email']").val() == "") || (field_isemail("#con_user_email") == false)) { 
		errormsg[1] = '<h2 class="errormsg">Please enter a valid Email Address</h2>';
		errorflag = true;
	}
	
	if ($("textarea[name = 'user_message']").val() == "") { 
		errormsg[2] = '<h2 class="errormsg">Please enter a Message you want emailed</h2>';
		errorflag = true;
	}
	
	
	
	if (errorflag == true) {
	errorheader = '<h1 class="errorheader">Oops, seems like you missed a few important fields...</h1>';
	
	var i=0;
	for (i=0; i < errormsg.length; i++) { 
		if (errormsg[i]) { errorheader += errormsg[i]; }
	}
	
    errorheader += '<h3 class="closewindow">This message will automatically close in <b>8 seconds</b>. To <b>CLOSE</b> it manually click anywhere outside this window.</h3>';
	
	$.blockUI({
		message: errorheader  }); 
        $('.blockOverlay').attr('title','Click to unblock').click($.unblockUI);
    
	setTimeout($.unblockUI, 8000); 
	
	return false; 
	} 
	else { return true; }
}



$(document).ready(function() {     
/*	$("input.textinput").focus(elementFocus);
	$("input.textinput").blur(elementBlur);
	$("textarea.textinput").focus(elementFocus);
	$("textarea.textinput").blur(elementBlur);
	*/
// override these in your code to change the default behavior and style 
$.blockUI.defaults = { 
    // message displayed when blocking (use null for no message) 
    message:  '<h1>Please wait...</h1>', 
 
    // styles for the message when blocking; if you wish to disable 
    // these and use an external stylesheet then do this in your code: 
    // $.blockUI.defaults.css = {}; 
    css: { 
        padding:        20, 
        margin:         0, 
        width:          '55%', 
        top:            '30%', 
        left:           '24%', 
        textAlign:      'left', 
        color:          '#000', 
        border:         '3px solid #aaa', 
		'-webkit-border-radius': '10px', 
        '-moz-border-radius':    '10px', 		
        backgroundColor:'#fff', 
        cursor:         'wait' 
    }, 
 
    // styles for the overlay 
    overlayCSS:  { 
        backgroundColor: '#000', 
        opacity:         0.6 
    }, 
 
     
    // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w 
    // (hat tip to Jorge H. N. de Vasconcelos) 
    iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank', 
 
    // force usage of iframe in non-IE browsers (handy for blocking applets) 
    forceIframe: false, 
 
    // z-index for the blocking overlay 
    baseZ: 1000, 
 
    // set these to true to have the message automatically centered 
    centerX: true, // <-- only effects element blocking (page block controlled via css above) 
    centerY: true, 
 
    // allow body element to be stetched in ie6; this makes blocking look better 
    // on "short" pages.  disable if you wish to prevent changes to the body height 
    allowBodyStretch: true, 
 
    // enable if you want key and mouse events to be disabled for content that is blocked 
    bindEvents: true, 
 
    // be default blockUI will supress tab navigation from leaving blocking content 
    // (if bindEvents is true) 
    constrainTabKey: true, 
 
    // fadeIn time in millis; set to 0 to disable fadeIn on block 
    fadeIn:  200, 
 
    // fadeOut time in millis; set to 0 to disable fadeOut on unblock 
    fadeOut:  400, 
 
    // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock 
    timeout: 0, 
 
    // disable if you don't want to show the overlay 
    showOverlay: true, 
 
    // if true, focus will be placed in the first available input field when 
    // page blocking 
    focusInput: true, 
 
    // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) 
    applyPlatformOpacityRules: true, 
    onUnblock: null, 
    quirksmodeOffsetHack: 4 
}; 		
	
});