// Check browser
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

var DRAG_dragging;
var offX = 0;
var offY = 0;
var loadingImg = new Image();
loadingImg.src = 'http://www.lacasagrande.es/scripts/cargando_imagen.gif';

// Shows a picture in a formatted layer. If layer doesnīt exist already, create it.
function showPicture(imageUrl, title1, title2) {
	// Layer does not exist. So letīs create it!
	content = '<link href="http://www.lacasagrande.es.es/lcg.css" rel="stylesheet" type="text/css" />'
	content += '<table border="0" cellspacing="0" cellpadding="0">';
	content += '<tr>';
	content += '<td width="1" height="1" background="http://www.lacasagrande.es/scripts/marco_n.gif"><img src="../scripts/spacer.gif" width="1" height="1"></td>';
	content += '<td width="1" height="1" background="http://www.lacasagrande.es/scripts/marco_n.gif"><img src="../scripts/spacer.gif" width="1" height="1"></td>';
	content += '<td width="1" height="1" background="http://www.lacasagrande.es/scripts/marco_n.gif"><img src="../scripts/spacer.gif" width="1" height="1"></td>';
	content += '</tr>';
	content += '<tr>';
	content += '<td width="1" height="1" background="http://www.lacasagrande.es/scripts/marco_n.gif"><img src="http://www.lacasagrande.es/scripts/spacer.gif" width="1" height="1"></td>';
	content += '<td valign=middle>';
	content += '<!-- interior inicio -->';
	content += '<table border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">';
	content += '<tr onMouseOver="setRowColor(this,\'#ffcc44\')" onMouseOut="setRowColor(this,\'#ffcc33\')">';
	content += '<td bgcolor="#ffcc33"><div align="right"><a href="#" ><img name="dragger" src="../scripts/spacer.gif" width="100" height="12" border="0"></a>';
	content += '<a href="#" onClick="closeShowreel()"><img src="http://www.lacasagrande.es/scripts/cerrar.gif" width="15" height="12" border="0" alt="cerrar"></a></div>';
	content += '</td>';
	content += '</tr>';
	content += '<tr>';
	content += '<td><img src="http://www.lacasagrande.es/scripts/spacer.gif" width="1" height="5"></td>';
	content += '</tr>';
	content += '<tr>';
	content += '<td>';
	content += '<div align=center><img name="showreelImg" src="' + imageUrl + '" border="1" hspace="6"></div>';
	content += '</td>';
	content += '</tr>';
	content += '<tr>';
	content += '<td><img src="http://www.lacasagrande.es/scripts/spacer.gif" width="1" height="8"></td>';
	content += '</tr>';
	content += '<tr>';
	content += '<td>';
	content += '<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">';
	content += '<tr>';
	content += '<td valign="top"><img src="http://www.lacasagrande.es/scripts/ventana_logo.gif" width="177" height="48" border="0"></td>';
	content += '<td width="129" valign="top" align="right">';

	if (title1 != "") {
		content += '<div id="showreel_t1" class="TituloFoto">'+title1+'</div>';
	}
	if (title2 != "")
	{
		content += '<div id="showreel_t2" class="TituloFoto">'+title2+'</div>';
	}

	content += '</td>';
	content += '</tr>';
	content += '</table>';
	content += '</td>';
	content += '</tr>';
	content += '</table>';
	content += '<!-- interior fin -->';
	content += '</td>';
	content += '<td width="1" height="1" background=http://www.lacasagrande.es/scripts/marco_n.gif><img src=http://www.lacasagrande.es/scripts/spacer.gif width=1 height=1></td>';
	content += '</tr>';
	content += '<tr>';
	content += '<td width="1" height="1" background="http://www.lacasagrande.es/scripts/marco_n.gif"><img src="http://www.lacasagrande.es/scripts/spacer.gif" width="1" height="1"></td>';
	content += '<td width="1" height="1" background="http://www.lacasagrande.es/scripts/marco_n.gif"><img src="http://www.lacasagrande.es/scripts/spacer.gif" width="1" height="1"></td>';
	content += '<td width="1" height="1" background="http://www.lacasagrande.es/scripts/marco_n.gif"><img src="http://www.lacasagrande.es/scripts/spacer.gif" width="1" height="1"></td>';
	content += '</tr>';
	content += '</table>';
	
	
//if (document.layers) {
   //var oLayer;
   //if(parentID){
    // oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
   //}else{
   //  oLayer = document.layers["showreel"].document;
  // }
   //oLayer.open();
   //oLayer.write(content);
   //oLayer.close();
   //document.layers["showreel"].document.images["dragger"].onmousedown=DRAG_begindrag;
   //document.layers["showreel"].document.images["dragger"].onmouseup=DRAG_enddrag;
 //}
 //else 
 if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") {
   document.getElementById("showreel").innerHTML = content;
   document.getElementById("showreel").style.visibility = "visible";
 }
 else 
 if (document.all) {
	        document.all("showreel").style.visibility = "visible";
	        document.all("showreel").innerHTML = content;
 			
      };
 
}
	

// Closes showreel layer
function closeShowreel() {
	
		if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") {
		document.getElementById("showreel").style.visibility = "hidden";
	}
	else if (document.all) {
		showreel.style.visibility = "hidden";
	}
	
}


// Checks if layer is already created. Returns TRUE if exists, otherwise it returns FALSE
function checkLayer(layer) {
	if (ns4) {
		if (document.getElementById[layer]) {
			return true;
		} else {
			return false;
		}
	} else if (ie4) {
		if (document.getElementById[layer]) {
			return true;
		} else {
			return false;
		}
	}
}

function DRAG_drag(e) {
	if (DRAG_dragging) {
		if (ie4) {
			mx=event.x;
			my=event.y;
			ob = document.all.showreel.style;
		} else {
			mx=e.pageX;
			my=e.pageY;
			ob = document.getElementById["showreel"];
		}
		ob.left = mx-offX;
		ob.top = my-offY;
		return false;
	} else {
		return true;
	}
}

function DRAG_begindrag(e){
	if (ie4) {
		ob = document.all.showreel;
		document.onmousemove=DRAG_drag;
		offX = event.x - parseInt(ob.style.left);
		offY = event.y - parseInt(ob.style.top);
	} else {
		ob = document.getElementById["showreel"];
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove=DRAG_drag;
		offX = e.pageX - parseInt(ob.left);
		offY = e.pageY - parseInt(ob.top);
	}

	DRAG_dragging=true;
	return false;
}


function DRAG_enddrag(e){
	if (ie4)
	{
		document.onmousemove=null
	} else {
		window.releaseEvents(Event.MOUSEMOVE);
		window.onmousemove=null
	}
	DRAG_dragging=false;
	return false;
}
function setRowColor(x,newColor){
	
	
		x.style.backgroundColor="#ffffff" ;

	 
}

