
var t_more_perf;
var act="";
var user_email="";
var user_key="";
var upbannermas= new Array('France','Gran Canaria'), is_ie=0, upban_country=0, upban_perform_count=new Array(1,2), upban_perform=1, upban_number_ph=1, upbanint=0, upbanintperf=0, animint=0, anim_a=100, anim_b=0, anim_c=0, anim_d=0, anim_font_flg=true, anim_font_a=100, anim_font_b=0, anim_font_c=0, anim_font_d=0, animintfont=0;
function init(){
	if(document.getElementsByTagName('forms')[0]){document.getElementsByTagName('forms')[0].elements(0).focus();}
	var ie=false;
	if(navigator.appName.substring(0,3)=="Mic") {ie=true;}
	document.getElementById("intro_p1_1").onmouseover=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p1_1").style.borderColor="#b8b8bc";
	}
	document.getElementById("intro_p1_1").onmouseout=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p1_1").style.borderColor="#656567";
	}
	document.getElementById("intro_p1_1").onclick=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		window.open("http://www.spbt.ru/about/poffice/news/?lang=eng",('target','_self'));
	}
	
	document.getElementById("intro_p1_2").onmouseover=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p1_2").style.borderColor="#b8b8bc";
	}
	document.getElementById("intro_p1_2").onmouseout=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p1_2").style.borderColor="#656567";
	}
	document.getElementById("intro_p1_2").onclick=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		window.open("http://www.spbt.ru/about/poffice/prel/?lang=eng",('target','_self'));
	}
	
	document.getElementById("intro_p1_3").onmouseover=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p1_3").style.borderColor="#b8b8bc";
	}
	document.getElementById("intro_p1_3").onmouseout=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p1_3").style.borderColor="#656567";
	}
	document.getElementById("intro_p1_3").onclick=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		window.open("http://www.spbt.ru/about/gbook/?lang=eng",('target','_self'));
	}
		
	document.getElementById("intro_p1_4").onmouseover=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p1_4").style.borderColor="#b8b8bc";
		t_more_perf=window.setTimeout("show_more_perf()",900);
	}
	document.getElementById("intro_p1_4").onmouseout=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p1_4").style.borderColor="#656567";
		window.clearTimeout(t_more_perf);
	}
		document.getElementById("intro_p1_4").onclick=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		window.open("http://www.spbt.ru/main/?lang=eng&jy=2010&jm=11&jd=2010_11_01",('target','_self'));
	}
			
	document.getElementById("intro_p2_1").onmouseover=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p2_1").style.borderColor="#b8b8bc";
	}
	document.getElementById("intro_p2_1").onmouseout=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p2_1").style.borderColor="#656567";
	}
	document.getElementById("intro_p2_1").onclick=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		window.open("http://www.spbt.ru/mapspbt/?lang=eng",('target','_self'));
	}
	document.getElementById("intro_p2_2").onmouseover=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p2_2").style.borderColor="#b8b8bc";
	}
	document.getElementById("intro_p2_2").onmouseout=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("intro_p2_2").style.borderColor="#656567";
	}
	document.getElementById("intro_p2_2").onclick=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		window.open("http://www.spbt.ru/main/index.php?lang=eng",('target','_self'));
	}
	document.getElementById("id_more_perf").onmouseover=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("id_more_perf").style.visibility="visible";
	}
	document.getElementById("id_more_perf").onmouseout=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		document.getElementById("id_more_perf").style.visibility="hidden";
	}
	document.getElementById("id_bnr_intro").onclick=function(ev){
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
				window.open("http://www.theatrechampselysees09.fr/saison-detail.php?t=3&s=83",('target','_blank'));				
	}
	/* init верхнего баннера */
	is_ie=( navigator.userAgent.indexOf("MSIE ")>0 ) ? 1 : 0;
	upbanint=window.setInterval("chbancountry(1)", 3200);  // 3200 - интервал смены стран <-- упр.
	upbanintperf=window.setInterval("chbancountry(2)", 8000); // 8000 - интервал смены фото постановки <-- упр.
	document.getElementById("baninf").onclick=function(ev){
		if(navigator.appName.substring(0,3)=="Mic") {ie=true;}
		if(ie){event.cancelBubble = true;} else {ev.cancelBubble = true;}
		window.open("http://www.irinakolesnikova.com/shedl/?lang=eng",('target','_blank'));
	}
	/* конец init верхн баннера */
		if(act.indexOf("confirm")!=-1){		if(user_email!="" && user_key!=""){
			send_confirm(user_email,user_key);
		}
	} else if(act.indexOf("unscribe")!=-1){
		if(user_email!="" && user_key!=""){
			send_unsubscribe(user_email,user_key);
		}
	}
}
function chbancountry(val) {
	switch(val){
	case 1: // для смены страны
		upban_country++;
		if(upban_country >= upbannermas.length) {upban_country=0;
			
		}
		window.clearInterval(animintfont); anim_font_flg=true;
		anim_font_c=anim_font_a; anim_font_d=anim_font_b;
		animintfont=window.setInterval("fade_font(document.getElementById('bancountry'),'"+upbannermas[upban_country]+"',50,"+is_ie+")", 150);
	break;
	case 2: // для смены спектакля
		var strobjimg_last="bb2_"+upban_perform+"_"+upban_number_ph;
		if(++upban_number_ph > upban_perform_count[upban_perform-1]) {upban_number_ph=1;
			if(++upban_perform > upban_perform_count.length) upban_perform=1;
		}
		var strobjimg="bb2_"+upban_perform+"_"+upban_number_ph;
		anim_c=anim_a; anim_d=anim_b;
		document.getElementById(strobjimg).style.visibility="visible";
		animint=window.setInterval("changebanimg(document.getElementById('"+strobjimg_last+"'),document.getElementById('"+strobjimg+"'),5,"+is_ie+")", 150);
	break;
	}
}
function fade_font(obj_font,newtext,step,ie){
	if(anim_font_flg){ // исчезновение
		if(anim_font_c >= 0){
			anim_font_c-=step;
		    if(ie){
		        obj_font.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+anim_font_c+")";
		    } else {
		        obj_font.style.opacity=anim_font_c/100;
		    }
		} else {
			anim_font_flg=false;
			obj_font.innerHTML='<p>'+newtext+'</p>';
			obj_font.getElementsByTagName('p')[0].style.fontSize = '8px';
		}
	} else { // проявление
		if(anim_font_d <= 100){
			anim_font_d+=step;
			if(ie){
		        obj_font.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+anim_font_d+")";
		    } else {
		        obj_font.style.opacity=anim_font_d/100;
		    }
			obj_font.getElementsByTagName('p')[0].style.fontSize = (Math.ceil((anim_font_d/100)*5))+'px';
		} else {
			window.clearInterval(animintfont);
			anim_font_flg=true;
			obj_font.getElementsByTagName('p')[0].style.fontSize = '14px';
		}
	}
}
function changebanimg(obj_a,obj_b,step,ie){
	if(anim_c){
		anim_c-=step;
	    anim_d+=step;
	    if(ie){
	        obj_a.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+anim_c+")";
	        obj_b.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+anim_d+")";
	    } else {
	        obj_a.style.opacity=anim_c/100;
	        obj_b.style.opacity=anim_d/100;
	    }
	} else {
		window.clearInterval(animint);
		obj_a.style.visibility="hidden";
	}
}
function show_more_perf(){
	get_artists();	document.getElementById("id_more_perf").style.visibility="visible";
}
xmlHttp=createXmlHttpRequestObject();
function createXmlHttpRequestObject(){ 
    var xmlHttp; 
    try{ 
        xmlHttp = new XMLHttpRequest(); 
    }catch(e){ 
        var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0","Microsoft.XMLHTTP"); 
        for(var i=0;i < XmlHttpVersions.length && !xmlHttp;i++){ 
            try{ 
                xmlHttp=new ActiveXObject(XmlHttpVersions[i]); 
            }catch(e){} 
        } 
    } 
    if(!xmlHttp){ 
        alert('Ошибка создания объекта XMLHttpRequest.'); 
    }else return xmlHttp; 
}
function get_artists(){
	if(xmlHttp){ 
        try{
            xmlHttp.open("GET","http://www.spbt.ru/cast_artists.php?ido=317&lang=eng", true); 
			xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		   	xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		   	xmlHttp.setRequestHeader("Pragma", "no-cache");
            xmlHttp.onreadystatechange=res_cast_artists;
            xmlHttp.send(null);
        }catch(e){ 
            alert("Невозможно соединиться с сервером:\n" + e.toString()); 
        } 
    }
}
function res_cast_artists(){
		if(xmlHttp.readyState == 4){ 
        if(xmlHttp.status==200){ 
           try{     			xmlResponse = xmlHttp.responseXML;
				var xmlRoot = xmlResponse.documentElement;	
				var blocks_array = xmlRoot.getElementsByTagName("block");
				
								for(var i=0;i<blocks_array.length;i++){
					var artists_array=blocks_array[i].getElementsByTagName("artist");
					var role_array=blocks_array[i].getElementsByTagName("role");					
					if(role_array[0].firstChild){
						var role=role_array[0].firstChild.data;
						if(role!="-"){
							if( i==0 ){
								document.getElementById("id_p_role1").innerHTML=role;
							} else if( i==1 ){
								document.getElementById("id_p_role2").innerHTML=role;
							} else if( i==2 ){
								document.getElementById("id_p_role3").innerHTML=role;
							}
						}
					}									
					if(artists_array.length){
						for(var j=0;j<artists_array.length;j++){
							var artist=artists_array[j].getElementsByTagName("name");
							var name_art=artist[0].firstChild.data;
							if(name_art!="-"){
								if( i==0 && j==0 ){
									document.getElementById("id_p_artist1").innerHTML=name_art;
								} else if(i==1 && j==0){
									document.getElementById("id_p_artist2").innerHTML=name_art;
								} else if(i==2 && j==0){
									document.getElementById("id_p_artist3").innerHTML=name_art;
								}
							}
						}
					}
				}
				if( document.getElementById("id_p_role1").innerHTML=="" && document.getElementById("id_p_role2").innerHTML=="" && document.getElementById("id_p_role3").innerHTML=="" && document.getElementById("id_p_artist1").innerHTML=="" && document.getElementById("id_p_artist2").innerHTML=="" && document.getElementById("id_p_artist3").innerHTML=="" ){
					document.getElementById("id_p_artist1").innerHTML="Cast of artists<br />will be announce later.";
}
   			}catch(e){
                alert("Ошибка чтения ответа: " + e.toString()); 
            }
  		} 
	}
	if(xmlHttp.readyState == 1){		
	}
}
function check_subscribe(){
	flg_good=0;
	if(document.getElementById("stremail").value){ 
		email=document.getElementById("stremail").value;
		if(email.indexOf("@")==-1 || email.indexOf(".")==-1){
			window.alert("Incorrect e-mail!");
		} else {
			mass_email=email.split("@");
			if(mass_email.length==2){
				mass_email1=mass_email[1].split(".");
				if(mass_email[0].length>1 && mass_email1[0].length>1 && (mass_email1[mass_email1.length-1].length==2 || mass_email1[mass_email1.length-1].length==3 || mass_email1[mass_email1.length-1].length==4) ){
					flg_good=1;
				} else {
					window.alert("Incorrect e-mail!");
				}
			} else {
				window.alert("Incorrect e-mail!");
			}
		}
	} else {window.alert("Enter your e-mail!");}
	if(flg_good){
		send_email(email);
	}
}
xmlHttp1=createXmlHttpRequestObject1();
xmlHttp2=createXmlHttpRequestObject1();
xmlHttp3=createXmlHttpRequestObject1();
function createXmlHttpRequestObject1(){ 
    var xmlHttp1; 
    try{ 
        xmlHttp1 = new XMLHttpRequest(); 
    }catch(e){ 
        var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0","Microsoft.XMLHTTP"); 
        for(var i=0;i < XmlHttpVersions.length && !xmlHttp1;i++){ 
            try{ 
                xmlHttp1=new ActiveXObject(XmlHttpVersions[i]); 
            }catch(e){} 
        } 
    } 
    if(!xmlHttp1){ 
        alert('Ошибка создания объекта XMLHttpRequest.'); 
    }else return xmlHttp1; 
}
function send_email(val){
	if(xmlHttp1 && val){ 
        try{
            xmlHttp1.open("GET","http://www.spbt.ru/subscribe_me.php?stremail="+val, true); 
			xmlHttp1.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		   	xmlHttp1.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		   	xmlHttp1.setRequestHeader("Pragma", "no-cache");
            xmlHttp1.onreadystatechange=res_email;
            xmlHttp1.send(null);
        }catch(e){ 
            alert("Невозможно соединиться с сервером:\n" + e.toString()); 
        } 
    }
}
function res_email(){
	if(xmlHttp1.readyState == 4){ 
        if(xmlHttp1.status==200){ 
            try{     			var result = xmlHttp1.responseText;
				if(result.indexOf("ok")!=-1){
					document.getElementById("id_div_subscribe").innerHTML="<p class=\"p_subscribe1\">Activation code was send to your e-mail.</p>";
				} else {
					document.getElementById("id_div_subscribe").innerHTML="<p class=\"p_subscribe1\">Error, try again later!</p>";
				}
			}catch(e){
                alert("Ошибка чтения ответа: " + e.toString()); 
            }
  		} 
	}
	if(xmlHttp1.readyState == 1){
	}
}
function send_confirm(val,val1){
	if(xmlHttp2 && val && val1){ 
        try{
            xmlHttp2.open("GET","http://www.spbt.ru/confirm.php?stremail="+val+"&key="+val1, true); 
			xmlHttp2.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		   	xmlHttp2.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		   	xmlHttp2.setRequestHeader("Pragma", "no-cache");
            xmlHttp2.onreadystatechange=res_confirm;
            xmlHttp2.send(null);
        }catch(e){ 
            alert("Невозможно соединиться с сервером:\n" + e.toString()); 
        } 
    }
}
function res_confirm(){
	if(xmlHttp2.readyState == 4){ 
        if(xmlHttp2.status==200){ 
            try{     			var result = xmlHttp2.responseText;
				if(result.indexOf("ok")!=-1){
					window.alert('Ваш e-mail был успешно подтверждён.');
				}
			}catch(e){
                alert("Ошибка чтения ответа: " + e.toString()); 
            }
  		} 
	}
	if(xmlHttp2.readyState == 1){
	}
}
function send_unsubscribe(val,val1){
	if(xmlHttp3 && val && val1){ 
        try{
            xmlHttp3.open("GET","http://www.spbt.ru/unsubscribe.php?stremail="+val+"&key="+val1, true); 
			xmlHttp3.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		   	xmlHttp3.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		   	xmlHttp3.setRequestHeader("Pragma", "no-cache");
            xmlHttp3.onreadystatechange=res_unsubscribe;
            xmlHttp3.send(null);
        }catch(e){ 
            alert("Невозможно соединиться с сервером:\n" + e.toString()); 
        } 
    }
}
function res_unsubscribe(){
	if(xmlHttp3.readyState == 4){ 
        if(xmlHttp3.status==200){ 
            try{     			var result = xmlHttp3.responseText;
				if(result.indexOf("ok")!=-1){
					window.alert('Ваш e-mail был отписан от рассылки.');
				}
			}catch(e){
                alert("Ошибка чтения ответа: " + e.toString()); 
            }
  		} 
	}
	if(xmlHttp3.readyState == 1){
	}
}