﻿	var indexArray=new Array();
	var imagesArray=new Array();
	var contentArray=new Array();
	var clickBox=-1;
	window.onscroll = function () {
                if(document.getElementById("idchuck")){//alert(document.documentElement.scrollTop+"--*");
					document.getElementById("idchuck").style.top = document.documentElement.scrollTop+167+'px';
				}
				if(document.getElementById("idphial")){//alert(document.documentElement.scrollTop+"--*");
					document.getElementById("idphial").style.top = document.documentElement.scrollTop+167+'px';
				}
            }
	function alertSize() {
		  var myWidth = 0;//, myHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			//myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {//|| document.documentElement.clientHeight 
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			//myHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth) ) {// || document.body.clientHeight 
			//IE 4 compatible
			myWidth = document.body.clientWidth;
		   // myHeight = document.body.clientHeight;
		  }
		  //window.alert( 'Width = ' + myWidth );
		  //window.alert( 'Height = ' + myHeight );
		  //alert(document.getElementById('tdmiddle').offsetWidth+'-jjjj---'+document.getElementById('idtd').offsetWidth);
		  
		  return myWidth-getScrollerWidth();
	}
	function alertSizeHight() {
		  var  myHeight = 0;
		  if( typeof( window.innerHeight ) == 'number' ) {
			//Non-IE
			//myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {//|| document.documentElement.clientHeight 
			//IE 6+ in 'standards compliant mode'
			//myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientHeight) ) {// || document.body.clientHeight 
			//IE 4 compatible
			//myWidth = document.body.clientWidth;
		    myHeight = document.body.clientHeight;
		  }
		  //window.alert( 'Width = ' + myWidth );
		  //window.alert( 'Height = ' + myHeight );
		  //alert(document.getElementById('tdmiddle').offsetWidth+'-jjjj---'+document.getElementById('idtd').offsetWidth);
		  
		  return myHeight;
	}
	
	//alert(wth+'-----------+++');
	
	var bourne="";
	 function getScrollerWidth() {

          var scr = null;

          var inn = null;

          var wNoScroll = 0;

          var wScroll = 0;

          // Outer scrolling div

          scr = document.createElement('div');

          scr.style.position = 'absolute';

          scr.style.top = '-1000px';

          scr.style.left = '-1000px';
 
          scr.style.width = '100px';

          scr.style.height = '50px';

          // Start with no scrollbar

          scr.style.overflow = 'hidden';

          // Inner content div

          inn = document.createElement('div');

          inn.style.width = '100%';

          inn.style.height = '200px';

          // Put the inner div in the scrolling div

          scr.appendChild(inn);

          // Append the scrolling div to the doc

          document.body.appendChild(scr);

          // Width of the inner div sans scrollbar

          wNoScroll = inn.offsetWidth;

          // Add the scrollbar

          scr.style.overflow = 'auto';

          // Width of the inner div width scrollbar

          wScroll = inn.offsetWidth;

          // Remove the scrolling div from the doc

          document.body.removeChild(

     document.body.lastChild);

          // Pixel width of the scroller
     return (wNoScroll - wScroll);
}
	var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
