var search = 0;
var fcs = 0;
var Days = new Array('Duminica','Luni','Marti','Miercuri','Joi','Vineri','Sambata');

var today = new Date();
var Year = takeYear(today);
var Month = leadingZero(today.getMonth()+1);
var DayName = Days[today.getDay()];
var Day = leadingZero(today.getDate());
var Hours = leadingZero(today.getHours());
var Minutes = leadingZero(today.getMinutes());
var Seconds = leadingZero(today.getSeconds());

function takeYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

function leadingZero(nr)
{
	if (nr < 10) nr = "0" + nr;
	return nr;
}
function searchOp1()
{
		
				document.getElementById('coversearch').style.filter='alpha(opacity=0)';
				document.getElementById('coversearch').style.MozOpacity=0;
				document.getElementById('coversearch').style.zIndex = 3;
				document.getElementById('cat').style.visibility = 'visible';
			
}
function searchOp2()
{

			if(fcs != 1)
			{
				search = 0;
				document.getElementById('coversearch').style.filter='alpha(opacity=73)';
				document.getElementById('coversearch').style.MozOpacity=0.73;
				document.getElementById('coversearch').style.zIndex = 10;
				document.getElementById('cat').style.visibility = 'hidden';
			}
		
}

var t = 1;

function tab(item)
{
	//chgange present section
	t = item;
}

/* Create a new XMLHttpRequest object to talk to the Web server */
		var xmlHttp = false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		try {
		  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
		    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e2) {
		    xmlHttp = false;
		  }
		}
		@end @*/
		
		if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
		  xmlHttp = new XMLHttpRequest();
		}

var prevTog = 1;

function highlight(item)
{
		
		
		
		document.getElementById('tog'+prevTog).style.backgroundColor='#CCEC9B';
		document.getElementById('tog'+prevTog).style.color='#549700';
		
		document.getElementById('tog'+item).style.backgroundColor='#84C225';
		document.getElementById('tog'+item).style.color='#FFF57D';
		
		prevTog = item;
}





img1 = new Image();
img1.src = httpHost + "images/compania-hover.gif";

img2 = new Image();
img2.src = httpHost + "images/contact-hover.gif";

img3 = new Image();
img3.src = httpHost + "images/stand-hover.gif";


img1 = new Image();
img1.src = httpHost + "images/compania-en-hover.gif";

img2 = new Image();
img2.src = httpHost + "images/contact-en-hover.gif";

img3 = new Image();
img3.src = httpHost + "images/stand-en-hover.gif";

var sub1 = 0;
var sub2 = 0;
var agt = navigator.userAgent.toLowerCase();
var currSub = "";
function setCurrSub(item) {
	currSub = item;
}

function switchImg(item, action,sub)
{
	if( action == "on") {
		document.getElementById(item).src = httpHost + "images/" + item + "-hover.gif";
		if(sub!='')
			submenu("on",sub);
		
	}
	
	if( action == "off" )
	{
		
		document.getElementById(item).src = httpHost + "images/" + item + ".gif";
		if(sub!='')
			submenu("off",sub);
			
	//	currSub = sub;
	}
}

function submenu(action,sub)
{
	
	if( action == "on")
	{
		
		if(currSub != "")
		document.getElementById("sub" + currSub).style.display = "none";
		document.getElementById("sub" + sub).style.display = "block";
		
		
	}
	
	if( action == "off")
	{
		
		document.getElementById("sub" + sub).style.display = "none";
		if(currSub != "")
		document.getElementById("sub" + currSub).style.display = "block";
		
	}
	
}

function opOn()
{
	document.getElementById('search').style.filter='alpha(opacity=100)';
	document.getElementById('search').style.MozOpacity=1;
	document.getElementById('search').style.opacity = 1;
}

function opOut()
{
	document.getElementById('search').style.filter='alpha(opacity=50)';
	document.getElementById('search').style.MozOpacity=0.5;
	document.getElementById('search').style.opacity = 0.5;
}

function focusFn(item)
{
	document.getElementById(item).style.background="#8ECCF0";
}

function blurFn(item)
{
	document.getElementById(item).style.background="#ECF7FD";
}

function showList(section)
{
	
	var pos = Position.cumulativeOffset($('prodinput'));
	$('prodList').style.top = pos[1] + 25 + 'px';
	$('prodList').style.left = pos[0] + 1 + 'px';
	//$('zoom').style.display = "none";
	$('prodList').style.zIndex = '1000';
	$('content2').style.zIndex = '999';
	$('content2').style.display = 'block';
	$('prodList').style.display = "block";
	
	updateUrl = httpHost + 'updateList.php?section='+section;
	
	
	
	new Ajax.Updater('prodList', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{ }
		});
		
	//new Effect.SlideDown( 'prodList', {duration:1});
	openProd = 1;
}

