
$(document).ready(function(){
	$(".open-sponsor").click(function(){
		holder = $("." + $(this).attr('title'));
		
		if(holder.is(':visible')) {
			holder.hide();
			$(this).find('span').html('+ N&auml;ita sponsoreid');
		}else{
			holder.show();
			$(this).find('span').html('- Peida sponsorid');
		}
		return false;
	});
});


function openPic(id,pos,amodul,ftime) {
    openWindow("http://" + location.hostname + "/index.php/page/openPic," + id + "," + pos + "," + amodul,700,600);
}

function showPic(pic,div,type) {	
 if(type == 1) {
	document.getElementById(div).innerHTML = "<img src='" + pic + "' border=0>";
 }else{
	document.getElementById(div).innerHTML = "";
 }
}

function checkAJAX() {
 
  var xmlHttp;
  try {  // Firefox, Opera 8.0+, Safari  
        xmlHttp=new XMLHttpRequest();  
  }
  catch (e){  // Internet Explorer  
      try{    
	  	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	  }
      
	  catch (e){    
	     try {
		    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
		 }
        
		catch (e) {      
		   alert("Your browser does not support AJAX!");      
		   return false;      
		}    
      }  
   }
   return xmlHttp;
}


function checkForm(formID) {
f = document.getElementById(formID);
submitForm = true;
for(i=0; i < f.length; i++) {
  if(f.elements[i].type == "text") {

    if(f.elements[i].value == "") {
       alert("Kohustuslik väli on täitmata! (" + (i + 1) + ")");
	   f.elements[i].focus;
	   submitForm = false;
	   break;
	   
	}
  }

}

if(submitForm == true) {
  f.submit();
}
}


function openWindow(url,width,height) {
	window.open(url,"","width="+width+",height="+height+",resizable=yes,scrollbars");
}

function leiabrauser() {

if(navigator.appName == "Netscape") {
   document.getElementById("findproducts_text").size = 22;
}
}

function printPage(url,width,height,type) {
printWin=window.open("http://" + location.hostname + "modulus/print.php?page="+url+"&type="+type,"","width="+width+",height="+height+",resizable=yes,scrollbars");
printWin.print();
}

function remove(table,id,lang) {
  if(confirm("Oled kindel?")) {
	 self.location.href='?do=delete:' + table + ':' + id +'&lang=' + lang;
  }
 
}

function edit(table,id){ 
 self.location.href='?do=' + table + ':' + id;
}


function get_focus(id) {
var e = document.getElementById(id);
 if(e) {
  e.focus()
 }
}

function goLink(Url){
	window.top.opener.location.href = encodeURI(Url) ;
	window.top.close() ;
	window.top.opener.focus() ;
}

function ref_page(id,link1,link2) {
link2 = document.getElementById(id).selectedIndex;
location.href= link1 + link2;
}

function submitForm(id,active) {
	document.getElementById('activeVal').value = active;
	document.getElementById('actionVal').value = 'save';
 	document.getElementById(id).submit();
}