var timer=null;
function changeColor(id,className){
//alert('---'+id+'****'+className+'+++'+document.getElementById(id));
	if(document.getElementById(id))document.getElementById(id).className=className;
}
function setText(id,text){
	if(document.getElementById(id))document.getElementById(id).innerHTML=text;
}
function setRedMapPos(){
	
	var lfRed=document.getElementById("blackMap").offsetLeft;
	var tpRed=document.getElementById("blackMap").offsetTop;
	
	
	document.getElementById('idRedMap').style.left=lfRed+85+"px";
	document.getElementById('idRedMap').style.top=tpRed+98+"px";
	//alert(lfRed+'---'+tpRed);
}
function showBallon(idpos,idshow,classPut,left,top){

	var lfRed=document.getElementById(idpos).offsetLeft;
	var tpRed=document.getElementById(idpos).offsetTop;
	document.getElementById(idshow).style.left=lfRed+document.getElementById('idtable').offsetLeft-left+"px";
	document.getElementById(idshow).style.top=tpRed+top+"px";
	
	document.getElementById(idshow).className=classPut;
	
	
}
function desplayObject(id,classname){
	document.getElementById(id).style.display=classname;//alert(document.getElementById(id).style.display+'**'+id);
	
}
function animateSmallHeight(id,idHide){
	
	//var ps=returnPosition('idHeader','idphial',0,0);
	//setPosition1('idHeader',id,730,130);
	var  wth=alertSize();
	var idphialPos=wth-639;
	idphialPos=idphialPos/2;
	
	var tmp1=(idphialPos+639)+'px';
	//var tmp=document.getElementById(id).offsetLeft-639;
	//if(document.getElementById(id))document.getElementById(id).style.left=tmp+"px";
	$("#"+id).animate({ width: "0px",height: "0px",left: tmp1}, 300 );
	document.getElementById(id).style.display="none";
	document.getElementById(idHide).style.display="none";
	

	
}
function animateHeight(id,idshow){
	var oo=document.getElementById('idphial').style.width+'';
	
	var  wth=alertSize();
	var idphialPos=wth-639;
	idphialPos=idphialPos/2;
	if((oo=='')||(oo=='0px')){
		
//alert(document.getElementById(id)+"--"+id+document.getElementById(idshow)+"---***"+idshow);
		//var ps=returnPosition('idHeader','idphial',0,0);
		if(document.getElementById(id))document.getElementById(id).style.display="block";
		if(document.getElementById(idshow))document.getElementById(idshow).style.display="block";
		//setPosition1('idHeader',id,730,130);
		
		document.getElementById(id).style.left=(idphialPos+639)+'px';
		var tmp=idphialPos;
		$("#"+id).animate({ width: "639px",height: "366px",left: tmp+"px"}, 300 );
	}
	
}


function animateSmallHeightTop(id,idHide){
	
	//var ps=returnPosition('idHeader','idphial',0,0);
	//setPosition1('idHeader',id,730,130);
	
	var  wth=alertSize();
	var idphialPos=wth/2;
	
	var hth=alertSizeHight();
	//var tmp1=(idphialPos+639)+'px';
	//var tmp=document.getElementById(id).offsetLeft-639;
	//if(document.getElementById(id))document.getElementById(id).style.left=tmp+"px";
	$("#"+id).animate({ width: "0px",height: "0px",left: idphialPos+'px',top:hth+'px'}, 300 );
	document.getElementById(id).style.display="none";
	document.getElementById(idHide).style.display="none";
	

	
}
function animateHeightTop(id,idshow){
	var oo=document.getElementById('idphial').style.width+'';
	if(document.getElementById(id))document.getElementById(id).style.top='0px';
	
	var  wth=alertSize();
	var idphialPos=wth/2;

	if((oo=='')||(oo=='0px')){
		
//alert(document.getElementById(id)+"--"+id+document.getElementById(idshow)+"---***"+idshow);
		//var ps=returnPosition('idHeader','idphial',0,0);
		if(document.getElementById(id))document.getElementById(id).style.display="block";
		if(document.getElementById(idshow))document.getElementById(idshow).style.display="block";
		//setPosition1('idHeader',id,730,130);
		
		document.getElementById(id).style.left=idphialPos+'px';
		//var tmp=idphialPos;
		$("#"+id).animate({ width: "639px",height: "366px",top: "130px",left: (idphialPos-320)+'px'}, 300 );
	}
	
}

