function submit()
{
var xmlhttp;
var email = document.getElementById("snews").value;
if (document.getElementById("snews").value==0){ 
  document.getElementById("error").innerHTML = "Please enter your email";
  return false;
}
else{
	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 && xmlhttp.status==200){
			//document.getElementById("news").innerHTML=xmlhttp.responseText;
			document.getElementById("submit_field").style.display="none";
			document.getElementById("submit_field").innerHTML=xmlhttp.responseText;
			$(document).ready(function(){
				$('#submit_field').show('slow');
			});
			return false;
		}
	}
		xmlhttp.open("GET","http://www.attika.lv/submit.php?m="+email,true);
		xmlhttp.send();
	}
}

var timer;
var gb=new Array();
	gb[0]="";
	gb[1]="url('http://www.attika.lv/img/majaslapas.png')";
	gb[2]="url('http://www.attika.lv/img/seo.png')";
	gb[3]="url('http://www.attika.lv/img/socialo_portalu_marketings.png')";
	gb[4]="url('http://www.attika.lv/img/graf1.png')";
	gb[5]="url('http://www.attika.lv/img/zids.png')";


function changer(numb){
	var aid="h_i"+numb;
	var bid="h_c"+numb;
	var cid="p_i"+numb;
	timer=setTimeout('neaktivs(\''+numb+'\')',10000);
		
	document.getElementById(bid).src="img/aktivs.png"; 
	document.getElementById('main_block').style.background=gb[numb];
	document.getElementById(aid).style.display="block";
	document.getElementById(cid).style.display="block";
}

function neaktivs(numb){
	var aid="h_i"+numb;
	var bid="h_c"+numb;
	var cid="p_i"+numb;
	document.getElementById(aid).style.display="none";
	document.getElementById(cid).style.display="none";
	document.getElementById(bid).src="http://www.attika.lv/img/neaktivs.png";
	if(numb==5){numb=1;}
	else{numb++;}
	document.getElementById('main_block').style.background=gb[numb];
	changer(numb);
}

function neaktiv(numb){
	clearTimeout(timer);
	var aid;
	var cid;
	var did;
	var i;
	for(i=1; i<=5; i++){
		aid="h_i"+i;
		document.getElementById(aid).style.display="none";
	}
	for(i=1; i<=5; i++){
		cid="p_i"+i;
		document.getElementById(cid).style.display="none";
	}
	for(i=1; i<=5; i++){
		did="h_c"+i;
		document.getElementById(did).src="img/neaktivs.png";
	}	
	changer(numb);
}

function again(){
	document.getElementById("submit_field").innerHTML="<input type=\"text\" id=\"snews\" name=\"news\" /><p><a href=\"#\" id=\"submit\" onclick=\"submit(); return false\">Pieteikties</a><div id=\"error\"></p></div>";
}

function submiter(){
	var vards=document.getElementById('vards');
	var number=document.getElementById('number');
	var info=document.getElementById('info');
	var skait=0;
	var error=0;
	
	document.getElementById('loading').style.display="block";
	document.getElementById('kluda').style.display="none";
	document.getElementById('paldies').style.display="none";
	vards.style.border="#ccc solid 1px";
	number.style.border="#ccc solid 1px";
	info.style.border="#ccc solid 1px";
	
	if(vards.value.length==0){
		vards.style.border="solid 2px #f00";
		//document.getElementById('kluda').style.display="block";
		skait++;
	}
	if(number.value.length==0){
		number.style.border="solid 2px #f00";
		//document.getElementById('kluda').style.display="block";
		skait++;
	}
	if(info.value.length==0){
		info.style.border="solid 2px #f00";
		//document.getElementById('kluda').style.display="block";
		skait++;
	}
	
	vards=vards.value;
	number=number.value;
	info=info.value;
	
	if(error>0){
		$(document).ready(function(){
			$('#kluda').delay('slow').show('slow');
		});
	}
	if(skait==0){
		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 && xmlhttp.status==200){
			document.getElementById('loading').style.display="none";
			document.getElementById('vards').value="";
			document.getElementById('number').value="";
			document.getElementById('info').value="";
			document.getElementById('paldies').style.display="block";
			return false;
		}
	}
		xmlhttp.open("GET","http://www.attika.lv/submit.php?v="+vards+"&n="+number+"&i="+info,true);
		xmlhttp.send();
		
	}
	else{
		document.getElementById('loading').style.display="none";
		$(document).ready(function(){
			$('#kluda').delay('slow').show('slow');
		});
	}
}
// Draugiem say
function DraugiemSay(){
	var title=document.title;
	var url=location.href;
	window.open(
	  'http://www.draugiem.lv/say/ext/add.php?title=' + encodeURIComponent( title ) +
	  '&link=' + encodeURIComponent( url ) + '&titlePrefix=M%C4%81jas%20lapu%20izstr%C4%81de',
	  '',
	  'location=1,status=1,scrollbars=0,resizable=0,width=530,height=400'
	);
	return false;
}


// Seko Man say
function SekomanSay(){
	var title=document.title;
	var url=location.href;
	document.location.href='http://sekoman.lv/home?status='+encodeURIComponent(title)+'&url='+escape(url);
	return false;
}


// Twitter Say
function TwitterSay(){
	var title='Mājas lapu izstrāde';
	var url=location.href;
	document.location.href='http://twitter.com/?status='+encodeURIComponent(title)+'%20-%20'+escape(url);
	return false;
}


// Buzz say
function BuzzSay(){
	var url=location.href;
	document.location.href='http://www.google.com/buzz/post?url='+escape(url);
	return false;
}

//Face Book say
function FacebookSay(){
	var title=document.title;
	var url=location.href;
	window.open(
	  'http://www.facebook.com/sharer.php?t=' + encodeURIComponent( title ) +
	  '&u=' + encodeURIComponent( url ),
	  '',
	  'location=1,status=1,scrollbars=0,resizable=0,width=626,height=436'
	);
	return false;
}

//MySpace say
function MyspaceSay(){
	var title=document.title;
	var url=location.href;
	document.location.href='http://www.myspace.com/Modules/PostTo/Pages/?l=3&u='+escape(url)+'&t='+encodeURIComponent(title);
	return false;
}

//Linkedin say
function LinkedinSay(){
	var title=document.title;
	var url=location.href;
	document.location.href='http://www.linkedin.com/shareArticle?mini=true&url='+escape(url)+'&title='+encodeURIComponent(title)+'&source=Atlaides%20kupons';
	return false;
}

//Orb say
function OrbSay(){
	var url=location.href;
	document.location.href='http://www.orb.lv/start/?status='+escape(url);
	return false;
}
function epast(){
	document.getElementById('snews').value="";
	document.getElementById('snews').style.color="#000";
}	
function epasti(){
	document.getElementById('snews').value="Epasts";
	document.getElementById('snews').style.color="#ccc";
}