function showList2(section)
{
	
	var pos = Position.cumulativeOffset($('prodinput2'));
	$('prodList').style.top = pos[1] + 25 + 'px';
	$('prodList').style.left = pos[0] + 1 + 'px';
	//$('zoom').style.display = "none";
	$('prodList').style.zIndex = '1000';
	$('content2').style.zIndex = '999';
	$('content2').style.display = 'block';
	$('prodList').style.display = "block";
	
	updateUrl = httpHost + 'updateList.php?section='+section;
	
	
	
	new Ajax.Updater('prodList', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{ }
		});
		
	//new Effect.SlideDown( 'prodList', {duration:1});
	openProd = 1;
}


function whichElement(e)
{
var targ
if (!e) var e = window.event
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == 3) // defeat Safari bug
   targ = targ.parentNode
var tname
tname=targ.tagName
alert("You clicked on a " + tname + " element.")
}




var gsection = "";
var gitem = "";

function chooseItem(item,section)
{
	$('discount').innerHTML = '&nbsp;';
	$('desccont').innerHTML = '&nbsp;';
	//$('zoom').style.display="none";
	$('bigimgcont').innerHTML = '&nbsp;';
	//$('pinput').value = getName(item,section);
	getName(item,section);
	closeList();
	//$('zoom').style.display = "block";
	$('prodList').style.display = "none";
	gsection = section;
	gitem = item;
	viewProduct(item,section);
	openProd = 1;
	//$('zoom').style.display = "block";
}

function getName(item,section)
{
	updateUrl = httpHost + 'updateProduct.php?product='+item+'&action=getName&section='+section;
	//namePos = Position.cumulativeOffset($('prodinput'));
	new Ajax.Updater('fldValue', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{
			
		//	$('fldValue').style.display="block";
		//	$('fldValue').style.left= namePos[0] + 10 +"px";
		//	$('fldValue').style.top= namePos[1] + 6 +"px";
			 }
		});
}

function setName()
{
			namePos = Position.cumulativeOffset($('prodinput2'));
			$('fldValue').style.display="block";
			$('fldValue').style.left= namePos[0] + 10 +"px";
			$('fldValue').style.top= namePos[1] -2 +"px";
}

function viewProduct(item,section)
{
	updateUrl = httpHost + 'updateProduct.php?product='+item+'&action=getThumbs&section='+section;
	
	new Ajax.Updater('smallimgcont', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{
			
			viewPic(0,section,item);
			
			 }
		});
		
}

function viewDiscount(item,section)
{
	updateUrl = httpHost + 'updateProduct.php?action=getDiscount&product='+item+'&section='+section;
	
	new Ajax.Updater('discount', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{ 
			viewDescription(item,section);	
		}
		});
}

function viewDescription(item,section)
{
	updateUrl = httpHost + 'updateProduct.php?action=getDescription&product='+item+'&section='+section;
	
	new Ajax.Updater('desccont', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{ 
				
		}
		});
}

var currentPic = "";
var openProd = "";
var currHeight = "";

function viewPic_(id) {
	var item = id;
	var	updateUrl = httpHost + 'updateProduct.php?action=getImage&image=' + item;
	$('bigimgcont').innerHTML = '&nbsp;';
	$('bigimgcont').style.width = 323+"px";		
	new Effect.Opacity( 'bigimgcont', {duration:0.1, from:1, to:0});
	
	$('thumb'+item).style.background = "#FFE9C7";
	
	if($('thumb'+item).style.opacity != "0.4")
		new Effect.Opacity( 'thumb'+item, {duration:0.4, from:1, to:0.4});
	
	currentPic = item;
	//$('zoom').style.display="none";
	var pos = Position.cumulativeOffset($('bigimgcont'));
	$('loading').style.zIndex = "6";
	$('loading').style.top = pos[1] + 100 + 'px';
	$('loading').style.left = pos[0] + 111 + 'px';
	
	$('loading').style.display="block";
	
	new Ajax.Updater('bigimgcont', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{ 
					//$('bigimgcont').style.display="block";
					new Effect.Opacity( 'bigimgcont', {duration:1, from:0, to:1});
					//if(item == 1)
					
						viewDiscount(prod,section);
			
		}
		});
}

function viewPic(item,section,prod)
{
	
	updateUrl = httpHost + 'updateProduct.php?action=getImage&section='+section+'&product='+prod+'&image=' + item;
	$('bigimgcont').innerHTML = '&nbsp;';
	$('bigimgcont').style.width = 323+"px";		
	new Effect.Opacity( 'bigimgcont', {duration:0.1, from:1, to:0});
	
	$('thumb'+item).style.background = "#FFE9C7";
	
	if($('thumb'+item).style.opacity != "0.4")
		new Effect.Opacity( 'thumb'+item, {duration:0.4, from:1, to:0.4});
	
	currentPic = item;
	//$('zoom').style.display="none";
	var pos = Position.cumulativeOffset($('bigimgcont'));
	$('loading').style.zIndex = "6";
	$('loading').style.top = pos[1] + 100 + 'px';
	$('loading').style.left = pos[0] + 111 + 'px';
	
	$('loading').style.display="block";
	
	new Ajax.Updater('bigimgcont', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{ 
					//$('bigimgcont').style.display="block";
					new Effect.Opacity( 'bigimgcont', {duration:1, from:0, to:1});
					//if(item == 1)
					
						viewDiscount(prod,section);
			
		}
		});
	
}

