/*scroll*/
var clipTop = 0;
var clipWidth = 380;
var clipBottom = 225;
var topper = 225;
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;

function init()
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('clipping');
	if (document.layers)
	{
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
		x.style.clip = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
	}
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function realscroll()
{
	if (!DHTML) return;
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function stopscroll()
{
	if (time) clearTimeout(time);
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}       

/* TICKER*/
function mouticker(vel)
{   
    if (document.getElementById) 
	{
		dns = document.getElementById("interior");
        dnsl =parseInt(dns.style.left);
		dns.style.left =(dnsl>(-151)) ? dnsl-vel+"px" : 810 + "px";
    }
} 

/*COMMENTS*/
function ObreComments(URL,nom) {
    var opcions="toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,left=100,top=100,width=400,height=410";
    contactwindow=window.open(URL, nom, opcions);
    if (window.focus) {contactwindow.focus()}
}

/*PHOTOS*/

function DOMCall(name) {
    if (document.layers)
        return document.layers[name];
    else if (document.all)
        return document.all[name];
    else if (document.getElementById)
        return document.getElementById(name);
}
var wi=1029;
var he=683;
function showPic (whichpic,id,w,h,lang) {
    wi=w;
    he=h;
    DOMCall('plh').setAttribute("href","../../imatge.php?id="+id+"&lang="+lang);
    DOMCall('plh').setAttribute("OnClick","ObreImatge(this.href,"+w+","+h+");return false;");
    DOMCall('placeholder').src = whichpic.href;
    return false;
}

function ObreImatge(URL) {
    var opcions="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=100,top=100,width="+wi+",height="+he;
    var nom="galeria";
    newwindow=window.open(URL, nom, opcions);
    if (window.focus) {newwindow.focus()}
}


$(document).ready(function(){
   init();setInterval('mouticker(2)',50);
 });
