
//======================================[AJAX]============================
function GetXmlHttpObject_ajax() {
	var xmlHttp=null;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
function $ajax(ajaxfile,ajaxurl,ajaxaction,otherfunction) {
	var xmlHttp=GetXmlHttpObject_ajax();
	xmlHttp.open("GET",ajaxfile+'?nocache='+Math.random()+'&'+ajaxurl);
	xmlHttp.onreadystatechange=function () {
		if (xmlHttp.readyState==4) {
			if(typeof(ajaxaction)=='function') {
				ajaxaction(xmlHttp.responseText);
			} else if (typeof(ajaxaction)=='string') {
				if(document.getElementById(ajaxaction)) {
					document.getElementById(ajaxaction).innerHTML=xmlHttp.responseText;
				} else {
					alert(xmlHttp.responseText);
				}
				$json(ajaxaction);
				otherfunction(xmlHttp.responseText);
			} else {
				ajaxaction.innerHTML=xmlHttp.responseText;
				$json(ajaxaction);
			}
		}
	}
	xmlHttp.send(null);
}
//===========================================================================
// Eroare daca nu exista elementul
function ErrorNoId(cine) {
	alert(' Reporniti browsetrul \n\r elementul '+cine+' nu exista ! ');
	return false;
}
// Get By Id
function byid(id){
	try{
		return document.getElementById(id);
	}
	catch(e){
		ErrorNoId(id);
	}
}
// Get By Name
function byname(name){
	try{
		return document.getElementsByName(name);
	}
	catch(e){
		ErrorNoId(name);
	}
}
function $v(id,val){
	try{
		document.getElementById(id).value=val;
		return true;
	}
	catch(e){
		ErrorNoId(id);
	}
}
function $val(id){
	try{
		return document.getElementById(id).value;
	}
	catch(e){
		ErrorNoId(id);
	}
}
function $json(id){
	$id('script','type','text/javascript',id).each(function (obj) { eval(obj.innerHTML); } );
}
function $get(campuri) {
	var get='';
	var first='';
	if (typeof(campuri)=='string')  return campuri+'='+$id(campuri).val();
	for (var i=0; i<campuri.length; i++){
		if (i>0) first='&';
		get+=first+campuri[i]+'='+$id(campuri[i]).val();
	}
	return get;
}


function $id(id,atr,valoare,start) {
	if (id!=null) return new $id().init(id,atr,valoare,start);
	this.init = function (id,atr,valoare,start) {
		this.tags=[];
		this.first_id;
		this.last_id;
		this.id;
		this.no_each=false;
		if (typeof(id)=='string') {
			if (typeof(start)=='string') start=byid(start);
			if (start==null) start=document;
			var tagurile = start.getElementsByTagName(id);
			var j=0;
			for (var i=0; i<tagurile.length; i++){
				var tag = tagurile[i];
				if (atr==null) {
					this.tags[j]=tag;
					this.last_id=tag;
					j++;
				} else {
					if (tag[atr] == valoare){
						this.tags[j]=tag;
						this.last_id=tag;
						j++;
					}
				}
			}
			this.first_id=this.tags[0];
			if (j==0) {
				this.id=byid(id);
				this.no_each=true;
			}
		}
		else {
			this.id=id;
			this.no_each=true;
		}
		return this;
	}
	this.css=function (atribut,valoare) {
		if (valoare==null && typeof(atribut)=='string') {
			return this.id.style[atribut];
		}
		return this.each(function (obj){
			if (valoare==null) {
				for (var key in atribut) {
					obj.style[key]=atribut[key];
				}
			} else {
				obj.style[atribut]=valoare;
			}
		});
	}
	this.replace=function (atribut,inlocuitor) {
		return this.each(function (obj,i){
			if(typeof(inlocuitor)=='function') {
				obj[atribut]=function () {
					inlocuitor(this,i);
				};
			}else{
				obj[atribut]=inlocuitor;
			}
		});
	}
	this.html=function (continut) {
		if (continut==null) return this.id.innerHTML;
		return this.each(function (obj){
			obj.innerHTML=continut;
		});
	}
	this.load=function (ajaxfile,otherfunction) {
		if (otherfunction==null) otherfunction=function () {};
		ajax_file_url=ajaxfile.split('?');
		$ajax(ajax_file_url[0],ajax_file_url[1],this.id,otherfunction);
		return this;
	}
	this.val=function (valoare) {
		if (valoare==null) return this.id.value;
		this.id.value=valoare;
		return this;
	}
	this.show=function () {
		return this.each(function (obj){
			obj.style.display='block';
		});
	}
	this.hide=function () {
		return this.each(function (obj){
			obj.style.display='none';
		});
	}
	this.clasa=function (valoare) {
		if (valoare==null) return this.id.className;
		return this.each(function (obj){
			obj.className=valoare;
		});
	}
	this.append=function (code) {
		return this.each(function (obj){
			var div_code = document.createElement("div");
			obj.appendChild(div_code);
			div_code.innerHTML=code;
		});
	}
	this.apptop=function (code) {
		return this.each(function (obj){
			var div_code = document.createElement("div");
			div_code.innerHTML=code;
			obj.insertBefore(div_code, obj.firstChild);
		});
	}
	this.appbefore=function (code) {
		return this.each(function (obj){
			var div_code = document.createElement("div");
			div_code.innerHTML=code;
			obj.parentNode.insertBefore(div_code, obj);
		});
	}
	this.appafeter=function (code) {
		return this.each(function (obj){
			var div_code = document.createElement("div");
			div_code.innerHTML=code;
			obj.parentNode.insertBefore(div_code, obj.nextSibling);
		});
	}
	this.remove = function () {
		return this.each(function (obj){
			obj.parentNode.removeChild(obj);
		});
	}
	this.tag = function (id) {
		if (id==null) id=0;
		this.id=this.tags[id];
		this.no_each=true;
		return this;
	}
	this.first = function (id) {
		this.id=this.first_id;
		this.no_each=true;
		return this;
	}
	this.last = function (id) {
		this.id=this.last_id;
		this.no_each=true;
		return this;
	}
	this.all = function() {
		this.no_each=false;
		return this;
	}
	this.each = function (functie) {
		if (this.no_each==true) {
			if (this.id!=null) functie (this.id,i);
		} else {
			for (var i=0; i<this.tags.length; i++){
				functie (this.tags[i],i);
			}
		}
		return this;
	}
	this.extend=function(nume,functie) {
		this[nume]=functie;
	}
	return this;
}



function flow_player() {

	$f("player", BASEHREF+"flow/flowplayer.commercial-3.1.0.swf", {

		clip: {
			autoPlay: true,
			autoBuffering: true
			//			scaling:'orig'
		},
		key: '$b692ba1aa93bca2f1da',
		plugins: {

			controls: {
				sliderColor: '#20202d',
				buttonColor: '#5F747C',
				timeBgColor: '#555555',
				bufferGradient: 'none',
				progressColor: '#0961ae',
				buttonOverColor: '#728B94',
				timeColor: '#01DAFF',
				backgroundColor: '#000000',
				bufferColor: '#445566',
				volumeSliderGradient: 'none',
				volumeSliderColor: '#000000',
				tooltipTextColor: '#ffffff',
				tooltipColor: '#5F747C',
				sliderGradient: 'none',
				progressGradient: 'medium',
				backgroundGradient: 'low',
				borderRadius: '5',
				durationColor: '#ffffff',
				height: 20,
				opacity: 1.0

			}


		},

		logo: {

url: '/images/logo_2.png',

fullscreenOnly: false,

//top: '5',
bottom: '35',
 //opacity: 0.7,
right: '5',

width: '100px',
height: '89px',

displayTime: 0,

linkUrl: '/'

}


	});


	var code = $f().embed().getEmbedCode();

	//var t=setTimeout(function() {document.getElementById("id_embed").innerHTML=code; } ,100);


//document.write("<div style='float:left;width:120px;'>");

//document.write("</div><div style='float:left;width:420px;padding-top:14px;'>");
//document.write("<a href=''><img src='images/yahoo_over.png'style='margin:8px;' /></a>");
//document.write("<a href=''><img src='images/favorites.png'style='margin:8px;height:60px;' /></a>");
//document.write("</div><div style='clear:both;'>");



	document.write("<br /><textarea class='get_code'  style='width:500px;overflow:hidden;float:left;'  onclick='this.select();' >"+code+"</textarea>");
	document.write("<img src='images/full_hd_1.png' height=44 style='margin-left:8px;float:left;' />");

}
function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function aceepta_18_ani() {
	setCookie('am_18_ani','DA',1);
	$("#window_alerta").dialog( 'close' );
}

function verifica_18() {
	var am_18_ani=getCookie('am_18_ani');
	if (am_18_ani!='DA') {
		var text="";
		text+="<center> Pentru accesarea acestei sectiuni este necesar sa confirmati daca aveti peste 18 ani <br/><br/>";
		text+="<span style='color:red'>+18</span>  <a href='javascript: aceepta_18_ani();' class='ui-state-default ui-corner-all'> &nbsp;  Da, am &nbsp;  </a> &nbsp; &nbsp;  <a href='http://auto-tv.ro/home' class='ui-state-default ui-corner-all'> &nbsp; Nu &nbsp;  </a>" ;
		text+="</center> ";
		alerta(text);
	}
}