﻿/*********************  START first page main tabs *********************/

function preloader()
{
    // preload the 11 large images
    i1 = new Image(); 
    i1.src = "../_img/img_large/1.jpg";
    i2 = new Image(); 
    i2.src = "../_img/img_large.2.jpg";
    i3 = new Image(); 
    i3.src = "../_img/img_large.3.jpg";
    i4 = new Image(); 
    i4.src = "../_img/img_large.4.jpg";
    i5 = new Image(); 
    i5.src = "../_img/img_large.5.jpg";
    i6 = new Image(); 
    i6.src = "../_img/img_large.6.jpg";
    i7 = new Image(); 
    i7.src = "../_img/img_large.7.jpg";
    i8 = new Image(); 
    i8.src = "../_img/img_large.8.jpg";
    i9 = new Image(); 
    i9.src = "../_img/img_large.9.jpg";
    i10 = new Image(); 
    i10.src = "../_img/img_large.10.jpg";
    i11 = new Image(); 
    i11.src = "../_img/img_large.11.jpg";
}

// ***************************** 11 tabs & large images timer *************************
var timer1 = 0;
function sel_tabs(current_tab)
{
    if (current_tab.length == 10)   // main_tab_1    sau     main_tab_11
        x = 1;  // div id = main_tab_x
    else
        x = 2;  // div id = main_tab_xy
    current_tab_number = current_tab.substr(current_tab.length - x, x) * 1; // get the tab number: main_tab_3 => 3
    //current_tab_number = current_tab * 1;                               // convert string to int
    if (current_tab_number <= 6)
        document.getElementById(current_tab).className = 'large_tabs_a2';    // deselect current tab (0-6)
    else
        document.getElementById(current_tab).className = 'large_tabs_a';    // deselect current tab (7-11)
    next_tab_number = current_tab_number + 1;                           // get next tab number
    if (next_tab_number == 12)
        next_tab_number = 1;
    next_tab = "main_tab_" + next_tab_number;
    if (next_tab_number <= 6)
        document.getElementById(next_tab).className = 'large_tabs_a2_sel';   // select next tab (0-6)
    else
        document.getElementById(next_tab).className = 'large_tabs_a_sel';   // select next tab (7-11)
    // change image
    new_background = "url('_img/img_large/";
    new_background += next_tab_number;
    new_background += ".jpg')";
    document.getElementById('large_img').style.background = new_background;
    timer1 = setTimeout("sel_tabs(next_tab);",3000);                    // 3000 miliseconds
}

function sel_tab(current_tab)
{
    if (timer1)
    {
        clearTimeout(timer1);
        timer1 = 0;
    }
    // reset style
    for (var i = 1; i < 7; i++)
    {
        tab = "main_tab_" + i;
        document.getElementById(tab).className = 'large_tabs_a2';    // deselect tab (0-6)
    }
    for (var i = 7; i < 12; i++)
    {
        tab = "main_tab_" + i;
        document.getElementById(tab).className = 'large_tabs_a';    // deselect tab (7-11)
    }
    // change image
    if (current_tab.length == 10)   // main_tab_1    sau     main_tab_11
        x = 1;  // div id = main_tab_x
    else
        x = 2;  // div id = main_tab_xy
    current_tab_number = current_tab.substr(current_tab.length - x, x) * 1; // get the tab number: main_tab_3 => 3
    new_background = "url('_img/img_large/";
    new_background += current_tab_number;
    new_background += ".jpg')";
    document.getElementById('large_img').style.background = new_background;
}
// ***************************** 11 tabs & large images timer *************************

// ***************************** news headlines timer *************************
var timernews__ = 0;
var news_index__ = 0;
var current_clr = "#ddd";

function tick__()
{
    scroll__();	// scroll (number of pixels)
    if (current_clr == '#333')
    {
		timernews__ = setTimeout("tick__();",3000);	// how long the link remains visible
	}
	else
	{
	    timernews__ = setTimeout("tick__();",100);	// how fast the link scrolls up
    }
}