function animateHeightRight(id,idshow,hgt){
//alert(id+','+idshow+'--'+document.getElementById(id)+'--'+document.getElementById(idshow));
//alert(document.getElementById(id)+"--"+id+document.getElementById(idshow)+"---***"+idshow);
	var ps=returnPosition('idHeader','idchuck',120,150);
	if(document.getElementById(id))document.getElementById(id).style.display="block";
	if(document.getElementById(idshow))document.getElementById(idshow).style.display="block";
	setPosition1('idHeader',id,120,150);
	//var tmp=document.getElementById(id).offsetLeft;
	//,left: tmp+"px"
	if(document.getElementById(id)){
		$("#"+id).animate({ width: "637px",height: hgt+"px"}, 300 );
	}
	
	
}
function animateSmallHeightright(id,idHide){
	var ps=returnPosition('idHeader','idphial',0,0);
	setPosition1('idHeader',id,120,150);
//	var tmp1=document.getElementById(id).offsetLeft;
	//var tmp=document.getElementById(id).offsetLeft-639;
	//document.getElementById(id).style.left=tmp+"px";
	$("#"+id).animate({ width: "0px",height: "0px"}, 300 );
	if(document.getElementById(id))document.getElementById(id).style.display="none";
	if(document.getElementById(idHide))document.getElementById(idHide).style.display="none";
	

	
}

function animateHeightRightTop(id,idshow,hgt){
	
	var oo='0px';
	if(document.getElementById('idchuck'))oo=document.getElementById('idchuck').style.width+'';
	if((oo=='')||(oo=='0px')){
		
		
		
		var  wth=alertSize();
		var idphialPos=wth/2;
	//$("#"+id).animate({top: document.documentElement.scrollTop+"px",left: idphialPos+'px'}, 1 );
	
		
//alert(document.getElementById(id)+"--"+id+document.getElementById(idshow)+"---***"+idshow);
		//var ps=returnPosition('idHeader','idphial',0,0);
		if(document.getElementById(id))document.getElementById(id).style.display="block";
		if(document.getElementById(idshow))document.getElementById(idshow).style.display="block";
		if(document.getElementById(id))document.getElementById(id).style.top=document.documentElement.scrollTop+'px';
		//setPosition1('idHeader',id,730,130);
		
		if(document.getElementById(id)){
			document.getElementById(id).style.left=idphialPos+'px';
			//var tmp=idphialPos;
			$("#"+id).animate({ width: "639px",height: "366px",top: document.documentElement.scrollTop+130+"px",left: (idphialPos-320)+'px'}, 300 );
		}
	}
	
	
}
function animateSmallHeightrightTop(id,idHide){
	
//var ps=returnPosition('idHeader','idphial',0,0);
	//setPosition1('idHeader',id,730,130);
	
	var  wth=alertSize();
	var idphialPos=wth/2;
	
	var hth=alertSizeHight()+document.documentElement.scrollTop;
	//var tmp1=(idphialPos+639)+'px';
	//var tmp=document.getElementById(id).offsetLeft-639;
	//if(document.getElementById(id))document.getElementById(id).style.left=tmp+"px";
	$("#"+id).animate({ width: "0px",height: "0px",left: idphialPos+'px',top:hth+'px'}, 300 );
	document.getElementById(id).style.display="none";
	document.getElementById(idHide).style.display="none";
	
}
function animateOpacity(id,idHide){
	if(document.getElementById(idHide))document.getElementById(idHide).style.display="none";
				
	if(document.getElementById(id))document.getElementById(id).style.display="block";
	if(BrowserDetect.browser=="Explorer"&&BrowserDetect.version=="6"){
		document.getElementById(id).style.filter="alpha(opacity="+(0.1*100)+")";
	}else{
		 document.getElementById(id).style.MozOpacity=0.1;
	}
	$("#"+id).animate({opacity: 1},1000); 
}
function setPosition1(id,idshow,left,top){
	if(document.getElementById(id)){
	
		var lfRed=document.getElementById(id).offsetLeft;
		var tpRed=document.getElementById(id).offsetTop;
		//alert(lfRed+'--'+tpRed+'**');
	}
	//alert(document.getElementById('tdmiddle').offsetWidth+'fffffff'+'---L'+lfRed+'---t'+tpRed);
	 
	if(document.getElementById(idshow))document.getElementById(idshow).style.left=lfRed+left+"px";
	//if(BrowserDetect.browser=="Explorer")
	if(document.getElementById(idshow))document.getElementById(idshow).style.top=tpRed+top+"px";
	//alert(document.getElementById(id).offsetLeft+'**'+id);
	//alert(document.getElementById(idshow).style.left+'--'+idshow);
	//if(idshow=='idCopyright')alert((tpRed+top)+"px");
}

