var JS = jQuery.noConflict();
var RootPath = "/";	
jQuery(function() {
			jQuery('.protectedImg').bind("contextmenu", function(e) {
				e.preventDefault();
			});
		}); 
		
/*		jQuery.fn.protectImage = function(settings) {
	settings = jQuery.extend({
		image: '/bsa/images/blank.gif',
		zIndex: 100
	}, settings);
	return this.each(function() {
		var position = jQuery(this).position();
		var height = jQuery(this).height();
		var width = jQuery(this).width();
		jQuery('<img />').attr({
			width: width,
			height: height,
			src: settings.image
		}).css({
			border: '1px solid #f00',
			top: position.top,
			left: position.left,
			position: 'absolute',
			zIndex: settings.zIndex
		}).appendTo('body')
	});
};

*/


var WEB =  {
	type: "macintosh",
	color: "red",
	TopMenuName: "nav_menu",
	getInfo: function () {
		return this.color + ' ' + this.type + ' apple';
	},
	//Main dropdown menu
	mainmenu: function (e){
var menuid = this.TopMenuName; 
JS("."+menuid+" ul ").css({display: "none"}); // Opera Fix
JS("."+menuid+" li").hover(function(){
JS(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(200);
		},function(){
		JS(this).find('ul:first').css({visibility: "hidden"});
		});
},
// Ajax call function
_AJX: function(action,divplace,fvalue,arrvars){
var variables = arrvars;
var fvals = '';
if(fvalue!=''){
fvals = JS('#'+fvalue+'').val();
}
WEB._AJX_animate(divplace,true);
JS.post("/bsa/js/ajx", {'do': ''+action+'','fvars':''+fvals+'','arr': ''+arrvars+''}, function(data){
if(data){
			if(data.length >0) {
			WEB._AJX_animate(divplace,false);
				JS('#'+divplace+'').html(data);
			}else{
				JS('#'+divplace+'').html("&nbsp;");
			}
			}
		});

},
_AJX_animate : function (divplace,mode){
if(mode==true){
JS('#'.divplace).css("padding:","30px");
JS('#'.divplace).css("background","url(/bsa/images/loading_small.gif) no-repeat top right");
}else{
JS('#'.divplace).css("padding:","0px");
JS('#'.divplace).css("background","none");
}
}
	
}// last


function _checkbox(checkerbox,div){
if(checkerbox.checked){
JS('#'+div+'').show();
}
else{
JS('#'+div+'').hide();
}
}

function _confirm(text,url){
var answer = confirm(text)
	if (answer){
		window.location = url;
	}else{
	return false
	}
}
function _remove_id(innercontainer,confirma){
var answer = false;
var confirma;
if(confirma!=''){
var answer = confirm(confirma);
if(!answer){
return false;
}
}else{
answer = true;
}
if(answer){
var olddiv = document.getElementById(innercontainer);
 olddiv.parentNode.removeChild(olddiv);
}
}

function _uploadFields(FieldsIDContainer,fieldname,fieldlimit){
var NewField;
var Holder =document.getElementById(""+FieldsIDContainer+"");
var ChildCount = Holder.childNodes.length;
if( (ChildCount-3)<(fieldlimit-1)){
var myElement = "<input name=\""+fieldname+"[]\" type=\"file\" /> <img src=\"/bsa/images//icons/cross.png\" onclick=\"this.parentNode.parentNode.removeChild(this.parentNode)\" />";
var breakElem = document.createElement("div");
breakElem.innerHTML = myElement;
breakElem.setAttribute("class", "input_dynamics");
Holder.appendChild(breakElem);	
}else{
alert("The upload is limited to "+fieldlimit+" files");
}
}

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function WEB_drop_open()
{  WEB_drop_canceltimer();
   WEB_drop_close();
   ddmenuitem = JS(this).find('ul').css('visibility', 'visible');}

function WEB_drop_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
	}

function WEB_drop_timer()
{  closetimer = window.setTimeout(WEB_drop_close, timeout);}

function WEB_drop_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
	  closetimer = null;}}

JS(document).ready(function()
{  
/*jQuery('.protected').protectImage(); */
WEB.color = "reddish";
WEB.mainmenu();
JS('#WEB_drop > li').bind('mouseover', WEB_drop_open);
JS('#WEB_drop > li').bind('mouseout',  WEB_drop_timer);

});

document.onclick = WEB_drop_close;
