/****************************************************************/

/*                                                              */

/*                      IMAGES SECTION                          */

/*                                                              */

/****************************************************************/



if (document.images)
{
	var mouse_over = new Array();
	var mouse_out = new Array();

	for (i=1; i<=2; i++)
	{
		mouse_over["language" + i] = new Image();
		mouse_out["language" + i] = new Image();
		mouse_over["language" + i].src = "./user/imgs/language" + i + "over.gif";
		mouse_out["language" + i].src = "./user/imgs/language" + i + "out.gif";
	}
}



function SwapImage (imageName)
{
	if (document.images)
	{
		document[imageName].src = mouse_over[imageName].src;
	}
}



function ImageRestore (imageName)
{
	if (document.images)
	{
		document[imageName].src = mouse_out[imageName].src;
	}
}



/****************************************************************/

/*                                                              */

/*                      FADING SECTION                          */

/*                                                              */

/****************************************************************/



var opacityTimer;

var loadingTimer;



function Loading (objID)
{

	var value = document.getElementById(objID).firstChild.nodeValue;
	switch (value)
	{

		case "...":
			document.getElementById(objID).firstChild.nodeValue = '';

			break;

		default:
			document.getElementById(objID).firstChild.nodeValue = value + '.';
			break;
	}

	loadingTimer = setTimeout("Loading('" + objID + "')", 350);

}



function HideLoading (obj_hide, obj_show, imageId, obj_description)
{

	if (loadingTimer)
	{
		clearTimeout(loadingTimer);
	}

	document.getElementById(obj_hide).style.display = "none";

	image = document.getElementById(imageId);

	setOpacity(image, 0);

	image.style.visibility = "visible";

	document.getElementById(obj_show).style.display = "block";

	document.getElementById(obj_description).style.display = "block";

	fadeIn(imageId,0);
}



function fadeIn (objId, opacity)
{

	if (document.getElementById)
	{

		obj = document.getElementById(objId);

		if (opacity <= 100)
		{

			setOpacity(obj, opacity);
			opacity += 10;
			opacityTimer = setTimeout("fadeIn('" + objId + "', " + opacity + ")", 30);
		}
		else
		{

			if (opacityTimer)
			{
				clearTimeout(opacityTimer);
			}
		}

	}

}



function setOpacity (obj, opacity)
{

	// IE/Win

	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}



/****************************************************************/

/*                                                              */

/*                      SCROLL SECTION                          */

/*                                                              */

/****************************************************************/



var scrollDownTimer;

var scrollUpTimer;

var name_frame;



function InitFrame (_frame)
{
	name_frame = _frame;
}

function scrollDown ()
{

    window.frames[name_frame].scrollBy(0,5); 
	scrollDownTimer = setTimeout("scrollDown()",20);
}



function scrollDownStop ()
{
	if (scrollDownTimer)
	{
		clearTimeout(scrollDownTimer);
	}

}



function scrollUp ()
{
	window.frames[name_frame].scrollBy(0,-5);
	scrollUpTimer = setTimeout("scrollUp()",20);
}



function scrollUpStop ()
{
	if (scrollUpTimer)
	{
	 	clearTimeout(scrollUpTimer);
	}

}



/****************************************************************/

/*                                                              */

/*                   MENU-EXPAND SECTION                        */

/*                                                              */

/****************************************************************/



function MenuUpdate (_parent_container, _div_id)
{

	var tag = "div";
	var state = "";	

	if (_div_id != "noname")
	{
		state = ChangeState(document.getElementById(_div_id).style.display);
		ContractMenu(tag,_parent_container);
		document.getElementById(_div_id).style.display = state;
	}
	else
	{
		ContractMenu(tag,_parent_container);
	}

}



function ContractMenu (_tag, _parent_container)
{

	var num_elem = document.getElementById(_parent_container).getElementsByTagName(_tag).length;	

	for (i = 0; i < num_elem; i++)
	{
		document.getElementById(_parent_container).getElementsByTagName(_tag)[i].style.display = "none";
	}

}

function borraFoto (i)
{
	if(i==1)
	{
		document.getElementById('verFotos').style.display = "none";	
	}
	else
	{
		document.getElementById('verFotos').style.display = "block";	
	}
}

function eliminarElemento(id)
{
	imagen = document.getElementById(id);

	if (!imagen)
	{
		alert("El elemento selecionado no existe");
	} 
	else 
	{
		padre = imagen.parentNode;
		padre.removeChild(imagen);
	}
}

function ChangeState (_state)
{

	if (_state == "none")
	{
		return "block";
	}
	else
	{
		return "none";
	}

}



/****************************************************************/

/*                                                              */

/*                   SCREEN-SIZE SECTION                        */

/*                                                              */

/****************************************************************/



function GetScreenSize ()
{
	if (self.screen)
	{

		document.main_form.sizeX.value = screen.availWidth;
		document.main_form.sizeY.value = screen.availHeight;
	}

	else
	{
		document.main_form.sizeX.value = 0;
		document.main_form.sizeY.value = 0;
	}

}



function GoTo (_url)
{

	GetScreenSize();
	document.main_form.action = "./user/" + _url;
	document.main_form.submit();
}



function GoToPage (_url)
{

	GetScreenSize();
	document.main_form.action = "./" + _url;
	document.main_form.target = "contenido";
	document.main_form.submit();
}

function GoToPage1 (_url)
{

	GetScreenSize();
	borraFoto(1);
	document.main_form.action = "./" + _url;
	document.main_form.target = "contenido";	
	document.main_form.submit();
}



function GoToPhotos (_url)
{
	GetScreenSize();	
	document.main_form.action = "./" + _url;
	document.main_form.target = "contenido";
	document.main_form.submit();
}



function ViewPhotos (_pgm, _photo)
{
	document.view_form.sizeX.value = screen.availWidth;
	document.view_form.sizeY.value = screen.availHeight;
	document.view_form.photo.value = _photo;
	document.view_form.pgm.value = _pgm;
	document.view_form.target = "verFotosIfr";
	document.view_form.submit();
}



function ViewProductions (_photo_id, _action,_pg,_sub_posicion)
{	

	document.production_form.sizeX.value = screen.availWidth;
	document.production_form.sizeY.value = screen.availHeight;
	document.production_form.photo_id.value = _photo_id;
	document.production_form.sub_posicion.value = _sub_posicion;
	document.production_form.action.value = _action;
	document.production_form.pgName.value = _pg;
	document.production_form.target = "contenido";
	document.production_form.submit();
}

function ViewProductions2 (_photo_id, _action,_pg,_sub_posicion,_posicion)
{	

	document.production_form.sizeX.value = screen.availWidth;
	document.production_form.sizeY.value = screen.availHeight;
	document.production_form.photo_id.value = _photo_id;
	document.production_form.sub_posicion.value = _sub_posicion;
	document.production_form.posicion.value = _posicion;
	document.production_form.action.value = _action;
	document.production_form.pgName.value = _pg;
	document.production_form.target = "contenido";
	document.production_form.submit();
}


// FUNCION EXTRA AŅADIDA

function openingCheck()
{

	var str = window.location.search;
	

	if( str != "" ) {

		var id  = str.substr(str.indexOf("=") + 1);
		var strID = 'photographer.php?pg=' + id;
	

		MenuUpdate('main_menu','photographers');
		GoToPage(strID);	

		MenuUpdate('submenu_photographer', id);
	}

}

