var convertorDataFromButton = false;

function populate(idul, textul){
	document.getElementById(idul).innerHTML = textul;
}

var global_linii = Array();

function change_classname_featured(idul, clasa){
	document.getElementById('featured_colt_' + idul).className = 'featured_box_colt' + clasa;
}

function change_classname_content(idul, clasa){
	document.getElementById('content_colt_' + idul).className = 'content_box_colt' + clasa;
	document.getElementById('content_title_' + idul).className = 'content_box_title' + clasa;
	document.getElementById('content_content_' + idul).className = 'content_box_content' + clasa;
	document.getElementById('content_down_' + idul).className = 'content_box_down' + clasa;
	
}

function preload_boxes(){
	img_boxes_0 = new Image();
	img_boxes_0.src = "img/colt_rosu.gif";
	img_boxes_1 = new Image();
	img_boxes_1.src = "img/box_title_gri.gif";
	
	img_0 = new Image();
	img_0.src = "images/down.gif";
	img_1 = new Image();
	img_1.src = "images/down_over.gif";
	img_2 = new Image();
	img_2.src = "images/left.gif";
	img_3 = new Image();
	img_3.src = "images/left_over.gif";
	img_4 = new Image();
	img_4.src = "images/right.gif";
	img_5 = new Image();
	img_5.src = "images/right_over.gif";
	img_6 = new Image();
	img_6.src = "images/close.gif";
	img_7 = new Image();
	img_7.src = "images/close_over.gif";
}

function setDateAzi(data){
	with (document.convertor) {
		data = data.split(".");
		anul.value = parseInt(data[2]);
		luna.value = parseInt(data[1]);
		ziua.value = parseInt(data[0]);
	}
	return false;
}

function checkSubmit(){
	with (document.convertor) {
		if (!isValidDate(anul.value, luna.value, ziua.value)) {
			alert("Data aleasa (" + ((ziua.value < 10) ? "0" + ziua.value : ziua.value) + "." + ((luna.value < 10) ? "0" + luna.value : luna.value) + "." + anul.value + ") nu este valida !");
			return false;
		}
		else 
			if (!isFloat(suma.value.replace(",", "."))) {
				alert('Suma trebuie sa fie o valoare numerica !');
				return false;
			}
		suma.value = suma.value.replace(",", ".");
		submit();
	}
}

function getkey(e){
	if (window.event) 
		return window.event.keyCode;
	else 
		if (e) 
			return e.which;
		else 
			return null;
}

function goodchars(e, goods, unde){
	var key, keychar;
	key = getkey(e);
	if (key == null) 
		return true;
	
	if (unde != undefined) {
		unde.value = unde.value.replace(",", ".");
		if ((key == 46) || (key == 44)) {
			str = unde.value;
			if (str.indexOf(".") != -1) 
				return false;
		}
	}
	
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	if (goods.indexOf(keychar) != -1) 
		return true;
	if (key == null || key == 0 || key == 8 || key == 9 || key == 13 || key == 27) 
		return true;
	return false;
}

function checkConvertorMic(){
	with (document.convertormic) {
	
		var convertit;
		var convertit_cu_tva;
		var convertit_fara_tva;
		var paritate = valuta1.value / valuta2.value;
		
		var valutele = new Array(3);
		valutele[0] = "RON";
		valutele[1] = "EUR";
		valutele[2] = "USD";
		
		convertit = (suma.value * paritate);
		convertit = convertit.toFixed(2);
		convertit_cu_tva = convertit * 1.19;
		convertit_cu_tva = convertit_cu_tva.toFixed(2);
		convertit_fara_tva = convertit_cu_tva - convertit;
		convertit_fara_tva = convertit_fara_tva.toFixed(2);
		
		document.getElementById('mic_rezultat').innerHTML = convertit.toString() + " " + valutele[valuta2.selectedIndex];
		document.getElementById('mic_rezultat_cu_tva').innerHTML = convertit_cu_tva.toString() + " " + valutele[valuta2.selectedIndex];
		document.getElementById('mic_rezultat_doar_tva').innerHTML = convertit_fara_tva.toString() + " " + valutele[valuta2.selectedIndex];
	}
	return false;
}

