function change_prod(bg,price,oldprice,name,pozymis)
{
	if (!document.getElementById('big_image'))
	{
		document.getElementById('image_flash').innerHTML = 	'<div id="big_image"><img src="templates/img/s.gif" width="375" height="388" alt=""><div id="price" class="price"></div><div id="old_price" class="old_price"></div><div id="prod_name" class="prod_name"></div></div>';
	}
	/*if (oldprice)
	{
		document.getElementById('price').innerHTML = '<div class="new_price">'+price+' Lt</div>';
		document.getElementById('old_price').innerHTML = oldprice+' Lt<img src="templates/img/red_line.gif" style="position:absolute; right:0; bottom:-5px;" width="50" alt="">';		
	}
	else
	{
		document.getElementById('price').innerHTML = price+' Lt';
		document.getElementById('old_price').innerHTML = '';		
	}*/
	if (pozymis==1)
	{
		document.getElementById('pozymis').innerHTML = '<img src="templates/img/top.gif" alt="">';
	}
	if (pozymis==2)
	{
		document.getElementById('pozymis').innerHTML = '<img src="templates/img/akcija.gif" alt="">';
	}
	if (pozymis==3)
	{
		document.getElementById('pozymis').innerHTML = '<img src="templates/img/ispardavimas.gif" alt="">';
	}
	if (!pozymis)
	{
		document.getElementById('pozymis').innerHTML = '';
	}
	document.getElementById('big_image').style.backgroundImage = bg;
	document.getElementById('prod_name').innerHTML = name;
}
function loading(type)
{
	if (type=='show')
	{
		win_height = parseInt(document.body.clientHeight);
		win_width = parseInt(document.body.clientWidth);

		_left = win_width / 2 - 518 / 2;
		_top = win_height / 2 - 222 / 2;

		document.getElementById('loading_page').innerHTML = '<img src="system/lightbox/images/loading.gif" alt="" />&nbsp;Loading ...';
		document.getElementById('loading_page').style.top = _top+'px';
		document.getElementById('loading_page').style.left = _left+'px';
	}
	else if (type=='hide')
	{
		document.getElementById('loading_page').innerHTML = '';
		document.getElementById('loading_page').style.top = '-1000px';
		document.getElementById('loading_page').style.left = '-1000px';
	}
}
function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null

	if (window.ActiveXObject)
	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
		strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
		objXmlHttp=new ActiveXObject(strName)
		objXmlHttp.onreadystatechange=handler 
		return objXmlHttp
		} 
		catch(e)
		{ 
		alert("Klaida. Naršymas su ActiveX yra išjunktas") 
		return 
		} 
	} 
	if (window.XMLHttpRequest)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}
function get_page(pageid,rightblock,pap_url)
{
	var url_1 = "http://elegantline.lt/";
	var url_2 = "http://www.elegantline.lt/";
	if ( url_1 == location.href.substring(0,url_1.length))
	{
		url = url_1;	
	}
	if ( url_2 == location.href.substring(0,url_2.length))
	{
		url = url_2;	
	}
	var reloadblock = true;
	loading('show')
	if (rightblock==2 && document.getElementById('flashcontent')) reloadblock = false
	if (rightblock==3 && document.getElementById('big_image')) reloadblock = false
	if (reloadblock)
	{
		xmlHttp2=GetXmlHttpObject(change_block)
		if (pageid) xmlHttp2.open("GET", url+"index.php?id="+pageid+"&ajax="+rightblock , true)
		else xmlHttp2.open("GET", url+"index.php?ajax="+rightblock , true)
		xmlHttp2.send(null)
	}
	xmlHttp=GetXmlHttpObject(change_content)
	xmlHttp3=GetXmlHttpObject(change_title)
	if (pageid)
	{
		if (pap_url=='undefined') pap_url='';
		xmlHttp3.open("GET", url+"index.php?id="+pageid+pap_url+"&ajax=4" , true)
		xmlHttp.open("GET", url+"index.php?id="+pageid+pap_url+"&ajax=1" , true)
	}
	else
	{
		xmlHttp3.open("GET", url+"index.php?ajax=4" , true)
		xmlHttp.open("GET", url+"index.php?ajax=1" , true)
	}
	xmlHttp3.send(null)
	xmlHttp.send(null)
}
function change_content()
{
	if ( xmlHttp.readyState == 4 ) {
		document.getElementById('content').innerHTML = xmlHttp.responseText;
		loading('hide')
	}
}
function change_title()
{
	if ( xmlHttp3.readyState == 4 ) {
		document.title = xmlHttp3.responseText;
	}
}
function change_block()
{
	if ( xmlHttp2.readyState == 4 ) {
		document.getElementById('image_flash').innerHTML = xmlHttp2.responseText;
	}
}

