/*********************************************************************
* Copyright 2008 Amblique :: www.amblique.com :: All Rights Reserved *
**********************************************************************
* JAVASCRIPT AND OTHER SCRIPTING
*********************************************************************/

/**********************************
* jQuery scripts
**********************************/
// noConflict :: http://docs.jquery.com/Core/jQuery.noConflict
// jQuery.noConflict();
$(document).ready(function(){
	// IE PNG Fix :: http://www.campbellsdigitalsoup.co.uk/about/png-fix
	//jQuery("img[src$=png], #nav-side-btm, #content-right-btm, #nav-side-left, #nav-side-right, #main-side-left, #content-right-inner #main-side-right").pngfix();
	
	// PopupWindow :: http://plugins.jquery.com/project/PopupWindow
	var profiles = {
		popupToolsPrint:{height:500,width:600,center:1,scrollbars:1,status:0,resizable:1},
		popupToolsEmail:{height:400,width:500,center:1,scrollbars:1,status:0,resizable:1}
	};
	$(".tool").popupwindow(profiles);
	
	// jQuery Lightbox :: http://leandrovieira.com/projects/jquery/lightbox
	$('a[rel*=lightbox]').lightbox({
		overlayBgColor: '#FFF',
		overlayOpacity: 0.8,
	containerBorderSize: 10,
		containerResizeSpeed: 400,
		imageLoading: 'images/lightbox/loading.gif',
		imageBtnClose: 'images/lightbox/close.gif',
		imageBtnPrev: 'images/lightbox/prevlabel.gif',
	imageBtnNext: 'images/lightbox/nextlabel.gif'
  });
	
	// Font resize
	//fontResizer('10px','11px','12px');
	
	//OVERLAY Stuff
	// if function argument is given to overlay it is assumed onBeforeLoad event listener
	$("a[rel*=overlay]").overlay({
		
		onBeforeLoad: function() {
		// grab wrapper element inside content
		var wrap = null;
		var link = this.getTrigger().attr("href");
		
		this.getBackgroundImage().expose({color: '#fff'}); 
		if (this.getContent().find("iframe").length > 0)
			wrap = this.getContent().find("iframe")[0];
		
		// load only for the first time it is opened
		if (wrap != null) {
			if (wrap.src != link)  {
				wrap.src = link;
			}
		}
		},
		onClose: function() { 
            $.expose.close(); 
        }		 
	});	
	
});

/**********************************
* Custom scripts
**********************************/

/***** Google toolbar yellow fields Fix *****/
if(window.attachEvent)
window.attachEvent("onload",setListeners);

function setListeners(){
inputList = document.getElementsByTagName("INPUT");
for(i=0;i<inputList.length;i++){
	inputList[i].attachEvent("onpropertychange",restoreStyles);
	inputList[i].style.backgroundColor = "";
}
selectList = document.getElementsByTagName("SELECT");
	for(i=0;i<selectList.length;i++){
		selectList[i].attachEvent("onpropertychange",restoreStyles);
		selectList[i].style.backgroundColor = "";
	}
}
function restoreStyles(){
	if(event.srcElement.style.backgroundColor != "" && event.srcElement.style.backgroundColor != "#a0d0ff"){
		event.srcElement.style.backgroundColor = "#a0d0ff"; /* color of choice for AutoFill */
		document.all['googleblurb'].style.display = "block";
	}
}

/***** Clear Input Text *****/
function clearText(thefield, clearType){ 
	if (thefield.defaultValue==thefield.value) {
		thefield.value = ""
	}		
}

/* jQuery Scripts */
function CloseOverlay(){
	//$(window).trigger('click');
	$('.close').trigger('click');
}

function CloseParentOverlay() {

		if (parent) {
			if (parent.CloseOverlay) {
				parent.CloseOverlay();
			}
		}
	
}
