function openWindow(url,oExtend) {
	// WINDOW ATTRIBUTES/PROPERTIES
	var oProps = {
		width: 100,
		height: 100,
		screenx: 0,
		screeny: 0,
		left: 0,
		top: 0,
		dependent: 'no',
		directories: 'no',
		fullscreen: 'no',
		location: 'no',
		menubar: 'no',
		resizable: 'no',
		scrollbars: 'no',
		status: 'no',
		toolbar: 'no'
	};
	// MERGE DEFAULT PROPERTIES WITH PROVIDED ARRAY
	for (var prop in oExtend) {
		if (oExtend.hasOwnProperty(prop)) {
			var val = oExtend[prop];
			prop = prop.toLowerCase();
			if (/^width|height|screenx|screeny|left|top$/.test(prop)) {
				val = parseFloat(val);
			}
			if (oProps.hasOwnProperty(prop)) {
				oProps[prop] = val;
			}
		}
	}
	// CENTER THE WINDOW
	oProps.screenx = oProps.left = ((screen.availWidth/2)-(oProps.width/2));
	oProps.screeny = oProps.top = ((screen.availHeight/2)-(oProps.height/2));
	// CONVERT THE PROPERTIES ARRAY INTO A STRING
	var strProps = '';
	for (var key in oProps) {
		if (oProps.hasOwnProperty(key)) {
			strProps += key + '=' + oProps[key] +',';
		}
	}
	// REMOVE THE LAST COMMA
	strProps = strProps.substring(0,strProps.length-1);
	// OPEN THE WINDOW
	var popWindow = window.open (url, "popwindow", strProps);
	// IF FOCUS IS SUPPORTED, PLACE THE WINDOW ON TOP
	if (window.focus) { popWindow.focus(); }
	// STANDARDS COMPLIANCE // PREVENT DEFAULT
	return popWindow;
}

$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form') return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea') this.value = '';
		else if (type == 'checkbox' || type == 'radio') this.checked = false;
		else if (tag == 'select') this.selectedIndex = -1;
	});
};

$(document).ready(function(){

	// webkit browsers load CSS and JS at the same time so make them wait a bit more
	if (jQuery.browser.safari && document.readyState != "complete") { setTimeout( arguments.callee, 100 ); return; }


	// ABENDAGO FORM VALIDATION //

	$("form *[rel='submit']").bind('click',function(){
		// we submit the form with JS because the validation requires JS.
		// this is to prevent a user from disabling JS in their browser and bypassing validation
		$(this).parents("form").submit();
		return false;
	});
	if ($.isFunction($.fn.validate)===true) {
		$("form#testform").validate({
			appendErrorBesideField: false,
			groupErrorMessage: true,
			errorDiv : ('div#error_testform'),
			//groupType : ['span.group','span.radio','span.checkbox'],
			groupType : 'span.group',
			callbackFunction: function(){
				alert("form was submitted successfully");
				return false;
			}
		});
	}


	// ABENDAGO GALLERY PLUGIN //
	
	if ($.isFunction($.fn.gallery)===true) {
		$("div#JQG_wrapper").gallery({  
			slideCanvasTime: 1000,
			slideThumbsTime: 500,
			aspectRatio: "fill",
			easeCanvasType: "easeInOutQuint",
			easeThumbsType: "easeOutQuad",
			nSelected: 0,
			nMargin: 2,
			nSlideAmount: 7,
			listener: function(e,o){
				//console.log(e);
			}
		});
	}
	
	
	// SWFOBJECT FLASH INJECTION //
	/*
	var reqVerMajor = 9;
	var reqVerMinor = 0;
	var reqRevision = 0;

	var reqFlashVersion = reqVerMajor+'.'+reqVerMinor+'.'+reqRevision;
	var currFlashVersion = GetSwfVer(reqVerMajor, reqVerMinor, reqRevision);
	var hasReqestedVersion = DetectFlashVer(reqVerMajor, reqVerMinor, reqRevision);
	
	if (hasReqestedVersion) {
		var	flashvars = {};
		var params = {};
		var attributes = {};
		params.menu = "false";
		params.wmode = "transparent";
		params.allowfullscreen = "false";
		params.allowscriptaccess = "always";
		swfobject.embedSWF("themes/project/flash/file.swf", "flashcontent", "500", "400", reqFlashVersion, "", flashvars, params, attributes);
	} else {
		$("div.warning p.flashversion span.have").text(currFlashVersion);
		$("div.warning p.flashversion span.need").text(reqFlashVersion);
		$("div.warning p.flashversion").show();
		$("div.warning").show();
	}
	*/


	//$('.tilt-right').rotate(3);

	if ($.isFunction($.fn.hint)===true) {
		$('form input[title!=""]').hint();
		$('form textarea[title!=""]').hint();
	}
	
	if ($.isFunction($.fn.colorbox)===true) {
		$('a.colorbox').colorbox();
	}



});
