// pop ajax
function loadSWF(url,targetID){
	//Check for existing SWF
	if(isObject(targetID)){
		//replace object/element with a new div
		replaceSwfWithEmptyDiv(targetID);
	}
	
	//Embed SWF
	if (swfobject.hasFlashPlayerVersion("8")) {
		var attributes = { data: url, width:"100%", height:"100%" };
		var params = { wmode:"transparent", menu:"false", quality:"high" };
		var obj = swfobject.createSWF(attributes, params, targetID);
	}
	
	//Show div
	document.getElementById('pop').style.display='block';void(0);

}

function isObject(targetID){
	var isFound = false;
	var el = document.getElementById(targetID);
	if(el && (el.nodeName === "OBJECT" || el.nodeName === "EMBED")){
		isFound = true;
	}
	return isFound;
}

function replaceSwfWithEmptyDiv(targetID){
	var el = document.getElementById(targetID);
	if(el){
		var div = document.createElement("div");
		el.parentNode.insertBefore(div, el);
		//Remove the SWF
		swfobject.removeSWF(targetID);
		//Give the new DIV the old element's ID
		div.setAttribute("id", targetID);
	};
};


//abre janela nova
function popUp(theURL,winName,w,h,scroll){	
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	features = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',status=yes';
	janela=window.open(theURL,winName,features);
	janela.focus();
};

//scroll nav
Event.observe(window, 'load', function() {
  $$('a[href^=#]:not([href=#])').each(function(element) {
    element.observe('click', function(event) {
      new Effect.ScrollTo(this.hash.substr(1));
      Event.stop(event);
    }.bindAsEventListener(element))
  })
})