function setPosition2(id,idshow,left,top,g){
	if(document.getElementById(id)){
		var lfRed=document.getElementById(id).offsetLeft;
		var tpRed=document.getElementById(id).offsetTop;
	}
	//alert(lfRed+'--');
	var l=lfRed+left;
	var t=tpRed+top;
	//alert(document.getElementById('tdmiddle').offsetWidth+'fffffff'+'---L'+lfRed+'---t'+tpRed);
	for(var i=0;i<g;i++){
		if(document.getElementById(idshow+i)){	
			document.getElementById(idshow+i).style.left=l+"px";
			document.getElementById(idshow+i).style.top=t+"px";
		}
		//alert('=='+document.getElementById(idshow+i).style.left);
	}
	//alert(document.getElementById(id).offsetLeft+'**'+id);
	//alert(document.getElementById(idshow).style.left+'--'+idshow);
}


function returnPosition(id,idshow,left,top){
	var lfRed=document.getElementById(id).offsetLeft;
	var tpRed=document.getElementById(id).offsetTop;
	//alert(document.getElementById('tdmiddle').offsetWidth+'fffffff'+'---L'+lfRed+'---t'+tpRed);
	
	var returnLeft=lfRed+left;
	var returnTop=tpRed+top;
	
	return [returnLeft,returnTop];
}


var ii=-1;
function opacityEvents(id){
		
		if(timer==null){
			if(ii==-1)animateOp(id);
			timer=window.setInterval("animateOp('"+id+"');",5000);
			
		}
}
function changeBackground(id,color){

	if(document.getElementById(id))document.getElementById(id).style.background = color; 
}
function fadeBackground(id,id1,url){
	if(document.getElementById(id)){
		var show1=id;
		var hide1=id1;
		if(document.getElementById(id).offsetWidth>0){
			show1=id1;
		    hide1=id;
		}
		$("#"+hide1).fadeOut(2000); 
		$("#"+show1).css({ 'background-image': 'url('+url+')' },$("#"+show1).fadeIn(1000));
	}
}
function stop(){
	window.clearInterval(timer);
	timer=null;
	//alert('---**');
	
}

function animateOpId(id,i){
	if(i==ii) return;
	stop();
	
	if(ii==indexArray.length)ii=0;
	fadeBackground('idbg','idbg1',imagesArray[i]);
	
	//var gudgeon=indexArray[ii].replace("15/", "36/");
	//document.getElementById('cupboardHref').href=contentArray[ii];
	
	document.getElementById('circle'+i+i).className="fantasize circle1 fl";
	document.getElementById('circle'+ii+ii).className="fantasize fl";
	//$('#'+id+((i==0)?'2':(i-1))).fadeOut("slow"); 
	$("#"+id+ii).fadeOut("slow"); 
	$("#"+id+i).fadeIn("slow"); 
	
	//document.getElementById('debug').innerHTML+=i+'***'+ii+'<br>';

	ii=i;
	
	window.clearInterval(timer);
	timer=1;
	//alert('----');
}
function animateOp(id){
	ii++;
	var ln=indexArray.length;
	if(ii==ln)ii=0;
        
		var id1=id+ii;
		var idHide1=(ii==0)?id+(ln-1):id+(ii-1);
		
		fadeBackground('idbg','idbg1',imagesArray[ii]);
		
		//var gudgeon=indexArray[ii].replace("15/", "36/");
		//if(document.getElementById('cupboardHref'))document.getElementById('cupboardHref').href=contentArray[ii];
	
			
		//alert(document.getElementById('cupboard').href+'--'+indexArray[ii]);
		//if(document.getElementById(idHide1))document.getElementById(idHide1).style.display="none";
		if(document.getElementById('circle'+ii+ii))document.getElementById('circle'+ii+ii).className="fantasize circle1 fl";
		if(document.getElementById('circle'+((ii==0)?(ln-1):(ii-1))+((ii==0)?(ln-1):(ii-1))))document.getElementById('circle'+((ii==0)?(ln-1):(ii-1))+((ii==0)?(ln-1):(ii-1))).className="fantasize fl";
		
		//alert(id1+"----*-"+idHide1+'---('+document.getElementById(id1).style.display+'---'+document.getElementById(idHide1).style.display+')'); 
		
		
		/*if(BrowserDetect.browser=="Explorer"&&BrowserDetect.version=="6"){
			if(document.getElementById(id1))document.getElementById(id1).style.filter="alpha(opacity="+(0.1*100)+")";
		}else{
			 if(document.getElementById(id1))document.getElementById(id1).style.MozOpacity=0.1;
		}
		*/
		$("#"+idHide1).fadeOut("slow"); 
		$("#"+id1).fadeIn("slow"); 
		
		//stop();
	
	
		//alert(ii+'-*** begin--');
		
	
}