function scriere_data(sursa, dest, lung){

	data = eval("document." + sursa + ".value");
	
	var data_taiata = data.split("-");
	var anul = data_taiata[0];
	var luna = data_taiata[1];
	var ziua = data_taiata[2];
	var data_rezultat = data_taiata[2] + " ";
	var lunile = new Array();
	
	if (lung) {
		lunile[0] = "ianuarie";
		lunile[1] = "februarie";
		lunile[2] = "martie";
		lunile[3] = "aprilie";
		lunile[4] = "mai";
		lunile[5] = "iunie";
		lunile[6] = "iulie";
		lunile[7] = "august";
		lunile[8] = "septembrie";
		lunile[9] = "octombrie";
		lunile[10] = "noiembrie";
		lunile[11] = "decembrie";
	}
	else {
		lunile[0] = "ian";
		lunile[1] = "feb";
		lunile[2] = "mar";
		lunile[3] = "apr";
		lunile[4] = "mai";
		lunile[5] = "iun";
		lunile[6] = "iul";
		lunile[7] = "aug";
		lunile[8] = "sep";
		lunile[9] = "oct";
		lunile[10] = "noi";
		lunile[11] = "dec";
	}
	switch (luna) {
		case "01":
			data_rezultat = data_rezultat + " " + lunile[0];
			break;
		case "02":
			data_rezultat = data_rezultat + " " + lunile[1];
			break;
		case "03":
			data_rezultat = data_rezultat + " " + lunile[2];
			break;
		case "04":
			data_rezultat = data_rezultat + " " + lunile[3];
			break;
		case "05":
			data_rezultat = data_rezultat + " " + lunile[4];
			break;
		case "06":
			data_rezultat = data_rezultat + " " + lunile[5];
			break;
		case "07":
			data_rezultat = data_rezultat + " " + lunile[6];
			break;
		case "08":
			data_rezultat = data_rezultat + " " + lunile[7];
			break;
		case "09":
			data_rezultat = data_rezultat + " " + lunile[8];
			break;
		case "10":
			data_rezultat = data_rezultat + " " + lunile[9];
			break;
		case "11":
			data_rezultat = data_rezultat + " " + lunile[10];
			break;
		case "12":
			data_rezultat = data_rezultat + " " + lunile[11];
			break;
	}
	
	data_rezultat = data_rezultat + " " + data_taiata[0];
	
	document.getElementById(dest).innerHTML = data_rezultat;
}

function verifica_suma_convertor(){
	if ((document.convertormare.suma_mare.value == '') || (document.convertormare.suma_mare.value == '0')) {
		alert("Introduceti o suma valida!");
		return false;
	}
	return true;
}

function verifica_iban(){
	if ((document.form_iban.nriban.value == '') || (document.convertormare.suma_mare.value == '0')) {
		alert("Introduceti codul IBAN!");
		return false;
	}
	return true;
}

function verifica_cnp(){
	if ((document.form_cnp.cod_cnp.value == '') || (document.convertormare.suma_mare.value == '0')) {
		alert("Introduceti CNP!");
		return false;
	}
	return true;
}

function cross_table_over(tabel, lin, col, culoare, textCol, deselect){ // cb1, 1, 1.
	var idul;
	id_tabel = "cb" + tabel;
	tabelul = document.getElementById(id_tabel);
	nr_lin = tabelul.rows.length;
	nr_lin = nr_lin - global_linii[tabel];
	nr_col = tabelul.rows[1].cells.length;
	if (col != null) 
		for (i = 1; i < nr_lin; i++) {
			idul = id_tabel + "_" + i + "_" + col;
			document.getElementById(idul).style.backgroundColor = culoare;
			document.getElementById(idul).style.color = textCol;
		}
	if (lin != null) 
		for (i = 1; i < nr_col; i++) {
			idul = id_tabel + "_" + lin + "_" + i;
			document.getElementById(idul).style.backgroundColor = culoare;
			document.getElementById(idul).style.color = textCol;
		}
	if (lin != null && col != null) 
		if (!deselect) {
			idul = id_tabel + "_" + lin + "_" + col;
			document.getElementById(idul).style.backgroundColor = "#DADADA";
		}
}