function scroll__()
{
	switch (current_clr)
	{
		case "#ddd":
		{
			current_clr = "#ccc";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#ccc":
		{
			current_clr = "#bbb";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#bbb":
		{
			current_clr = "#aaa";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#aaa":
		{
			current_clr = "#999";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#999":
		{
			current_clr = "#888";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#888":
		{
			current_clr = "#777";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#777":
		{
			current_clr = "#666";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#666":
		{
			current_clr = "#555";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#555":
		{
			current_clr = "#444";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
		case "#444":
		{
			current_clr = "#333";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}

		case "#333":
		{
			if (news_index__ < news_titles.length - 1)
			{
				news_index__ = news_index__ + 1;
				document.getElementById('newslink__').innerHTML = "Stiri: " + news_titles[news_index__];
				document.getElementById('newslink__').href = news_href[news_index__];
				document.getElementById('newslink__').title = "Stiri: " + news_titles[news_index__];
			}
			else
			{
				news_index__ = 0;
				document.getElementById('newslink__').innerHTML = "Stiri: " + news_titles[news_index__];
			    document.getElementById('newslink__').href = news_href[news_index__];
			    document.getElementById('newslink__').title = "Stiri: " + news_titles[news_index__];
			}
			current_clr = "#ddd";
			document.getElementById('newslink__').style.color = current_clr;
			break;
		}
	}
}

function stoptick__()
{
    if (timernews__)
	{
        	clearTimeout(timernews__);
        	timernews__ = 0;
        }
}

function setnewslink__()
{
	news_index__ = 0;
	document.getElementById('newslink__').innerHTML = news_titles[news_index__];
	document.getElementById('newslink__').href = news_href[news_index__];
	document.getElementById('newslink__').title = "Stiri: " + news_titles[news_index__];
	//document.links["link"].href = news_titles[news_index];	// cross browser solution ?!?
}

// ***************************** news headlines timer *************************

// ******************************************************* NEWS START

//remove_broken_news_images not used any more
function remove_broken_news_images()  // when using the Repeater, i set the src for the img_left
{   // images: "http://decitequipmentscms.keysys.ro/_files_news/" + whatever is in the database field, even if it is ""
    if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.content = document.getElementById("main_section_div");
	this.images = this.content.getElementsByTagName("img");
	for (var i = 0; i < this.images.length; i++)
	{
	    if ((this.images[i].src.toLowerCase().search(".jpg") == -1) && (this.images[i].src.toLowerCase().search(".jpeg") == -1) && (this.images[i].src.toLowerCase().search(".gif") == -1) && (this.images[i].src.toLowerCase().search(".png") == -1))
            this.images[i].style.display = 'none';
    }
}

function news_show_calendar()
{
    // create article
    var s = "";
    s += "<div class='news_date'>ianuarie&nbsp;2008</div>";
    s += "<div class='news_title'>Program expozitional 2008</div>";
    s += "<p>Pe toti cei care doresc sa descopere si sa cunoasca cele mai noi <span class='mov'>produse distribuite</span>, precum si afle mai multe detalii despre <span class='mov'>solutiile IT si sistemele de securitate</span> dezvoltate de DEC in premiera pentru segmentul turistic/de productie/de comert distributie/de comert retail/ constructii/ transporturi/ autoritati publice, ii invitam sa ne fie alaturi la urmatoarele manifestari expozitionale:</p>";
    s += "<ul>";
    s += "<li>";
    s += "<div class='news_subtitle_small'>CeBIT 4-9 martie 2008, Hanovra (DE)</div>";
    s += "Cel mai renumit targ al inovatiilor in tehnologia informatiei si comunicatiilor din lume, DEC participa pentru a doua oara consecutiv si prezinta gama de solutii IT si sisteme de securitate dezvoltate.";
    s += "</li>";
    s += "<li>";
    s += "<div class='news_subtitle_small'>Targul de Turism al Romaniei 27-30 martie 2008, Bucuresti (RO)</div>";
    s += "expozitie internationala de servicii si oferte turistice, IT si sisteme de rezervari, invatamant si formare profesionala in turism. Editia a XIX-a.";
    s += "</li>";
    s += "<li>";
    s += "<div class='news_subtitle_small'>Expo SECURITY 21-24 aprilie 2008, Bucuresti (RO)</div>";
    s += "Expozitie Internationala pentru sisteme de securitate, politie, alarmare, protectie civila contra incendiilor si dezastrelor. Editia a XI-a.";
    s += "</li>";
    s += "<li>";
    s += "<div class='news_subtitle_small'>ROMHOTEL 23-26 octombrie 2008, Bucuresti (RO)</div>";
    s += "expozitie internationala de arhitectura, echipamente, mobilier si dotari pentru hoteluri si restaurante. Editia a XVI-a.";
    s += "</li>";
    s += "<li>";
    s += "<div class='news_subtitle_small'>PROSHOP 5-9 noiembrie 2008, Bucuresti (RO)</div>";
    s += "expozitie internationala pentru dotarea magazinelor, prezentarea marfurilor si promovarea vanzarilor. Editia a VIII-a.";
    s += "</li>";
    s += "</ul>";
    document.getElementById('news_current_content').innerHTML = s;
}
// ******************************************************* NEWS STOP

// ******************************************************* ABOUT US START

function sel_about(i)    // id about
{
    var s = "";
    switch (i)
    {
        case 0:
        {
            s += "<div class='news_title'>Despre DEC</div>";
            s += "<p><b>DEC</b> este o companie inovatoare specializata in dezvoltarea de solutii IT de securitate, cu una dintre cele mai indelungate experiente din Romania in acest domeniu. Infiintata in 1991, <b>DEC</b> are un portofoliu impresionant de parteneri care au beneficiat alegand solutiile noastre IT la cheie.</p>";
            s += "<p>DEC este specializata pe <b>sisteme de securitate</b> (<span class='mov'>control acces, supraveghere video</span>) si <b>solutii IT de management specific</b> (<span class='mov'>pontaj, ticketing pentru ski/spa/strand/parcare/expo, control acces hotelier, si vanzari mobile-SFA</span>).</p>";
            s += "<p><b>DEC</b> ofera atat <b>servicii de dezvoltare aplicatii software</b> si de <b>integrare de sisteme</b>, cat si <b>solutii IT la cheie</b> dezvoltate conform <b>specificului fiecarui client</b>, asigurand astfel indeplinirea tintita a nevoilor de <b>management</b> eficient al <b>resurselor umane, <b>controlul</b> eficient al fluxului de vizitatori</b>, cat si <b>securitatea organizatiei</b> precum si <b>eliminarea</b> posibilelor situatii de <b>frauda</b> din afara sau din interiorul organizatiei.</p>";
            s += "<p>Totodata, DEC a intregit si lansat la distributie pe piata din Romania un <b>portofoliu de echipamente</b> (specifice solutiilor IT) de inalta calitate si promovand <b>cele mai noi tehnologii</b>. Pe baza experientei ca dezvoltator de solutii la cheie, si avand alaturi parteneri internationali strategici, DEC va oferi suport in accesul la tehnologia de varf inglobata in produsele sale distribuite tuturor partenerilor din canalul de distributie, integratorilor de proiecte si utilizatorilor finali.</p>";
            s += "<div class='news_subtitle'>Certificari</div>";
            s += "<p>Certificarile obtinute de DEC impreuna cu aliantele cu parteneri internationali puternici sunt recunoasteri clare ale competentelor si expertizei noastre.</p>";
            s += "<p><b>DEC</b> este partener <b><span class='mov_bold'>Microsoft</span> Gold Certified</b> iar competentele recunoscute de Microsoft sunt <b>ISV/Software Solutions</b> si <b>Networking Infrastructure Solutions</b>. <b>DEC</b> este partener (<b>Associate Member</b>) in programul <b><span class='mov_bold'>Intel</span>® Channel Partner</b> si deopotriva partener Intel in programul <b>Intel Inside&reg;</b>. In plus, <b>DEC</b> este si partener <span class='mov_bold'>IBM</span> in programul <b>Built On Express Advantage</b>.</p>";
            s += "<p>Pentru a veni in intampinarea clientilor sai, <b>DEC</b> a implementat sistemul de management al calitatii, obtinand certificarea <b>ISO 9001:2000</b> de la <b>IQNet</b>.</p>";
            s += "<div id='prezentare_certificari'>";
            s += "<img src='_img/prezentare_certificari/microsoft_gold_isv.jpg' alt='Microsoft Gold Certified Partner' title='Microsoft Gold Certified Partner' />";
	    s += "<img src='_img/prezentare_certificari/cisco_registered_partner.gif' alt='CISCO Registered Partner' title='CISCO Registered Partner' />";
            s += "<img src='_img/prezentare_certificari/intel_channel_partner_program.jpg' alt='Intel Channel Partner Program' title='Intel Channel Partner Program' />";
            s += "<img src='_img/prezentare_certificari/built_on_ea_offerings_rgb.jpg' alt='IBM express advantage' title='IBM express advantage' />";
            s += "<img src='_img/prezentare_certificari/iso_ro.jpg' alt='ISO' title='ISO' />";
            s += "</div>";
            break;
        }
        case 1:
        {
            s += "<div class='news_title'>Parteneri</div>";
            s += "<div>";
            s += "<div style='background:url(_img/produs_table_separator.jpg) no-repeat left bottom; margin-bottom:10px;'><p style='background:url(_img/prezentare_parteneri/logo_advantech.jpg) no-repeat top left; padding-left:210px; padding-bottom:10px;'><b>ADVANTECH</b> este producatorul principal de echipamente pentru produsele si serviciile inovative ale ePlatform, inca din 1983. Inovator prin definitie, ADVANTECH ofera <b>platforme de computer</b> de inalta calitate si performanta la care adauga servicii de customizare cu valoare adaugata pentru integratori de solutii.</p></div>";
            s += "<div style='background:url(_img/produs_table_separator.jpg) no-repeat left bottom; margin-bottom:10px;'><p style='background:url(_img/prezentare_parteneri/logo_arecont.jpg) no-repeat top left; padding-left:210px; padding-bottom:10px;'><b>ARECONT VISION</b> este lider in fabricarea camerelor megapixel cu IP de inalta performanta. <b>ARECONT VISION</b> este o companie multinationala, cu sediul in Canada, si reprezentante in SUA si Rusia, ocupandu-se cu <b>dezvoltarea si fabricarea de sisteme de supraveghere video multi-megapixel, in timp real</b>.</p></div>";
            s += "<div style='background:url(_img/produs_table_separator.jpg) no-repeat left bottom; margin-bottom:10px;'><p style='background:url(_img/prezentare_parteneri/logo_custom.jpg) no-repeat top left; padding-left:210px; padding-bottom:10px;'><b>CUSTOM</b> este o companie multinationala infiintata in 1992 in Italia, si avand astfel o experienta indelungata in dezvoltarea de produse mechatronice. CUSTOM este lider european ca furnizor de echipamente: <b>POS</b> (<b>Points of Sale</b> – Puncte de vanzare), <b>OEM</b> (<b>Original Equipment Manufacturer</b>) si <b>GLB</b> (<b>Gamming Lottery Betting</b> – Loterie si Pariuri). Inca de la inceput, tinta CUSTOM este ca toate etapele technice, proiectele electronice si mecanice, driverele si utilitarele sa fie realizate intern, in cadrul companiei.</p></div>";
            s += "<div style='background:url(_img/produs_table_separator.jpg) no-repeat left bottom; margin-bottom:10px;'><p style='background:url(_img/prezentare_parteneri/logo_kaba.jpg) no-repeat top left; padding-left:210px; padding-bottom:10px;'><b>KABA</b> este unul din cei mai mari jucatori ai industriei de securitate. Compania este cel mai renumit producator mondial de echipamente inovative si extrem de cuprinzatoare pentru segmentul de control acces in zone publice si intreprinderi: <b>turnicheti, bariere, usi batante, usi culisante, usi rotitoare si usi de siguranta</b>.</p></div>";
            s += "<div style='background:url(_img/produs_table_separator.jpg) no-repeat left bottom; margin-bottom:10px;'><p style='background:url(_img/prezentare_parteneri/logo_noax.jpg) no-repeat top left; padding-left:210px; padding-bottom:10px;'><b>NOAX</b> este lider in fabricarea de <b>PC-uri industriale</b> fiabile si de rezistenta inalta. Compania are in spate multi ani de experienta in dezvoltarea si producerea de PC-uri cu touch-panel special proiectate pentru operare pe termen foarte indelungat, in conditii de productie extrema. Fie ca sunt supuse vibratiilor, socurilor, umiditatii, apei, uleiurilor sau prafului, computerele industriale NOAX isi arata calitatea si valoarea zi de zi, indiferent de duritatea conditiilor mediului de functionare.</p></div>";
            s += "<div style='background:url(_img/produs_table_separator.jpg) no-repeat left bottom; margin-bottom:10px;'><p style='background:url(_img/prezentare_parteneri/logo_powerview.jpg) no-repeat top left; padding-left:210px; padding-bottom:10px;'><b>POWERVIEW</b> este o companie infiintata in 2004, avand sediul in Olanda dedicata integrarii imaginii, siguranta, retelistica si tehnologiei de recunoastere biometrica. Gama de produse oferite include: <b>DVR, camere video, sisteme de recunoastere faciala, sisteme de recunoastere a amprentei</b>.</p></div>";
            s += "<div style='background:url(_img/produs_table_separator.jpg) no-repeat left bottom; margin-bottom:10px;'><p style='background:url(_img/prezentare_parteneri/logo_vido.jpg) no-repeat top left; padding-left:210px; padding-bottom:10px;'><b>VIDO</b>, companie cu sediul in Austria, a fost infiintata in 1995, si este un fabricant profesionist <b>pentru echipamente si accesorii CCTV</b>. Avand echipa proprie de cercetare si dezvoltare, VIDO este un important furnizor de echipamente OEM pentru cele mai mari companii ce ofera solutii in domeniul sistemelor de securitate si CCTV. Gama larga de produse furnizate de VIDO cuprinde: camere speed dome, DVR-uri, camere CCD, lentile CCTV, monitoare,  controllere, switcher-e si alte accesorii.</p></div>";
            s += "</div>";
            break;
        }
    }
    document.getElementById('prezentare_current_content').innerHTML = s;            
}

// ******************************************************* ABOUT US STOP

/*********************  START left side main menu *********************/

function SDMenu(id) {
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.submenus = this.menu.getElementsByTagName("div");
	this.remember = false;          // store menu states (expanded or collapsed) in cookie and restore later
	this.speed = 3;                 // menu sliding speed (1 - 5 recomended)
	this.markCurrent = true;        // mark current link / page (link.href == location.href) [?!?]
	this.oneSmOnly = true;          // one expanded submenu at a time
}
SDMenu.prototype.init = function() {
	var mainInstance = this;
	for (var i = 0; i < this.submenus.length; i++)
		this.submenus[i].getElementsByTagName("span")[0].onclick = function() {
			mainInstance.toggleMenu(this.parentNode);
		};
	if (this.markCurrent) {
		var links = this.menu.getElementsByTagName("a");
		for (var i = 0; i < links.length; i++)
			if (links[i].href == document.location.href) {
				links[i].className = "current";
				break;
			}
	}
	if (this.remember) {
		var regex = new RegExp("sdmenu_" + encodeURIComponent(this.menu.id) + "=([01]+)");
		var match = regex.exec(document.cookie);
		if (match) {
			var states = match[1].split("");
			for (var i = 0; i < states.length; i++)
				this.submenus[i].className = (states[i] == 0 ? "collapsed" : "");
		}
	}
};
SDMenu.prototype.toggleMenu = function(submenu) {
	if (submenu.className == "collapsed")
		this.expandMenu(submenu);
	else
		this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function(submenu) {
	var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var links = submenu.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++)
		fullHeight += links[i].offsetHeight;
	var moveBy = Math.round(this.speed * links.length);
	
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight + moveBy;
		if (newHeight < fullHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "";
			mainInstance.memorize();
		}
	}, 30);
	this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function(submenu) {
	var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var moveBy = Math.round(this.speed * submenu.getElementsByTagName("a").length);
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "collapsed";
			mainInstance.memorize();
		}
	}, 30);
};
SDMenu.prototype.collapseOthers = function(submenu) {
	if (this.oneSmOnly) {
		for (var i = 0; i < this.submenus.length; i++)
			if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
				this.collapseMenu(this.submenus[i]);
	}
};
SDMenu.prototype.expandAll = function() {
	var oldOneSmOnly = this.oneSmOnly;
	this.oneSmOnly = false;
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className == "collapsed")
			this.expandMenu(this.submenus[i]);
	this.oneSmOnly = oldOneSmOnly;
};
SDMenu.prototype.collapseAll = function() {
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className != "collapsed")
			this.collapseMenu(this.submenus[i]);
};
SDMenu.prototype.memorize = function() {
	if (this.remember) {
		var states = new Array();
		for (var i = 0; i < this.submenus.length; i++)
			states.push(this.submenus[i].className == "collapsed" ? 0 : 1);
		var d = new Date();
		d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
		document.cookie = "sdmenu_" + encodeURIComponent(this.menu.id) + "=" + states.join("") + "; expires=" + d.toGMTString() + "; path=/";
	}
};

/*********************  STOP left side main menu *********************/


/*********************  START set noimage if img src is incorrect *********************/

function fix_images(img_size)
{
    if (!document.getElementById || !document.getElementsByTagName)
		return false;
	if (img_size == 60)     // categorii.aspx [  futile because of ajax :P  ]
	    this.content = document.getElementById("main_section_center");
	if (img_size == 80)     // subcategorii.aspx & cauta.aspx
	{
	    if (document.getElementById("main_section"))    // subcategorii.aspx
	        this.content = document.getElementById("main_section");
	    if (document.getElementById("found_products"))    // cauta.aspx
	        this.content = document.getElementById("found_products");
	}
	if (img_size == 200)    // produse.aspx
	    this.content = document.getElementById("main_section");
	this.images = this.content.getElementsByTagName("img");
	for (var i = 0; i < this.images.length; i++)
	{
	    if ((this.images[i].src.toLowerCase().search(".jpg") == -1) && (this.images[i].src.toLowerCase().search(".jpeg") == -1) && (this.images[i].src.toLowerCase().search(".gif") == -1) && (this.images[i].src.toLowerCase().search(".png") == -1))
            if (img_size != 200)
                this.images[i].src = "_img/noimage" + img_size + ".jpg";
            else
                this.images[i].style.display = 'none';
        else
            if ((this.images[i].width == 28) && (this.images[i].height == 30))   // daca exista in baza de date, dar nu exista pe server imaginea mare
            {
                if (img_size != 200)
                    this.images[i].src = "_img/noimage" + img_size + ".jpg";
                else
                    this.images[i].style.display = 'none';
            }
            else
                if ((this.images[i].width > img_size) && (img_size == 200))
                {// adjust size for large images
                    this.images[i].style.height = Math.floor(this.images[i].height * img_size / this.images[i].width) + "px";
                    this.images[i].style.width = img_size + "px";
                }
        if (this.images[i].src.search("_img/noimage200.jpg") > -1)  // la pagina produse, daca o imagine devine default, ii pun display:none
            this.images[i].style.display = 'none';
    }
}

/*********************  START set noimage if img src is incorrect *********************/


/********************* Contact: after submit ***********************/

function doAfterSubmit()
{

    if (document.getElementById('error_label').value != "")
    {
        if ((document.getElementById('txtNume').value != "") || (document.getElementById('txtPrenume').value != "") || (document.getElementById('txtCompanie').value != "") || (document.getElementById('txtTelefon').value != "") || (document.getElementById('txtEmail').value != "") || (document.getElementById('txtComments').value != ""))
        {
            document.getElementById('contact_form').style.display = 'none';
            document.getElementById('mesajdeconf').style.display = 'block';
        }
        else
        {
            document.getElementById('contact_form').style.display = 'block';
            document.getElementById('mesajdeconf').style.display = 'none';
        }
    }
    else
        alert(document.getElementById('error_label').value);
}


// ******************************************************* contact radiobuttons stuff

function contact_rbl(rbi_id)        // radio button item id
{
    var id="";
    for (var i = 0; i < 4; i++)
    {
        id = "RadioButton_sursa_" + i;
        document.getElementById(id).checked = false;
        if (i > 0)
        {
            id = "txt_sursa_" + i;
            document.getElementById(id).style.visibility = "hidden";
        }
    }
    id = "RadioButton_sursa_" + rbi_id;
    document.getElementById(id).checked = true;
    if (rbi_id > 0)
        {
            id = "txt_sursa_" + rbi_id;
            document.getElementById(id).style.visibility = "visible";
            document.getElementById(id).focus();
        }
}



// ******************************************************* contact stop


// ******************************************************* Toggle language start

function toggle_language(lang)
{
    var loc = window.location + "";
    if (lang == "en")
    {
        loc = loc.replace(".ro", ".eu");
        // replace file's names
        loc = loc.replace("categorii.aspx", "category.aspx");
        loc = loc.replace("cauta.aspx", "search.aspx");
        loc = loc.replace("distribuitori.aspx", "distributors.aspx");
        loc = loc.replace("despre_dec.aspx", "about_dec.aspx");
        loc = loc.replace("produse.aspx", "products.aspx");
        loc = loc.replace("stiri.aspx", "news.aspx");
        loc = loc.replace("subcategorii.aspx", "subcategory.aspx");
        loc = loc.replace("termeni_si_conditii.aspx", "terms_and_conditions.aspx");
    }
    else
    {// not used (from .en to .ro)
        loc = loc.replace(".eu", ".ro");
        // replace file's names
        loc = loc.replace("category.aspx","categorii.aspx");
        loc = loc.replace("search.aspx", "cauta.aspx");
        loc = loc.replace("distribuitors.aspx", "distribuitori.aspx");
        loc = loc.replace("about_dec.aspx", "despre_dec.aspx");
        loc = loc.replace("products.aspx", "produse.aspx");
        loc = loc.replace("news.aspx", "stiri.aspx");
        loc = loc.replace("subcategory.aspx", "subcategorii.aspx");
        loc = loc.replace("terms_and_conditions.aspx", "termeni_si_conditii.aspx");
    }
    window.location = loc;
}

// ******************************************************* Toggle language stop

// ******************************************************* search start

function keycheck(evt)
{
    evt = (evt) ? evt : ((event) ? event : null);
    var evver = (evt.target) ? evt.target : ((evt.srcElement)
    ?evt.srcElement : null );
    var keynumber = evt.keyCode;
    if(keynumber==13)
    {
        cauta(document.getElementById('search_input_text').value);
        return false;
    }
    else
        return true;
}

function cauta()
{
    var str = document.getElementById('search_input_text').value;
    if (str == "cauta")
    {
        alert("Introduceti unul sau mai multe cuvinte.");
        document.getElementById('search_input_text').focus();
    }
    else
    {
        str = str.replace(/^(\s+)?(.*\S)(\s+)?$/, '$2');
        if( str.length < 4)
        {
            alert('Va rugam introduceti cel putin 4 caractere pentru cautare.');
            document.getElementById('search_input_text').focus();
        }
        else
        {
            window.location = "cauta.aspx?query=" + str;
        }
    }
}

// ******************************************************* search stop

// ******************************************************* categorii.aspx promo start

var timer_promo = 0;
var progress = 0;   // max = 150 (px) (latimea maxima a imaginii/bannerului de promotie)
var timer_step = 1;
var i = 0;
var i_nou = 0;
var i_in_curand = 0;

function goPromo()
{
    // show on the progressbar the number of the current promo out of all promos (ex: 4/16)
    if (document.getElementById('main_section_right').style.display != 'none')
    {
        document.getElementById('progress_status_span').innerHTML = (i+1)*1 + "/" + promotii.length;
        document.getElementById('progress_status_span_nou').innerHTML = (i_nou+1)*1 + "/" + promotii_nou.length;
        document.getElementById('progress_status_span_in_curand').innerHTML = (i_in_curand+1)*1 + "/" + promotii_in_curand.length;
        
        progress = document.getElementById('progressbar').offsetWidth;
        progress++;        // increase width

        if (progress == 150)
        {
            document.getElementById('progressbar').style.width = 1 + 'px';
            document.getElementById('progressbar_nou').style.width = 1 + 'px';
            document.getElementById('progressbar_in_curand').style.width = 1 + 'px';
            // change PROMO
            if (i < promotii.length - 1)
                i++;
            else
                i = 0;
            document.getElementById('promo_img').src = "http://decitequipmentscms.keysys.ro/_files_promo/" + promotii[i].image;
            document.getElementById('promo_img').title=promotii[i].title;
            document.getElementById('promo_img').alt=promotii[i].title;
            document.getElementById('a_promo_img').setAttribute('href', 'promo.aspx?idpromo='+promotii[i].id);
            // this link [current promo] is no longer used... document.getElementById('a_promo_current').setAttribute('href', 'promo.aspx?idpromo='+promotii[i].id);
            document.getElementById('a_promo_all').setAttribute('href', 'promo.aspx?idpromo=0');
            
            try
            {
                // change NOU
                if (i_nou < promotii_nou.length - 1)
                    i_nou++;
                else
                    i_nou = 0;
                document.getElementById('nou_img').src = "http://decitequipmentscms.keysys.ro/_files_promo/" + promotii_nou[i_nou].image;
                document.getElementById('nou_img').title=promotii_nou[i_nou].title;
                document.getElementById('nou_img').alt=promotii_nou[i_nou].title;
                document.getElementById('a_nou_img').setAttribute('href', 'promo.aspx?idpromo='+promotii_nou[i_nou].id);
            }
            catch(e1)
            {
                // do nothing... probably the promotii_nou array does not exist
            }
            
            try
            {
                // change IN CURAND
                if (i_in_curand < promotii_in_curand.length - 1)
                    i_in_curand++;
                else
                    i_in_curand = 0;
                document.getElementById('in_curand_img').src = "http://decitequipmentscms.keysys.ro/_files_promo/" + promotii_in_curand[i_in_curand].image;
                document.getElementById('in_curand_img').title=promotii_in_curand[i_in_curand].title;
                document.getElementById('in_curand_img').alt=promotii_in_curand[i_in_curand].title;
                document.getElementById('a_in_curand_img').setAttribute('href', 'promo.aspx?idpromo='+promotii_in_curand[i_in_curand].id);
            }
            catch(e2)
            {
                // do nothing... probably the promotii_in_curand array does not exist
            }
            

		    timer_promo = setTimeout("goPromo();", timer_step);	// how long the image remains visible
	    }
	    else
	    {
            document.getElementById('progressbar').style.width = progress + 'px';
            document.getElementById('progressbar_nou').style.width = progress + 'px';
            document.getElementById('progressbar_in_curand').style.width = progress + 'px';
	        timer_promo = setTimeout("goPromo();", timer_step);	// how fast the link scrolls up
        }
    }
}

function stop_timer_promo()
{
    if (timer_promo)
	{
	    clearTimeout(timer_promo);
	    timer_promo = 0;
    }
}

function promo(id, title, image, product_count)    // init function for the promo object! [the promo object array is created in categorii.aspx.cs]
{
    this.id = id;
    this.title = title;
    this.image = image;
    this.product_count = product_count;
}


// ******************************************************* categorii.aspx promo stop