function underline(id)
{
		document.getElementById(id).style.textDecoration = 'underline'
}
function normal(id)
{
		document.getElementById(id).style.textDecoration = 'none'
}

var http_request = false;
function makePOSTRequest(url, parameters)
{
	xmlHttp = false;
	if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
		xmlHttp = new XMLHttpRequest();
		if (xmlHttp.overrideMimeType)
		{
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            xmlHttp.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject)
	{ // IE
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
	}
	if (!xmlHttp)
	{
		alert('Cannot create XMLHTTP instance');
		return false;
	}
      
	xmlHttp.onreadystatechange = change_content;
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
   }

function get(obj,sk,id)
{
	var poststr = "";
	var endas = "";
	var array;
	for (i=0; i<document.forms[obj].elements.length; i++)
	{
		if(document.forms[obj].elements[i].type!='checkbox' && document.forms[obj].elements[i].type!='radio' && document.forms[obj].elements[i].type!='select')
		{
			poststr = poststr + endas + document.forms[obj].elements[i].name + "=" + encodeURI( document.forms[obj].elements[i].value )
		}
		else if(document.forms[obj].elements[i].checked  == true)
		{
			poststr = poststr + endas + document.forms[obj].elements[i].name + "=" + encodeURI( document.forms[obj].elements[i].value )
		}
		endas = "&";
	}
	//alert(poststr);
	loading('show');
	makePOSTRequest('index.php?id='+id+'&ajax=1', poststr);
}


 var img = new Array(13); //array to hold the images

 var start = null; //start pointer

 var counter = 1; //counts the image sequences

 var delayTime = 5000; //user defined

 for(i = 1; i <= 12; i++)
 {
	img[i] = new Image();
	img[i].src = "images/imagai2_" + i + ".jpg";
 }
 
 //function for getting the user defined delay time

 function getDelayTime(dlTime)
 {
   var temp = parseInt(dlTime);
   if(temp != NaN)
    delayTime = temp * 1000;
   else
    delayTime = 4000;
 }

 //function for changing the images

 function anim()
 {
	if (document.getElementById('image00'))
	{
		counter++;
		document.getElementById('image00').src = img[counter].src;
		if(counter == 12)
		counter = 0; //sets the counter value to 0
	}
 }

 //function for starting the slide show

 function slide()
 {
	if (!document.form1) stopSlide()
	else
	   with(document.form1)
	   {
		 start = setInterval("anim()", delayTime);
	   }
 }

 //function to stop the slide show

 function stopSlide()
 {
   clearInterval(start);
 }


function code_start()
{
	loading("show");
	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape")
		{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}
	
	winW_1=document.getElementById('root_table').offsetWidth;
	winH_1=document.getElementById('root_table').offsetHeight;
	
	document.getElementById('bg').style.width=(winW_1-2)+"px";
	document.getElementById('bg').style.height=(winH_1-2)+"px";

	document.getElementById('bg').style.left="0px";
	document.getElementById('bg').style.top="0px";
	if (winW<1000)
	{
		document.getElementById('code').style.width = "1100px";
	}
	
	document.getElementById('playlist').style.visibility="hidden";
	
	//document.getElementById('bg').style.zIndex = "-100";
	
	opacityTween = new OpacityTween(document.getElementById('bg'),Tween.bounceEaseOut, 0, 100, 3);
	code_page = new Tween(document.getElementById('code').style,'top',Tween.regularEaseOut,-620,0,4,'px');
	opacityTween.onMotionFinished = function(){code_page.start();};
	code_page.onMotionFinished = function(){loading("hide");};
	opacityTween.start();
	
}