function schimba_rss(valoare){
	document.getElementById("content_rss_preluat").innerHTML = valoare;
}

function verifica_alerta(){
	valoare = document.form_alerta.email.value;
	if (!isEmail(valoare)) {
		alert("Adresa de e-mail invalida!");
		return false;
	}
	for (var i = 0; i < document.form_alerta.elements.length; i++) {
		if (document.form_alerta.elements[i].type == 'checkbox') 
			if (document.form_alerta.elements[i].checked) {
				return true;
			}
	}
	alert("Trebuie sa bifati cel putin o valuta pentru alerta!");
	return false;
}

function bifeaza_valuta(valuta){
	eval("document.form_alerta." + valuta + ".checked=true");
}

/***********************************************
 * Cool DHTML tooltip script II- © 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
 ***********************************************/
var offsetfromcursorX = 12 //Customize x offset of tooltip
var offsetfromcursorY = 10 //Customize y offset of tooltip
var offsetdivfrompointerX = 10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY = 14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).
document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="img/arrow2.gif">') //write out pointer image
var ie = document.all
var ns6 = document.getElementById && !document.all
var enabletip = false
if (ie || ns6) 
	var tipobj = document.all ? document.all["dhtmltooltip"] : document.getElementById ? document.getElementById("dhtmltooltip") : ""

var pointerobj = document.all ? document.all["dhtmlpointer"] : document.getElementById ? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
	return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
	if (ns6 || ie) {
		if (typeof thewidth != "undefined") 
			tipobj.style.width = thewidth + "px"
		if (typeof thecolor != "undefined" && thecolor != "") 
			tipobj.style.backgroundColor = thecolor
		tipobj.innerHTML = thetext
		enabletip = true
		return false
	}
}

function positiontip(e){
	if (enabletip) {
		var nondefaultpos = false
		var curX = (ns6) ? e.pageX : event.clientX + ietruebody().scrollLeft;
		var curY = (ns6) ? e.pageY : event.clientY + ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var winwidth = ie && !window.opera ? ietruebody().clientWidth : window.innerWidth - 20
		var winheight = ie && !window.opera ? ietruebody().clientHeight : window.innerHeight - 20
		
		var rightedge = ie && !window.opera ? winwidth - event.clientX - offsetfromcursorX : winwidth - e.clientX - offsetfromcursorX
		var bottomedge = ie && !window.opera ? winheight - event.clientY - offsetfromcursorY : winheight - e.clientY - offsetfromcursorY
		
		var leftedge = (offsetfromcursorX < 0) ? offsetfromcursorX * (-1) : -1000
		
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge < tipobj.offsetWidth) {
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left = curX - tipobj.offsetWidth + "px"
			nondefaultpos = true
		}
		else 
			if (curX < leftedge) 
				tipobj.style.left = "5px"
			else {
				//position the horizontal position of the menu where the mouse is positioned
				tipobj.style.left = curX + offsetfromcursorX - offsetdivfrompointerX + "px"
				pointerobj.style.left = curX + offsetfromcursorX + "px"
			}
		
		//same concept with the vertical position
		if (bottomedge < tipobj.offsetHeight) {
			tipobj.style.top = curY - tipobj.offsetHeight - offsetfromcursorY + "px"
			nondefaultpos = true
		}
		else {
			tipobj.style.top = curY + offsetfromcursorY + offsetdivfrompointerY + "px"
			pointerobj.style.top = curY + offsetfromcursorY + "px"
		}
		tipobj.style.visibility = "visible"
		if (!nondefaultpos) 
			pointerobj.style.visibility = "visible"
		else 
			pointerobj.style.visibility = "hidden"
	}
}

