function fnAnimatePanel(sPanelName,oButton){if(document.getElementById(sPanelName).style.height=="0px"){var attributes={height:{to:document.getElementById(sPanelName+"cont").offsetHeight}};YAHOO.util.Cookie.set(sPanelName,1,{expires:new Date("January 12, 2025")});oButton.innerHTML="<img border='0' src='/build/assets/skins/sam/dt-arrow-up.png'/>";}else{var attributes={height:{to:0}};YAHOO.util.Cookie.set(sPanelName,0,{expires:new Date("January 12, 2025")});oButton.innerHTML="<img border='0' src='/build/assets/skins/sam/dt-arrow-dn.png'/>";}
var anim=new YAHOO.util.Anim(sPanelName,attributes,1,YAHOO.util.Easing.easeOut);anim.animate();}
function fnInitAnimatePanels(sName){if(YAHOO.util.Cookie.get(sName)=="0"){document.getElementById(sName).style.height="0px";document.getElementById("btn_"+sName).innerHTML="<img border='0' src='/build/assets/skins/sam/dt-arrow-dn.png'/>";}
if(YAHOO.util.Cookie.get(sName)=="1"){document.getElementById(sName).style.height="";document.getElementById("btn_"+sName).innerHTML="<img border='0' src='/build/assets/skins/sam/dt-arrow-up.png'/>";}}
function fnShowHidePanel(oElementName,oButton){var oVDiv=document.getElementById(oElementName);if(oVDiv.style.display=="none"){oVDiv.style.display="block";YAHOO.util.Cookie.set(oElementName,1,{expires:new Date("January 12, 2025")});oButton.innerHTML="<img border='0' src='/build/assets/skins/sam/dt-arrow-up.png'/>";}else{oVDiv.style.display="none";YAHOO.util.Cookie.set(oElementName,0,{expires:new Date("January 12, 2025")});oButton.innerHTML="<img border='0' src='/build/assets/skins/sam/dt-arrow-dn.png'/>";}}
function fnInitPanels(sName){if(YAHOO.util.Cookie.get(sName)=="0"){document.getElementById(sName).style.display="block";fnShowHidePanel(sName,document.getElementById("btn_"+sName));}
if(YAHOO.util.Cookie.get(sName)=="1"){document.getElementById(sName).style.display="none";fnShowHidePanel(sName,document.getElementById("btn_"+sName));}}
YAHOO.namespace("example.container");function init(url,oelement){var attributes={opacity:{to:0.4}};var anim=new YAHOO.util.Anim(oelement,attributes,0.5,YAHOO.util.Easing.easeOut);anim.animate();var content=document.getElementById(oelement);YAHOO.example.container.wait=new YAHOO.widget.Panel("wait",{width:"240px",fixedcenter:true,close:false,draggable:false,zindex:4,modal:false,visible:false});YAHOO.example.container.wait.setHeader("Загружаю, подождите...");YAHOO.example.container.wait.setBody("<img src=\"/engine/ajax/loading.gif\"/>");YAHOO.example.container.wait.render(content);var callback={success:function(o){var attributes2={opacity:{to:1}};content.innerHTML=o.responseText;content.style.visibility="visible";YAHOO.example.container.wait.hide();var anim2=new YAHOO.util.Anim(oelement,attributes2,1,YAHOO.util.Easing.easeOut);anim2.animate();},failure:function(o){content.innerHTML=o.responseText;content.style.visibility="visible";content.innerHTML="CONNECTION FAILED!";YAHOO.example.container.wait.hide();}}
YAHOO.example.container.wait.show();var conn=YAHOO.util.Connect.asyncRequest("GET",url,callback);}
function initmin(url,oelement){
	var content=document.getElementById(oelement);
	var callback={success:function(o){
		var attributes2={opacity:{to:1}};
		content.innerHTML=o.responseText;
		var anim2=new YAHOO.util.Anim(oelement,attributes2,1,YAHOO.util.Easing.easeOut);
		anim2.animate();
		},failure:function(o){
			content.innerHTML=o.responseText;
			content.innerHTML="CONNECTION FAILED!";
		}
	}
	var conn=YAHOO.util.Connect.asyncRequest("GET",url,callback);
}


