var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function toggle(targetId) {
	if(document.getElementById){
		target=document.getElementById(targetId);
		if(target.style.display=="none") {
			target.style.display="";
		} else {
			target.style.display="none";
		}
	}
}
function hideMe(targetId) {
	if(document.getElementById){
		target=document.getElementById(targetId);
		target.style.display="none";
	}
}

function showMe(targetId) {
	if(document.getElementById){
		target=document.getElementById(targetId);
		target.style.display="";
	}
}


function subSwitch(type) {
var target='';
	if (type==1) {
		showMe ('switch1');
		hideMe ('switch2');
		hideMe ('switch3');
		hideMe ('switch4');

		SetCookie('bgi_disptype', '1', 365);
		
	}
	if (type==2) {
		showMe ('switch2');
		hideMe ('switch1');
		hideMe ('switch3');
		hideMe ('switch4');
		SetCookie('bgi_disptype', '2', 365);
	}
	if (type==3) {
		showMe ('switch3');
		hideMe ('switch1');
		hideMe ('switch2');
		hideMe ('switch4');
		SetCookie('bgi_disptype', '3', 365);
	}

	if (type==4) {
		showMe ('switch4');
		hideMe ('switch1');
		hideMe ('switch2');
		hideMe ('switch3');
		SetCookie('bgi_disptype', '4', 365);
	}
	
	
	
	
	document.getElementById('tab1').className='inactivetab';
	document.getElementById('tab2').className='inactivetab';
	document.getElementById('tab3').className='inactivetab';
	document.getElementById('tab4').className='inactivetab';
	target=document.getElementById('tab'+type);
	target.className='activetab';
}
function SetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"=" + escape(cookieValue) + ";expires="+expire.toGMTString();
}


function hidetabcontents() {
	hideMe('tabnews1');
	hideMe('tabnews2');
	hideMe('tabnews3');
	

	classMe('tab1','inactivetab');
	classMe('tab2','inactivetab');
	classMe('tab3','inactivetab');
	

}

function hidetabcontentsgal() {
	hideMe('tabnews4');
	hideMe('tabnews5');
	classMe('tab4','inactivetab');
	classMe('tab5','inactivetab');
}

function hidetabcontentsmail() {
	hideMe('tabnews6');
	hideMe('tabnews7');
	classMe('tab6','inactivetab');
	classMe('tab7','inactivetab');
}

function classMe(targetId, classN) {
	if(document.getElementById){
		target=document.getElementById(targetId);
		target.className=classN;
	}
}

function switchMe(targetId, actionerId) {
	if(document.getElementById){
		target=document.getElementById(targetId);
		actioner=document.getElementById(actionerId);
		target.style.display="block";
		actioner.className="activetab";
	}
}

function showDiv(targetId) {
target = document.getElementById(targetId);

	if(target.style.display=='none'){
		document.getElementById('q_submit').style.visibility='hidden';
		target.style.display='block';
	}else if(target.style.display=='block'){
		document.getElementById('q_submit').style.visibility='visible';
		target.style.display='none';
	}
	
}

//AJAX ZA ABONIRANE
var xmlHttp
function GetXmlHttpObject()
{
var xmlHttp=null;

try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e) 
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function sendmail(){
   

   var name = document.getElementById('mailime').value;
   var email = document.getElementById('mailemail').value;
   xmlHttp=GetXmlHttpObject()

   if (xmlHttp==null){

      alert ("Browser does not support HTTP Request")

      return

   } 

   var url="maillist.php?user_email="+email+"&user_ime="+name;

   url=url+"&sid="+Math.random()
   

   xmlHttp.onreadystatechange=stateChangedmail 

   xmlHttp.open("GET",url,true)

   xmlHttp.send(null)
}

function stateChangedmail() { 

   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 

      document.getElementById("msg").innerHTML=xmlHttp.responseText

   } 

}
// END AJAX GALERIA

function changeImg(img){
	document.getElementById('rightsnimki').innerHTML='<img src="'+img+'" alt="www.bgimoti.eu" width="440" />';
}