function onloadIndex(){
//alert('---');
setAmplify('idamplify');
	setPosition1('idHeader','idphial',140,130);
	//desplayObject('buffet0','block');
	setPosition1('idHeader','idchuck',120,150);
	setPosition2('idHeader','buffet',294,50,6);
	setPosition1('idlastTd','idCopyright',708,-149);
	opacityEvents('buffet');
	centerDiv1('idbg','idbg1');
	
	if(document.getElementById('idCopyright'))document.getElementById('idCopyright').style.display="block";
	//fadeBackground('idTdHeader','/uploads/news/id3/header4.jpg');
	//timer=window.setInterval("animateOp('"+id+"');",90);
	//alert(BrowserDetect.version+'----');
	
}
function setAmplify(id){
	var ht=alertSizeHight();
	var rr;
	if(BrowserDetect.browser=="Explorer")
		rr=ht-105-120-49-50;
	else
		rr=ht-105-120-49-10;
	//alert(ht+'--'+rr+"--");
	if(document.getElementById(id))document.getElementById(id).style.height=rr+'px';
}
function onloadMain(){

}

function centerDiv1(idShow,idShow1){
	var  wth=alertSize();//document.getElementById(idShow).offsetWidth=1393
	var width1=(wth-1393)/2;
	
	if(document.getElementById(idShow))document.getElementById(idShow).style.left=width1+'px';
	if(document.getElementById(idShow1))document.getElementById(idShow1).style.left=width1+'px';
	//alert(document.getElementById(idShow).offsetWidth+'--*'+wth+'--**'+document.getElementById(idShow).style.left);
}
function centerDiv(id,idShow){
	var width1=(document.getElementById(id).offsetWidth-document.getElementById(idShow).offsetWidth)/2;
	document.getElementById(idShow).style.left=width1+'px';
	
}
function doSomething(e) {
			var posx = 0;
			var posy = 0;
			if (!e) var e = window.event;
			if (e.pageX || e.pageY) 	{
				posx = e.pageX;
				posy = e.pageY;
			}
			else if (e.clientX || e.clientY) 	{
				posx = e.clientX + document.body.scrollLeft
					+ document.documentElement.scrollLeft;
				posy = e.clientY + document.body.scrollTop
					+ document.documentElement.scrollTop;
			}
			// posx and posy contain the mouse position relative to the document
			// Do something with this information
			
			return [posx,posy];
			//alert(myPos[0]+'--'+myPos[2]);
			
}
function showGlobule(lfRed,tpRed,idshow,classPut){

	document.getElementById(idshow).style.left=lfRed+"px";
	document.getElementById(idshow).style.top=tpRed-80+"px";
	//alert(lfRed+'-----'+classPut);
	document.getElementById(idshow).className=classPut;
	
}
function getIndexes(count){
	posB=document.getElementById('idtable').offsetLeft+document.getElementById('idImg').offsetLeft+110;
	posE=document.getElementById('idtable').offsetLeft+document.getElementById('idImg').offsetLeft+577;
	var delim=posE-posB;
	//alert(posE+'--'+posB+'--'+delim+'--'+count);
	count--;
	var pixels=delim/count;
	return pixels;
}
function getData(posMouse){
	posMouse=posMouse-posB;//CIA YRA posB ji reikia padaryt globaliu
	var dataIndex=posMouse/pix;
	var tt=Math.round(dataIndex);
	if(tt>=cnt) tt-=1;
	
	
	document.getElementById('idFir').innerHTML='<b>'+tm[tt]+'</b>';
}
function getBalloonColor(posMouse){

	posMouse=parseInt(posMouse)-parseInt(posB);//CIA YRA posB ji reikia padaryt globaliu
	
	var colorIndex=posMouse/parseInt(pxls);
	//alert(posB+'posb'+posMouse+" - "+colorIndex+" - "+pxls);
	//alert(colors[Math.round(colorIndex)]+'------'+Math.round(colorIndex)+'--'+colorIndex);
	return colors[Math.round(colorIndex)];
}
function setLastBalloon(idpad,idshow,idLetter,classPut,classPut2,txt,idtxtBlue,idtxtLetter,left1,top1){
	
	var t=txt.charAt(0);
	
	document.getElementById(idshow).className=classPut;
	document.getElementById(idLetter).className=classPut2;
	document.getElementById(idpad).style.left=posE-left1+"px";
	document.getElementById(idpad).style.top=top1+"px";
	
	t=t.toUpperCase();
	document.getElementById(idtxtBlue).innerHTML='<table border="0" cellspacing="0" height="63" width="250" cellpadding="0"><tr><td valign="middle" align="center" class="bluedv">Paskutinis ( -ė) papasakojęs ( -usi ) draugui  apie eglę</td></tr><tr><td valign="top" align="center" class="bluedv"><b>'+txt+'</b></td></tr></table>';

	document.getElementById(idtxtLetter).innerHTML=t;	
	
	

}
function formsubmit(id,formname){
	if((document.getElementById(id).value!='')&&(document.getElementById(id).value!='Draugo (-ės) el.p')){
	//alert(document.getElementById(id).value+'-------');
		verifyEmail(document.getElementById(id).value,formname);
	
		//formname.submit();
		
		
	}else{
		//alert('Uzpildykit laukus!!');
		document.getElementById('successfully').className='successfull';
		document.getElementById('execute').className='imgOpicity';
		
	}
}

