var myself;
var new_fade = {
	opacInterval: 0,
	opacity:100,
	obj_id: 'img1',
	lastTick: 1,
	lastTick2: 1,
	imgs:Array(),
	count: 2,
	maxpic:0,
	path:'',
	interval:5000,
	lnk:Array(),
	lnkcnt:1,
	init: function(path,interval,img,lnk) {
		this.interval=interval,
		this.lnk=lnk;
		this.path=path;
		this.imgs=img;
		this.maxpic=this.imgs.length-1;
		this.lastTick=new Date().getTime();
		this.lastTick2 = new Date().getTime();
		myself=this;
		document.getElementById('img2').src=this.path+this.imgs[1];
		document.getElementById('img1').parentNode.href=this.lnk[0];
		this.opacInterval=setInterval("callMethod2()",1);
	},
	tk: function (th) {
		var curTick = new Date().getTime();
		var elapsedTicks = curTick - th.lastTick;	 
		var elapsed2 = curTick - th.lastTick2;
		if(elapsed2<th.interval) return;
		if (elapsedTicks>10) {
			th.lastTick=curTick;
			object=document.getElementById(th.obj_id);
			object.style.opacity = (th.opacity / 100);
			object.style.MozOpacity = (th.opacity / 100);
			object.style.KhtmlOpacity = (th.opacity / 100);
			object.style.filter = "alpha(opacity=" + th.opacity + ")";
			th.opacity--;
			th.opacity--;
			if (th.opacity<=0) {
				document.getElementById('img1').parentNode.href=th.lnk[th.lnkcnt];
				th.lnkcnt++;
				if (th.lnkcnt>th.maxpic)th.lnkcnt=0;
				th.lastTick2=curTick;
				if (object.id=='img1') {
					if (th.count>th.maxpic)th.count=0;
					object.style.zIndex=1;
					th.obj_id='img2';
					object=document.getElementById(th.obj_id);
					object.style.zIndex=2;
					object=document.getElementById('img1');
					th.opacity=100;
					object.style.opacity = (th.opacity / 100);
					object.style.MozOpacity = (th.opacity / 100);
					object.style.KhtmlOpacity = (th.opacity / 100);
					object.style.filter = "alpha(opacity=" + th.opacity + ")";
					object.src=th.path+th.imgs[th.count];
					th.count++;
				} else {
					if (th.count>th.maxpic)th.count=0;
					object.style.zIndex=1;
					th.obj_id='img1';
					object=document.getElementById(th.obj_id);
					object.style.zIndex=2;

					th.opacity=100;
					object=document.getElementById('img2');
					object.style.opacity = (th.opacity / 100);
					object.style.MozOpacity = (th.opacity / 100);
					object.style.KhtmlOpacity = (th.opacity / 100);
					object.style.filter = "alpha(opacity=" + th.opacity + ")";
					object.src=th.path+th.imgs[th.count];
					th.count++;
				}
				//clearInterval(th.opacInterval);
				//object.style.display='none';
			}
		}
	},
	endfade: function() {
		clearInterval(this.opacInterval);
	}
}
function callMethod1() {
	myself.start(myself);
}
function callMethod2() {
	myself.tk(myself);
}


function changeImage(src,dst) {
	var d=document.getElementById(dst).childNodes[0];
	d.src=src.src.replace('images/products/XS_','images/products/L_');
	document.getElementById(dst).href=src.src.replace('images/products/XS_','images/products/XL_');
}



function initialize_ymap() {

	var myPoint = new YGeoPoint( 44.454231, 26.088124);
	// Create a map object
	var map = new YMap(document.getElementById('ymap'));
	// Display the map centered on a latitude and longitude
		map.drawZoomAndCenter(myPoint, 5);

	// Add zoom control
	map.addZoomLong();
	// Add the pan control
	map.addPanControl();

	// Create a new marker for an address
	var myMarker = new YMarker("Paris 14, Bucharest, Romania");
	// Add a label to the marker
	myMarker.addAutoExpand("Detalii");
	// Create some content to go inside the SmartWindow
	var myMarkerContent = "<strong>BritishGallery.ro</strong><br>Paris 14, sector 2, 011816, Bucuresti";
	// When the marker is clicked, show the SmartWindow
	YEvent.Capture(myMarker, EventsList.MouseClick,
	function() {
			myMarker.openSmartWindow(myMarkerContent);
		});
	// Put the marker on the map
	map.addOverlay(myMarker);

	// Astea nu le vreau acum
	//Add map type control
	//map.addTypeControl();
	// Default map to satellite (YAHOO_MAP_SAT) -- other opts: YAHOO_MAP_HYB, YAHOO_MAP_REG
	//map.setMapType(YAHOO_MAP_SAT);
}


function changeCode(obj){
	var a=document.getElementById('detailsfrm').getElementsByTagName('SELECT');
	var c=document.getElementById('detailsfrm').getElementsByTagName('INPUT');
	var b=document.getElementById('code').getElementsByTagName('SPAN');
	var comb=Array();
	var k=0;
	for (var i=0;i<a.length;i++) {
		comb[k]=a[k].value;
		k++;
	}
	for (var i=0;i<c.length;i++) {
		if (c[i].name.substr(0,4)=='ext_') {
			comb[k]=c[i].value;
			k++;
		}
	}
	comb=comb.sort(sortNumber);
	comb=comb.join('_');
	for (var i=0;i<b.length;i++) {
		b[i].className='hide';
		document.getElementById(b[i].id.replace('code_','stoc_')).className='hide';
	}
	document.getElementById('code_'+comb).className='';
	document.getElementById('stoc_'+comb).className='stoc';
}
function sortNumber(a,b)
{
	return a - b;
}

function makeSearchString(obj) {
	var input=obj.childNodes[0];
//	var input=document.getElementById('search');
	obj.action=obj.action+'cauta/'+input.value.replace(' ','+');
}


var galleryOptions = {
	slideshowGroup: 'gallery',
	wrapperClassName: 'dark',
	outlineType: 'glossy-dark',
	dimmingOpacity: 0.8,
	align: 'center',
	transitions: ['expand', 'crossfade'],
	fadeInOut: true,
	wrapperClassName: 'borderless floating-caption',
	marginLeft: 100,
	marginBottom: 80,
	numberPosition: 'caption'
};


if (hs.addSlideshow) hs.addSlideshow({
    slideshowGroup: 'gallery',
    interval: 5000,
    repeat: false,
    useControls: true,
    overlayOptions: {
    	className: 'text-controls',
		position: 'bottom center',
		relativeTo: 'viewport',
		offsetY: -60
	},
	thumbstrip: {
		position: 'bottom center',
		mode: 'horizontal',
		relativeTo: 'viewport'
	}

});	
