/**
* Author: Teodor Muraru
* Various functions compiled by me..
* 
*/
function nothing(){}
function action(){}
function show_hide(){}
function voteaza(){}  

function toggle_teo(id)
{   if (document.getElementById(id)){
        if (document.getElementById(id).style.display != 'none')
	        document.getElementById(id).style.display = 'none';
        else
	        document.getElementById(id).style.display = '';
    }
}
function toggle_t() {
    for ( var i=0; i < arguments.length; i++ ) {
        if ($(arguments[i])) $(arguments[i]).style.display = ($(arguments[i]).style.display != 'none' ? 'none' : 'block' );
    }
}
function show_true(id)
{    
    if (document.getElementById(id)){
        if (document.getElementById(id).style.display == 'none')
	        document.getElementById(id).style.display = 'block';
    }
}
function show_false(id)
{
if (document.getElementById(id).style.display != 'none')
	document.getElementById(id).style.display = 'none';
}
   
function toggle_show(id){
    if (document.getElementById(id)){   
        if (document.getElementById(id).style.display == 'none')
            document.getElementById(id).style.display = 'block';
    }
}
function toggle_hide(id){
    if (document.getElementById(id)){   
        if (document.getElementById(id).style.display != 'none')
            document.getElementById(id).style.display = 'none';
    }
}

   
/**
 * Functions used in the section: "Concurs" in 1 Iunie
 *
 */
err_cauta = "Eroare: Ce cuvinte cauti?!\n";
function cautare_(){alert(err_cauta);
    if ($('cautare').value.strlen < 3) {
        alert(err_cauta);
        return false; 
    }
    if ($('cauta')){  $('cauta').submit();  }
}
err1="Eroare: Nu ai completat numele!\n";
err2="Eroare: Nu ai completat adresa email!\n";
err3="Eroare: Nu ai completat titlul!\n";
err4="Eroare: Nu ai completat propunerea!\n";
function action2sss(){
	if(validate_propunere())
		$('propuneeee').submit();

}
function validate_propunere(){

	var error="";
    if ($('numeeee').value.length < 3){
    	error+=err1;
	}
    if($('emaileee').value.length < 3 || $('emaileee').value.indexOf('@',1) == -1){
    	error+=err2;
	}
	if ($('titluleee').value.length < 3){
		error+=err3;
	}
	if($('propunereeee').value.length < 3){
		error+=err4;
	}
	//alert(error + ' - ' + $('numeeee').value + ' => ' +$('numeeee').value.length);
	if(error!="")
	{
		alert(error);
		return false;
	}
	return true;
}
/**
 * Function used in the section: "Ce isi doresc femeile" in Martisor
 *
 */
function switchTab( currElement, which )
{
	var swap = which == 1 ? 2 : 1;
	var whichLi = which == 1 ? 1 : 0;

	document.getElementById('tabbedContent-' + which).className='content';
	document.getElementById('tabbedContent-' + swap).className='content hidden';
	currElement.className='selected';
	document.getElementById('list').getElementsByTagName('li')[whichLi].className = '';
}

function rgb2hex(color){  rgb_color=color.split(", ");
    red=rgb_color[0]; green=rgb_color[1]; blue=rgb_color[2];
    var hex = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
    var rgb = new Array();
    var k = 0;
    for (var i = 0; i < 16; i++)
        for (var j = 0; j < 16; j++) {
            rgb[k] = hex[i] + hex[j]; k++
        }
    return('#' + rgb[red] + rgb[green] + rgb[blue]);
}
function hex2rgb(hex)
 {
     var regexp = new RegExp('^#?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$');
     var match = hex.toLowerCase().match(regexp);

     if (match)
    {
         var rgb = new Array(parseInt(match[1], 16), parseInt(match[2], 16), parseInt(match[3], 16));
        return(rgb);
     }
     else
    {
         return(null);
    }
 }
 
 
function makepage(src)
{      
  return "<html>\n" +
    "<head>\n" +
    "<title>Temporary Printing Window</title>\n" +
    "<script>\n" +
    "function step1() {\n" +
    "  setTimeout('step2()', 10);\n" +
    "}\n" +
    "function step2() {\n" +
    "  window.print();\n" +
    "  window.close();\n" +
    "}\n" +
    "</scr" + "ipt>\n" +
    "</head>\n" +
    "<body onLoad='step1()'>\n" +
    "<img src='/modules/default/img/iunie/main_content/sections/pentru-copii/picteaza/" + src + "' />\n" +
    "</body>\n" +
    "</html>\n";
}

function printme(imagine)
{
  link = "about:blank";
  var pw = window.open(link, "_new");
  pw.document.open();
  pw.document.write(makepage(imagine));
  pw.document.close();
}

