/***********************************************
* Dynamic Ajax Content- ТЉ Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
************************************************/
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}




var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}


function change_link_color (idname, menu) {
	//var element;
	var divs=new Array('sd','ld','hd','fhd');
	
//document.getElementById("content_header").className = idname+'_header';
	
	var i=0;
	for (i=0;i<divs.length;i++)
	{
			
		if (divs[i]==idname) {
			  document.getElementById(divs[i]).className = divs[i]+'_active';
			  //alert (divs[i]+"_link");
		}
		else {
		
			//element.style.display = "none";
			//element_link.className = '';
			//document.getElementById(divs[i]+"_link").style.backgroundImage = "url(/images/"+divs[i]+"_bw.png)"; 
			document.getElementById(divs[i]).className = divs[i];
			//alert (divs[i]+"_link");
			 
		}
		if (idname=='tv') {
			  document.getElementById('now_program').className = 'none_active';
			   
			  //alert (divs[i]+"_link");
		}
		else {
			document.getElementById('now_program').className = 'active';
		}
	}


}


function show_close_anons () {
	//var element;
	//var divs=new Array('128','512','1');
	
//document.getElementById("content_header").className = idname+'_header';
	
	//var i=0;
	var lang = getCookie("lang");
		//alert (lang);
		if (document.getElementById('watch_anons').className=='watch_anons') {
			  document.getElementById('watch_anons').className = 'close_anons';
			  if (lang=='eng') {
			  document.getElementById('watch_anons').innerHTML='Hide bill';
			  }
			  else { 
			  
			  document.getElementById('watch_anons').innerHTML='аЁаКб�б�б�б� аАаНаОаНб�б�';
			  }
			  //alert (divs[i]+"_link");
		}
		else {
		
			//element.style.display = "none";
			//element_link.className = '';
			//document.getElementById(divs[i]+"_link").style.backgroundImage = "url(/images/"+divs[i]+"_bw.png)"; 
			 document.getElementById('watch_anons').className = 'watch_anons';
			if (lang=='eng') {
			  
			  document.getElementById('watch_anons').innerHTML='Show bill';
			  }
			  else { 
			  document.getElementById('watch_anons').innerHTML='а�аОаКаАаЗаАб�б� аАаНаОаНб�б�';
			  
			  }
			//alert (divs[i]+"_link");
			 
		}
	


}



function show_hide (idname) {
	//var element;
	var divs=new Array('chat','program','partner','about','projects');
	
document.getElementById("content_header").className = idname+'_header';
	
	var i=0;
	for (i=0;i<divs.length;i++)
	{
			
		if (divs[i]==idname) {
			  document.getElementById(divs[i]+"_link").className = divs[i]+'_active';
			  //alert (divs[i]+"_link");
		}
		else {
		
			//element.style.display = "none";
			//element_link.className = '';
			//document.getElementById(divs[i]+"_link").style.backgroundImage = "url(/images/"+divs[i]+"_bw.png)"; 
			document.getElementById(divs[i]+"_link").className = divs[i]+'_link';
			//alert (divs[i]+"_link");
			 
		}
	}


}
function show_hide_header (idname) {
	//var element;
	//var divs=new Array('chat','program','partner','movie','about','license','possibility');
	
document.getElementById("content_header").className = idname+'_header';
	

}


function simple_tooltip(target_items, name){
$(target_items).each(function(i){
$("body").append("<div class='"+name+"' id='"+name+i+"'><p>"+$(this).attr('title')+"</p></div>");
var my_tooltip = $("#"+name+i);

$(this).removeAttr("title").mouseover(function(){
my_tooltip.css({opacity:0.8, display:"none"}).fadeIn(400);
}).mousemove(function(kmouse){
my_tooltip.css({left:kmouse.pageX+15, top:kmouse.pageY+15});
}).mouseout(function(){
my_tooltip.fadeOut(400);
});
});
}
$(document).ready(function(){
simple_tooltip("#slider a","tooltip");
}
);





   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
      var poststr = "user_nick=" + 
document.getElementById("user_nick").value ;
 makePOSTRequest('post.php', poststr);
   }
   
   
   
   ///time
   
   var lang = getCookie("lang");
   var d=document