function hideddrivetip(){
	if (ns6 || ie) {
		enabletip = false
		tipobj.style.visibility = "hidden"
		pointerobj.style.visibility = "hidden"
		tipobj.style.left = "-1000px"
		tipobj.style.backgroundColor = ''
		tipobj.style.width = ''
	}
}

document.onmousemove = positiontip



/***************************************************************************************
 SWFOBJECT
 **************************************************************************************/
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if (typeof deconcept == "undefined") {
	var deconcept = new Object();
}
if (typeof deconcept.util == "undefined") {
	deconcept.util = new Object();
}
if (typeof deconcept.SWFObjectUtil == "undefined") {
	deconcept.SWFObjectUtil = new Object();
}
deconcept.SWFObject = function(_1, id, w, h, _5, c, _7, _8, _9, _a){
	if (!document.getElementById) {
		return;
	}
	this.DETECT_KEY = _a ? _a : "detectflash";
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if (_1) {
		this.setAttribute("swf", _1);
	}
	if (id) {
		this.setAttribute("id", id);
	}
	if (w) {
		this.setAttribute("width", w);
	}
	if (h) {
		this.setAttribute("height", h);
	}
	if (_5) {
		this.setAttribute("version", new deconcept.PlayerVersion(_5.toString().split(".")));
	}
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		deconcept.SWFObject.doPrepUnload = true;
	}
	if (c) {
		this.addParam("bgcolor", c);
	}
	var q = _7 ? _7 : "high";
	this.addParam("quality", q);
	this.setAttribute("useExpressInstall", false);
	this.setAttribute("doExpressInstall", false);
	var _c = (_8) ? _8 : window.location;
	this.setAttribute("xiRedirectUrl", _c);
	this.setAttribute("redirectUrl", "");
	if (_9) {
		this.setAttribute("redirectUrl", _9);
	}
};
deconcept.SWFObject.prototype = {
	useExpressInstall: function(_d){
		this.xiSWFPath = !_d ? "expressinstall.swf" : _d;
		this.setAttribute("useExpressInstall", true);
	},
	setAttribute: function(_e, _f){
		this.attributes[_e] = _f;
	},
	getAttribute: function(_10){
		return this.attributes[_10];
	},
	addParam: function(_11, _12){
		this.params[_11] = _12;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(_13, _14){
		this.variables[_13] = _14;
	},
	getVariable: function(_15){
		return this.variables[_15];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var _16 = new Array();
		var key;
		var _18 = this.getVariables();
		for (key in _18) {
			_16[_16.length] = key + "=" + _18[key];
		}
		return _16;
	},
	getSWFHTML: function(){
		var _19 = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute("swf", this.xiSWFPath);
			}
			_19 = "<embed type=\"application/x-shockwave-flash\" src=\"" + this.getAttribute("swf") + "\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\"";
			_19 += " id=\"" + this.getAttribute("id") + "\" name=\"" + this.getAttribute("id") + "\" ";
			var _1a = this.getParams();
			for (var key in _1a) {
				_19 +=[key]  + "=\"" + _1a[key] + "\" ";
			}
			var _1c = this.getVariablePairs().join("&");
			if (_1c.length > 0) {
				_19 += "flashvars=\"" + _1c + "\"";
			}
			_19 += "/>";
		}
		else {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute("swf", this.xiSWFPath);
			}
			_19 = "<object id=\"" + this.getAttribute("id") + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\">";
			_19 += "<param name=\"movie\" value=\"" + this.getAttribute("swf") + "\" />";
			var _1d = this.getParams();
			for (var key in _1d) {
				_19 += "<param name=\"" + key + "\" value=\"" + _1d[key] + "\" />";
			}
			var _1f = this.getVariablePairs().join("&");
			if (_1f.length > 0) {
				_19 += "<param name=\"flashvars\" value=\"" + _1f + "\" />";
			}
			_19 += "</object>";
		}
		return _19;
	},
	write: function(_20){
		if (this.getAttribute("useExpressInstall")) {
			var _21 = new deconcept.PlayerVersion([6, 0, 65]);
			if (this.installedVer.versionIsValid(_21) && !this.installedVer.versionIsValid(this.getAttribute("version"))) {
				this.setAttribute("doExpressInstall", true);
				this.addVariable("MMredirectURL", escape(this.getAttribute("xiRedirectUrl")));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if (this.skipDetect || this.getAttribute("doExpressInstall") || this.installedVer.versionIsValid(this.getAttribute("version"))) {
			var n = (typeof _20 == "string") ? document.getElementById(_20) : _20;
			n.innerHTML = this.getSWFHTML();
			return true;
		}
		else {
			if (this.getAttribute("redirectUrl") != "") {
				document.location.replace(this.getAttribute("redirectUrl"));
			}
		}
		return false;
	}
};
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var _23 = new deconcept.PlayerVersion([0, 0, 0]);
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if (x && x.description) {
			_23 = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}
	else {
		if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) {
			var axo = 1;
			var _26 = 3;
			while (axo) {
				try {
					_26++;
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + _26);
					_23 = new deconcept.PlayerVersion([_26, 0, 0]);
				} 
				catch (e) {
					axo = null;
				}
			}
		}
		else {
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			} 
			catch (e) {
				try {
					var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					_23 = new deconcept.PlayerVersion([6, 0, 21]);
					axo.AllowScriptAccess = "always";
				} 
				catch (e) {
					if (_23.major == 6) {
						return _23;
					}
				}
				try {
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				} 
				catch (e) {
				}
			}
			if (axo != null) {
				_23 = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
			}
		}
	}
	return _23;
};
deconcept.PlayerVersion = function(_29){
	this.major = _29[0] != null ? parseInt(_29[0]) : 0;
	this.minor = _29[1] != null ? parseInt(_29[1]) : 0;
	this.rev = _29[2] != null ? parseInt(_29[2]) : 0;
};
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if (this.major < fv.major) {
		return false;
	}
	if (this.major > fv.major) {
		return true;
	}
	if (this.minor < fv.minor) {
		return false;
	}
	if (this.minor > fv.minor) {
		return true;
	}
	if (this.rev < fv.rev) {
		return false;
	}
	return true;
};
deconcept.util = {
	getRequestParameter: function(_2b){
		var q = document.location.search || document.location.hash;
		if (_2b == null) {
			return q;
		}
		if (q) {
			var _2d = q.substring(1).split("&");
			for (var i = 0; i < _2d.length; i++) {
				if (_2d[i].substring(0, _2d[i].indexOf("=")) == _2b) {
					return _2d[i].substring((_2d[i].indexOf("=") + 1));
				}
			}
		}
		return "";
	}
};
deconcept.SWFObjectUtil.cleanupSWFs = function(){
	var _2f = document.getElementsByTagName("OBJECT");
	for (var i = _2f.length - 1; i >= 0; i--) {
		_2f[i].style.display = "none";
		for (var x in _2f[i]) {
			if (typeof _2f[i][x] == "function") {
				_2f[i][x] = function(){
				};
			}
		}
	}
};
if (deconcept.SWFObject.doPrepUnload) {
	if (!deconcept.unloadSet) {
		deconcept.SWFObjectUtil.prepUnload = function(){
			__flash_unloadHandler = function(){
			};
			__flash_savedUnloadHandler = function(){
			};
			window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
		};
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet = true;
	}
}
if (!document.getElementById && document.all) {
	document.getElementById = function(id){
		return document.all[id];
	};
}
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject;
var SWFObject = deconcept.SWFObject;

/**************************************************************************************/