function formTellsubmit(yourName,email,friendEmail){
	var pz=0;
	if((document.getElementById(yourName).value=='')||(document.getElementById(yourName).value=='Tavo vardas')){
		pz=1;
		document.getElementById('div_first').className='inputGreen';
		
	//call ,document.formname
		//formname.submit();
	}
	if((document.getElementById(email).value=='')||(document.getElementById(email).value=='Tavo el. paštas')){
		pz=1;
		document.getElementById('div_second').className='inputGreen';
		
	}
	
	if((document.getElementById(friendEmail).value=='')||(document.getElementById(friendEmail).value=='Draugo (-ės) el.p')){
		pz=1;
		document.getElementById('div_fird').className='inputGreen';
		
	}
	
	if(pz==0){
		verify2Email(document.getElementById(yourName).value,document.getElementById(email).value,document.getElementById(friendEmail).value);
	}else{
	
		//alert('Uzpildykite laukus!!');
		
		document.getElementById('successfully').className='successfull';
		document.getElementById('execute').className='imgOpicity';
			
			
	}
}
function verify2Email(yourname,email,friendEmail) {
	//checkEmail = form.email.value
	var pz=0;
	
	if ((email.indexOf('@') < 0) || ((email.charAt(email.length-4) != '.') && (email.charAt(email.length-3) != '.')))
	{
		
		document.getElementById('div_second').className='inputGreen';
		
		pz=1;
		
	}
	if((friendEmail.indexOf('@') < 0) || ((friendEmail.charAt(friendEmail.length-4) != '.') && (friendEmail.charAt(friendEmail.length-3) != '.'))){
		
		pz=1;
		document.getElementById('div_fird').className='inputGreen';
		
	
	}
	if(pz==0) {
		ajaxFunction(yourname,email,friendEmail);
		
	}else{
		//alert("Elektroninio pasto adresas ivestas neteisingai!!!");
		document.getElementById('successfully').className='successfull';
		document.getElementById('execute').className='imgOpicity';
	}

}