var NN=d.layers?true:(window.opera&&!d.createComment)?true:false
var worldtime = new Array()
if (lang=='eng') {
worldtime[1]="London,1"
worldtime[2]="Moscow,4"
worldtime[0]="New York,-3"
worldtime[3]="Tokyo,10"
}
else {
worldtime[1]="а�аОаНаДаОаН,1"
worldtime[2]="а�аОб�аКаВаА,4"
worldtime[0]="а�б�б� а�аОб�аК,-3"
worldtime[3]="аЂаОаКаИаО,10"
}


function showTime(){
	tmN= new Date()
var dM=''+tmN.getMinutes();dM=dM.length<2?'0'+dM:dM
 var dS=''+tmN.getSeconds();dS=dS.length<2?'0'+dS:dS
 var tmp=''
for (i=0; i<=worldtime.length-1;i++) {
  thisplace=worldtime[i].split(",")
  
  hours=tmN.getUTCHours()
  hours=eval(hours)
  shifthours=eval(thisplace[1])
  dH=eval(shifthours+hours)
  if (dH <0) {dH=24+dH}
  if (dH >=24) {dH=dH-24}
  if (dH<10) {dH='0'+dH}
  tmp=tmp+'<div class="time">'+dH+':'+dM+':'+dS+'</div><div class="city">'+thisplace[0]+'</div><br>'
}
 //var tmN=new Date()
// var dH=''+tmN.getHours();dH=dH.length<2?'0'+dH:dH 
 tmp=tmp+''
 if(NN)d.F.chas.value=tmp;else d.getElementById('tm').innerHTML=tmp
 var t=setTimeout('showTime()',1000)
}


  function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}




