
//***********************************************************************
// 	indexOf function fix for Internet Explorer
//***********************************************************************

if (!Array.indexOf) {
	Array.prototype.indexOf = function(obj) {
		for(var i=0; i<this.length; i++) {
			if (this[i]==obj) {
				return i;
			}
		}
		return -1;
	}
}


//***********************************************************************
//	- Posem el focus al primer camp del formulari
//	- Canviem el color del border quan el camp agafa el focus o quan el perd
//***********************************************************************

$(document).ready(function() {	
	//$(':input:visible:enabled:first').focus();
	
	/*$('input, textarea, select').focus(function(){
		$(this).css('border', '1px solid #D69728');
	});*/
	
	/*$('input, textarea, select').blur(function(){
		$(this).css('border', '1px solid #999999');
	});*/
});


function OpenWindow(url, w, h)
{
	var l = parseInt((screen.width - w)/2);
	var t = parseInt((screen.height - h)/2);
	var n = parseInt(Math.random() * 1000);
	var nw = window.open(url, "NewWindow" + n, "width=" + w + "px,height=" + h + "px,left=" + l + "px,top=" + t + "px");
	
	return nw;
}

function OpenWindowWScroll(url, w, h)
{
	var l = parseInt((screen.width - w)/2);
	var t = parseInt((screen.height - h)/2);
	var n = parseInt(Math.random() * 1000);
	var nw = window.open(url, "NewWindow" + n, "width=" + w + "px,height=" + h + "px,left=" + l + "px,top=" + t + "px,scrollbars=1");
}

/* Menu CSS Hover IE6 Hack */

var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
	  closetimer = null;}}

$(document).ready(function()
{  $('#menu > li').bind('mouseover', jsddm_open)
   $('#menu > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;