function verifyEmail(email,formname) {
	//checkEmail = form.email.value
	if ((email.indexOf('@') < 0) || ((email.charAt(email.length-4) != '.') && (email.charAt(email.length-3) != '.')))
	{
		//alert("Elektroninio pasto adresas ivestas neteisingai!!!");
		document.getElementById('successfully').className='successfull';
		document.getElementById('execute').className='imgOpicity';
		//form.email.select();
		//return false;
	}else {
		//if(formname!=''){
			//formname.submit();
		//}
		
		ajaxFunctionEmail(email);
		document.getElementById('inp').value='Draugo (-ės) el.p';
		alert("Laiskas issiustas sekmingai!!!");
		//window.location.href=window.location.href;
		/* form.method="get";
		form.target="_self";
		form.action="myscript.cgi";
		form.submit(); */
	}

}

function ajaxFunction(yourName,email,friendEmail)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	}
	else
	{
	  // code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
		//document.myForm.time.value=xmlhttp.responseText
			//alert(xmlhttp.responseText+'ppppppp');
			//alert('Jus sekmingai uzsiregistravote!!!');
			//window.location.href=window.location.href;
			
			document.getElementById('successfully').className='successfull';
			document.getElementById('showSuccessfully').className='imgOpicity';
			
			
			//alert(document.getElementById('successfully').className+'---------');
		}
	}
	xmlhttp.open("GET","data.php?yourName="+yourName+"&email="+email+"&friendEmail="+friendEmail+"",true);
	xmlhttp.send(null);
}


function ajaxFunctionEmail(email)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	}
	else
	{
	  // code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			//document.myForm.time.value=xmlhttp.responseText;
		//	alert(xmlhttp.responseText+'-email------');
			//window.location.reload();
			window.location.href=window.location.href
		}
	}
	xmlhttp.open("GET","email.php?email="+email+"",true);
	xmlhttp.send(null);
}
function clearFields(id1,id2){
	document.getElementById(id1).value="";
	document.getElementById(id2).value=""
}
function verifyEmail(email,question){
var status = false;     
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     if (email.search(emailRegEx) == -1) {
          alert("Neteisingas pašto adresas!");
     }
    
     else if(question==''){
         // alert("Woohoo!  The email address is in the correct format and they are the same.");
	
			
			alert("Užpildykite laukus!");
		
     }else{
		status = true;
	 }
     return status;
}
function sedEmail(email,question,sendEmail){
	var bool=verifyEmail(email,question);
	if(bool){
		$.ajax({
		  url: 'http://fohow777.lt/send.php',
		  data: {email:email,question: question,bourne: bourne,sendEmail: sendEmail},
		  success: function(data) {
			//$('.result').html(data);
		   //alert('Load was performed.'+data);
	
			animateOpacity('idLetterSent','sendForm');
		
		  }
		});
	}
	
}
function sedEmailUniversal(email,question,idShow,idHide,sendEmail){//alert(sendEmail+'-----------------*');

	var bool=verifyEmail(email,question);
	if(bool){
		$.ajax({
		  url: 'http://fohow777.lt/send.php',
		  data: {email:email,question: question,bourne: bourne,sendEmail: sendEmail},
		  success: function(data) {
			//$('.result').html(data);
		   // alert('Load was performed.'+data);

			animateOpacity(idShow,idHide);
		  }
		});
	}
	
}
function sedEmailReg(email,question,sendEmail){//alert(sendEmail+'-----------------*');
	var bool=verifyEmail(email,question);
	if(bool){
		$.ajax({
		  url: 'http://fohow777.lt/send.php',
		  data: {email:email,question: question,bourne: bourne,sendEmail:sendEmail},
		  success: function(data) {
			//$('.result').html(data);
		    //alert('Load was performed.'+data);
		//	animateOpacity('idLetterSent','sendForm');
			animateOpacity('screw1','idNurse');
			setText('seminarDateNut',document.getElementById('idGrind').innerHTML);
		  }
		});
	}
	
}
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)


	



