function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		o1 = newImage("images/separator_active.gif");
		o2 = newImage("images/separator_active_end.gif");
		o3 = newImage("images/separator_active_start.gif");
		o4 = newImage("images/separator_active_superend.gif");
		o5 = newImage("images/separator_active_superstart.gif");
		o6 = newImage("images/separator_inactive.gif");
		o7 = newImage("images/separator_inactive_end.gif");
		o8 = newImage("images/separator_inactive_start.gif");
		o9 = newImage("images/sg_menu_back.gif");
		o10 = newImage("images/sg_menu_back_over.gif");
		o11 = newImage("images/sg_menu_back2.gif");
		o12 = newImage("images/sg_menu_back_over.gif");
		
		
		preloadFlag = true;
	}
}

function bookmarkit(){
	if (document.all){	
		window.external.addFavorite('http://www.fotoazja.pl','fotoAzja.pl - Azja w obiektywie');
	}

}

function checkCheckForm(f){
	if (f.opinia.value == "" ) {
		alert('Musisz wpisać tekst opinii / komentarza');
		return false;
	}
}

function sprawdz_emial(f){
	if (f.email_test.value=='') {
		alert('Nie podałeś/aś adresu e-mail');
		return false;
	}
	if ( ((f.email_test.value.indexOf('@',1))==-1)||(f.email_test.value.indexOf('.',1))==-1 ) {
		alert('Podałeś błędny e-mail');
		return false;
	}
	alert('fotoAzja jest częścią portalu transAzja.pl. W celu rejestracji zostaniesz teraz przekierowany na www.transazja.pl');
	return true;	
}


function zmien(id) {
	document.getElementById(id).style.display=(document.getElementById(id).style.display=='block')?'none':'block';
}

function zamknij_reklame(id){
	document.getElementById(id).style.display='none';
}

function zmien2(id, zakres) {
	
	for(p=1;p<=zakres;p++){
		if(p==id){
			document.getElementById(p).style.display="block";
		}
		else{
			document.getElementById(p).style.display="none";	
		}
	}
			
}

function zmien_klase(id, zakres, nazwa) {
	
	var klasa_on = nazwa+"_active";
	var klasa_off = nazwa;
		
	for(p=1;p<=zakres;p++){
		
		var elem = 'klasa_'+p;
		
		if(elem==id){
			document.getElementById(elem).className = klasa_on;
		}
		else{
			document.getElementById(elem).className = klasa_off;	
		}
	}
			
}

function zmien_obrazek(id, zakres, id1) {
	
	var obr_on_start = "images/separator_active_start.gif";
	var obr_on_end = "images/separator_active.gif";
	var obr_off = "images/separator_inactive.gif";

	for(p=2;p<=zakres;p++){
		
		var elem = 'separator_'+p;
		var elem1 = 'separator_'+(p+1);

		if(elem==id){
			document.images[elem].src = obr_on_start;
		}
		else if(elem1==id1){
			document.images[elem].src = obr_on_end;
		}		
		else{
			document.images[elem].src = obr_off;	
		}
	}
			
}

function zmien_obrazek_skarj(id, akcja, koniec){
	
	if(koniec == '0'){
		var obr_on = "images/separator_active_superstart.gif";
		var obr_off = "images/separator_inactive_start.gif";
	}else{
		var obr_on = "images/separator_active_superend.gif";
		var obr_off = "images/separator_inactive_end.gif";	
	}
	
	if(akcja == 'on'){
		document.images[id].src = obr_on;
	}
	else{
		document.images[id].src = obr_off;
	}

}

function openpopup(){
	winpops=window.open(popurl,"popup","width=450,height=180,screenX=150,screenY=150,top=150,left=150")
}


function soundwindow(trak,akcja) {
	window.name = "main";

    sound = window.open('music.php','sound_okienko','width=195,height=115,resizable=0,scrollbars=0,menubar=no,location=0,status=0,left=100,top=110');
	if(akcja == 1 && trak != 0){
	    setTimeout("moretext("+trak+")",3000);
	}
	else{
		sound.window.close();
	}
}

function moretext(trak){
	sound.bgmusic.TGotoAndPlay('/music_'+trak,'start');
	sound.blur();
}

function get_cookie(Name) {
//this function is used only if variable "poponce" above is set to "true"
 var search = Name + "="
 var returnvalue = "";
 if (document.cookie.length > 0) {
   offset = document.cookie.indexOf(search)
   if (offset != -1) { // if cookie exists
     offset += search.length
     // set index of beginning of value
     end = document.cookie.indexOf(";", offset);
     // set index of end of cookie value
     if (end == -1)
        end = document.cookie.length;
     returnvalue=unescape(document.cookie.substring(offset, end))
     }
  }
 return returnvalue;
}


function loadpopup(){
 if (status=="true") { // if popups turned on
  if (get_cookie('alreadypopped')==''){ // and cookie not set
   openpopup() // then show popup
   if (poponce=="true") { // if popup once only required
     document.cookie="alreadypopped=yes" // then set a cookie
     }
   }
  // cookie is already set; so do nothing
 }
}


function load_toplayer(){
 if (status=="true") { // if popups turned on
  if (get_cookie('alreadypopped')==''){ // and cookie not set
  
  open_toplayer()
  
   if (poponce=="true") { // if popup once only required
     document.cookie="alreadypopped=yes" // then set a cookie
     }
   }
  // cookie is already set; so do nothing
 }
}


function open_toplayer(){
	var myWidth = 220;
	var myHeight = 315;
	var myLeft = ((screen.width-myWidth)/2)-160;
    //var myTop = ((screen.height-myHeight)/2)-170;
	var myTop = 120;

	document.write('<div id="toplayer" style="display:none; position:absolute; left:'+myLeft+'px; top:'+myTop+'px; width:'+myWidth+'px; height:'+myHeight+'px; z-index:2;"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="315" HEIGHT="220" id="foto_azja_toplayer" ALIGN=""> <PARAM NAME=movie VALUE="images/flash/foto_azja_toplayer.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="images/flash/foto_azja_toplayer.swf" quality=high wmode=transparent bgcolor=#FFFFFF  WIDTH="315" HEIGHT="220" NAME="foto_azja_toplayer" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></div>');
	setTimeout("pokaz_toplayer()",5000);
}

function pokaz_toplayer(){
	document.getElementById("toplayer").style.display='block';
}