function showZoom()
{
	var pos = Position.cumulativeOffset($('bigimgcont'));
	//$('zoom').style.top = pos[1] + 0 + 'px';
	//$('zoom').style.left = pos[0] + 50 + 'px';
	//$('zoom').style.display="block";
}

function opac(act)
{
	if(act == 0)
	{
		//new Effect.Opacity( 'zoom', {duration:0.3, from:1, to:0.7});
	}
	
	if(act == 1)
	{
		//new Effect.Opacity( 'zoom', {duration:0.3, from:0.7, to:1});
	}
}

function opac2(act)
{
	if(act == 0)
	{
		//new Effect.Opacity( 'close', {duration:0.3, from:1, to:0.7});
	}
	
	if(act == 1)
	{
		//new Effect.Opacity( 'close', {duration:0.3, from:0.7, to:1});
	}
}

function close()
{
	//$('close').style.display = "none";
	new Effect.Opacity( 'bigImage', {duration:0.4, from:1, to:0,
		afterFinish:function()
		{
				$('bigImage').innerHTML = "&nbsp;";
				$('bigImage').style.display = "none";
				
				//$('zoom').style.display="block";
					
		}
		});

}

function zoom(id)
{
	
	
	
	//$('bigimgcont').innerHTML = '&nbsp;';
	new Effect.Opacity( 'bigImage', {duration:0.1, from:1, to:0});
	updateUrl = httpHost + 'updateProduct.php?action=getBigImage&image=' + id;
	var pos = Position.cumulativeOffset($('bigimgcont'));
	
	//$('zoom').style.display="none";
	$('bigImage').style.top = pos[1] +  'px';
	$('bigImage').style.left = pos[0] +  'px';
	
	$('loading').style.zIndex = "10";
	$('loading').style.top = pos[1] + 100 + 'px';
	$('loading').style.left = pos[0] + 111 + 'px';
	
	$('loading').style.display="block";
	
	new Ajax.Updater('bigImage', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function()
		{ 
					new Effect.Opacity( 'bigImage', {duration:0.7, from:0, to:1});
		}
		});
		
	
}


function showClose()
{
	var h = Element.getHeight('bigImage');
		
		var w = $('bigImage').offsetWidth;
		var pos2 = Position.cumulativeOffset($('bigImage'));
		
		//$('close').style.left = pos2[0] + (w/2 - 100) + 'px';
		//$('close').style.top = pos2[1] + (h - 48) + 'px';
		//alert($('close').style.top + "-" + $('close').style.left);
		//$('close').style.display="block";
}

function sendNewsletter(name, email) {
	
	$('letterResponse').style.display="block";
	updateUrl = httpHost + "newsLetterControl.php?name="+name+"&email="+email;
	new Ajax.Updater('letterResponse', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function() { 
					
		}
		});
	new Effect.Opacity( 'letterResponse', {duration:0.7, from:0, to:1});
}

function sendEmail2Friend(lang, link) {
	updateUrl = httpHost + "email2friend.php?link="+escape(link)+"&email="+escape($("email2friendEmail").value)+"&lang="+lang + "&nume=" + escape($("numeemail").value);
	new Ajax.Updater('sendFriendMsg', updateUrl, {
		asynchronous:true,
		evalScripts:true,
		method:'get',
		onComplete:function() { 

		}
		});
}

function initBanners() {
	if(document.getElementById('banner_content'))	
		document.getElementById('banner_content').innerHTML = AC_FL_RunContent(
					'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
					'width', '468',
					'height', '60',
					'src', httpHost + '/images/banner2nou21.swf',
					'quality', 'high',
					'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
					'align', 'middle',
					'play', 'true',
					'loop', 'true',
					'scale', 'showall',
					'wmode', 'window',
					'devicefont', 'false',
					'id', 'cmr_flash',
					'bgcolor', '#ffffff',
					'name', 'banner2nou21',
					'menu', 'true',
					'allowFullScreen', 'false',
					'allowScriptAccess','sameDomain',
					'movie', httpHost + '/images/banner2nou21',
					'salign', ''
					); //end AC code
	
	if(document.getElementById('right_banner'))	
		document.getElementById('right_banner').innerHTML = AC_FL_RunContent(
					'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
					'width', '181',
					'height', '240',
					'src', httpHost + '/images/banner1nou3.swf',
					'quality', 'high',
					'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
					'align', 'middle',
					'play', 'true',
					'loop', 'true',
					'scale', 'showall',
					'wmode', 'window',
					'devicefont', 'false',
					'id', 'cmr_flash',
					'bgcolor', '#ffffff',
					'name', 'banner2nou21',
					'menu', 'true',
					'allowFullScreen', 'false',
					'allowScriptAccess','sameDomain',
					'movie', httpHost + '/images/banner1nou3',
					'salign', ''
					); //end AC code				
}