tId = setTimeout("", 100);
function fnMoving(sOrder) {
 clearTimeout(tId);
 tId = setTimeout("fnShow('"+ sOrder +"')", 500);
}
function fnShow(sOrder) {
 animatedcollapse.show(sOrder)
 document.getElementById(sOrder).style.display = 'block';
}
/*
function fnCC(eid){
	YAHOO.util.Cookie.set("pogoda_city_id", eid, { expires:new Date("January 12, 2025") });
	if(document.location=="http://www.vkurse.kz/index.php?do=pogoda"){
			window.location.href = "http://www.vkurse.kz/index.php?do=pogoda"
	}else{
	initmin('/getcinimainfo.php?go=pogoda_sity_id&city_id='+eid, 'pogoda_sity'); 
	YAHOO.panelcity.hide(); 
	}
	return false;
}
*/


function fnChangeCity(s_city_id){
		YAHOO.util.Cookie.set("cinema_city_id", s_city_id, { expires:new Date("January 12, 2025") });
		 var tab0=tabView.get('activeTab');
		 
		 tabView.getTab(0).set('dataSrc', 'getcinimainfo.php?take=films&city_id='+s_city_id);
		 tabView.getTab(0).set('content', '');
		 tabView.getTab(0).set('cacheData', 'false');
		 tabView.getTab(1).set('dataSrc', 'getcinimainfo.php?take=cinima&city_id='+s_city_id);
		 tabView.getTab(1).set('content', '');
		 tabView.getTab(1).set('cacheData', 'false');
		 tabView.getTab(2).set('dataSrc', 'getcinimainfo.php?take=filmscinima&city_id='+s_city_id);
		 tabView.getTab(2).set('content', '');
		 tabView.getTab(2).set('cacheData', 'false');
		 tab0.refresh();
}

function display() {
  if (document.getSelection) {
    var str = document.getSelection();
    if (window.RegExp) {
      var regstr = unescape("%20%20%20%20%20");
      var regexp = new RegExp(regstr, "g");
      str = str.replace(regexp, "");
    }
  } else if (document.selection && document.selection.createRange) {
    var range = document.selection.createRange();
    var str = range.text;
  } else {
    var str = "Sorry, this is not possible with your browser.";
  }
  document.getElementById("errortext").value=str;
}

function initcont() {
	
	// Define various event handlers for Dialog
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};
	var handleSuccess = function(o) {
		alert("Ваше сообщение отправлено!!");
	};
	var handleFailure = function(o) {
		alert("Ошибка: " + o.status);
	};

	// Instantiate the Dialog
	YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1", 
							{ width : "30em",
							  fixedcenter : true,
							  visible : false, 
							  constraintoviewport : true,
							  buttons : [ { text:"Отослать", handler:handleSubmit, isDefault:true },
								      { text:"Отмена", handler:handleCancel } ]
							});

							
							
	YAHOO.example.container.dialog2 = new YAHOO.widget.Dialog("dialog2", 
							{ width : "30em",
							  fixedcenter : true,
							  visible : false, 
							  constraintoviewport : true,
							  buttons : [ { text:"Отослать", handler:handleSubmit, isDefault:true },
								      { text:"Отмена", handler:handleCancel } ]
							});						
							
	// Validate the entries in the form to require that both first and last name are entered
	YAHOO.example.container.dialog1.validate = function() {
		var data = this.getData();
		if (data.firstname == "") {
			alert("введите Имя");
			return false;
		} else {
			return true;
		}
	};
	YAHOO.example.container.dialog2.validate = function() {
		var data = this.getData();
		if (data.errortext == "") {
			alert("Пожалуйста, выделите часть текста, в котором вы нашли ошибку!");
			return false;
		} else {
			return true;
		}
	};

	// Wire up the success and failure handlers
	YAHOO.example.container.dialog1.callback = { success: handleSuccess,
						     failure: handleFailure };
	YAHOO.example.container.dialog2.callback = { success: handleSuccess,
						     failure: handleFailure };
	
	// Render the Dialog
	YAHOO.example.container.dialog1.render();
	YAHOO.example.container.dialog2.render();

	YAHOO.util.Event.addListener("show", "click", YAHOO.example.container.dialog1.show, YAHOO.example.container.dialog1, true);
	YAHOO.util.Event.addListener("show2", "click", YAHOO.example.container.dialog2.show, YAHOO.example.container.dialog2, true);
}