$(document).ready(function() {
 //$('#TB_window').tinyscrollbar();

$('#show_code').click(function(){
			
			$('#player_code').show("slow");
			$('#show_code').hide("fast");
			$('#hide_code').show("fast");
			SelectAll('player_code');
			//document.getElementById('player_code').focus();
   			//document.getElementById('player_code').select();
			//$('#player_code').focus();
			//$('#player_code').select();

			//$('.code_player').attr("id","hide_code");
			//$('.code_player').text("Скрыть код плеера");
			
			//document.pcode.code.focus();
 			//document.pcode.code.select();

							 });
$('#hide_code').click(function(){

			$('#player_code').hide("slow");
		    $('#show_code').show("fast");
			$('#hide_code').hide("fast");
			//$('.code_player').attr("id","show_code");
			//$('.code_player').text("Код плеера для вставки на сайт/блог");
			//document.pcode.code.focus();
 			//document.pcode.code.select();

							 });						   
//$('#tvtd').css("width","1000px");			
		//	$('#tvtd').css("height","563px");
		//	$('#tvtable').css("width","1020px");
		//	$('#afisha').hide("fast");
$('.divout').click(function(){

			$('#tvtd').width(998);			
			$('#tvtd').height(563);
			$('#tvtable').width(1020);			
			$('#tvtable').css("float","none");
			$('#tvtable').css("margin-right","0px");

			$('#tvtd').html('<object id="videoplayer5687" type="application/x-shockwave-flash" data="http://pik-tv.com/uppod.swf" width="100%" height="100%"><param name="bgcolor" value="#000000" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://pik-tv.com/uppod.swf" /><param name="flashvars" value="comment=pik_SD&amp;st=s3nzQWVetHIZs92zuGljM1zeQHnlMio0tHpZpioe=SzlbYBdu3hz&amp;file=QRnLQWVet082tjEzbCffbGf9t1mZuxNeQi5ru3T9Qi5rbRn1" /></object>');
			$('.sd').addClass(" active");
			$('.ld').removeClass(" active");
			$('.hd').removeClass(" active");
			$('.apple').removeClass(" active");
			$('#afisha').hide("fast");			
				
					});
$('.divin').click(function(){
			
			$('#tvtd').css("width","696px");
			$('#tvtd').css("height","392px");
			$('#tvtd').html('<object id="videoplayer5687" type="application/x-shockwave-flash" data="http://pik-tv.com/uppod.swf" width="100%" height="100%"><param name="bgcolor" value="#000000" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://pik-tv.com/uppod.swf" /><param name="flashvars" value="comment=pik_SD&amp;st=s3nzQWVetHIZs92zuGljM1zeQHnlMio0tHpZpioe=SzlbYBdu3hz&amp;file=QRnLQWVet082tjEzbCffbGf9t1mZuxNeQi5ru3T9Qi5rbRn1" /></object>');
					});


$('.ld').click(function(){
			$('.ld').addClass(" active");
			$('.sd').removeClass(" active");
			$('.hd').removeClass(" active");
			$('.apple').removeClass(" active");
			
			$('#tvtd').html('<object id="videoplayer5688" type="application/x-shockwave-flash" data="http://pik-tv.com/uppod.swf" width="100%" height="100%"><param name="bgcolor" value="#000000" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://pik-tv.com/uppod.swf" /><param name="flashvars" value="comment=pik_MV&amp;st=s3nzQWVetHIZs92zuGljM1zeQHnlMio0tHpZpioe=SzlbYBdu3hz&amp;file=QRnLQWVet082tjEzbCffbGf9t1mZuxNeQi5ru3TmQi5rbJn1" /></object>');
					});
$('.sd').click(function(){
			$('.sd').addClass(" active");
			$('.ld').removeClass(" active");
			$('.hd').removeClass(" active");
			$('.apple').removeClass(" active");
			
			$('#tvtd').html('<object id="videoplayer5687" type="application/x-shockwave-flash" data="http://pik-tv.com/uppod.swf" width="100%" height="100%"><param name="bgcolor" value="#000000" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://pik-tv.com/uppod.swf" /><param name="flashvars" value="comment=pik_SD&amp;st=s3nzQWVetHIZs92zuGljM1zeQHnlMio0tHpZpioe=SzlbYBdu3hz&amp;file=QRnLQWVet082tjEzbCffbGf9t1mZuxNeQi5ru3T9Qi5rbRn1" /></object>');
					});
$('.hd').click(function(){
			$('.hd').addClass(" active");
			$('.ld').removeClass(" active");
			$('.sd').removeClass(" active");
			$('.apple').removeClass(" active");
			
			$('#tvtd').html('<object id="videoplayer5635" type="application/x-shockwave-flash" data="http://pik-tv.com/uppod.swf" width="100%" height="100%"><param name="bgcolor" value="#000000" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://pik-tv.com/uppod.swf" /><param name="flashvars" value="comment=piktv_HD&amp;st=s3nzQWVetHIZs92zuGljM1zeQHnlMio0tHpZpioe=SzlbYBdu3hz&amp;file=QRnLQWVet082tjEzbCffbGf9t1mZuxNeQi5ru3T0Qi5rbHn1" /></object>');
					});


$('.apple').click(function(){

//$.getScript("js/uppod.js");
$('.hd').removeClass(" active");
$('.ld').removeClass(" active");
$('.sd').removeClass(" active");
$('.apple').addClass(" active");
$('#tvtd').html('<link rel="stylesheet" href="/css/pik-idev.css" type="text/css" media="screen"><div class="video-js-box"><video id="pik-imedia" class="video-js" width="704" height="392" controls poster="http://www.pik-tv.com/images/piktv_700x390.jpg"><source src="http://95.140.82.2/imedia/istream001-250/playlist.m3u8" /></video></div>');
//$.getScript("js/uppod_player.js");
//var speed="ipod";
	//$(location).attr('href',"http://kontakttv.com/index.php?player=ipod");
	});

});


function ctrlEnter(event,id_tag) {
  if((event.ctrlKey) && ((event.keyCode == 13)||(event.keyCode == 10))) {
   $(id_tag).submit();
   
   
  }
}
var ie=document.all?1:0;
var ns=document.getElementById&&!document.all?1:0;

function InsertSmile(SmileId,message,form)
{
    document.forms[form].elements[message].focus();
    document.forms[form].elements[message].value+=" "+SmileId+" ";
}// -->

