/*
* $Id: functions.js,v 1.1 2007/02/09 11:56:38 razvan.stanga Exp $
*/

// init
_browser = getBrowser ();

function confirmSubmit (msg) {
	var agree=confirm(msg);
	if (agree) {
		return true ;
	} else {
		return false ;
	}
}

function is_empty (str) {
    return str.search("^[ \t\n\r]*$")>-1 ? true : false;
}

function is_int (str) {
    return str.search("^[0-9]*$")>-1 ? true : false;
}

function validField (str, msg) {
    if ( is_empty(str) ) {
		alert (msg);
		return false;
    }
    return true;
}

function multipleSelect ( arr, f, field ) {

    eval ('var val = document.forms.'+f+'.'+field+'.length');
	for ( j=0 ; j < val ; j++ ) {
	    if ( arr == 'all' ) {
	    	eval ('document.forms.'+f+'.'+field+'[j].selected = true;');
	    } else {
	        eval ('document.forms.'+f+'.'+field+'[j].selected = false;');
	    }
	}
	if ( arr == 'all' ) {
	    return "";
	}

	var b = arr.split (',');
	for ( i=0 ; i < b.length ; i++ ) {
	    for ( j=0 ; j < val ; j++ ) {
	        if ( b[i] == eval ('document.forms.'+f+'.'+field+'[j].value') ) {
	    		eval ('document.forms.'+f+'.'+field+'[j].selected = true');
	        }
	    }
	}
}

function setValue (field, f, val) {
	//val = val.replace ("\'", "\\\\\\'");
	eval ("f = document.forms."+f+"."+field);
	f.value = val;
}

function getLength (field, f) {
	x = eval ("document.forms."+f+"."+field+".length");
	return x;
}

function selectOption (field, f ,i) {
	eval ("document.forms."+f+"."+field+"["+i+"].selected=true;");
}

function getValue (field, f) {
	eval ("var x = document.forms."+f+"."+field+".value");
	return x;
}

function getOption (n, f, o) {
	var selOp = eval ('document.forms.'+f+'.'+n+';');
	if ( o == 't' ) {
		return selOp.options[selOp.selectedIndex].text;
	} else {
     	return selOp.options[selOp.selectedIndex].value;
   	}
}

function getOptionIndex (n, f, v, o) {
	var selOp = eval ('document.forms.'+f+'.'+n+';');
	if ( o == 't' ) {
		return selOp.options[v].text;
	} else {
     	return selOp.options[v].value;
   	}
}

function doSubmit ( f ) {
	eval ('document.forms.'+f+'.submit ();');
}

function checkboxAll (field, f, act, s, e) {
	for ( i=s ; i < e ; i++ ) {
	    if ( act == 'c' ) {
	    	eval ('document.forms.'+f+'.'+field+'['+i+'].checked = true;');
	    } else if ( act == 'u' ) {
	    	eval ('document.forms.'+f+'.'+field+'['+i+'].checked = false;');
	    }
	}
}

function inputAll (field, f, val, s, e) {
	for ( i=s ; i < e ; i++ ) {
    	eval ('document.forms.'+f+'.'+field+'['+i+'].value = "'+val+'";');
	}
}

function checkBox (f, field, m) {

	var checkbox = 	eval ('document.forms.'+f+'.'+field);
	var len = checkbox.length;

	var j = 0;
	for ( i=0 ; i < len ; i++ ) {
	    if ( checkbox[i].checked == true ) {
			j++;
			if ( j > m ) {
			    checkbox[i].checked = false;
			    alert ("Nu puteti selecta mai mult de "+m+" optiuni");
			    return false;
			}
	    }
	}
}

function addOption (n, f, t, v, s) {
	var selOp = eval ('document.forms.'+f+'.'+n+'');
	var len = selOp.options.length;
	selOp.options[len] = new Option (t, v);
	if ( s == true ) {
		selOp[len].selected = true;
	}
}

function removeOption (n, f, op) {
	var selOp = eval ('document.forms.'+f+'.'+n+'');
	for ( i=0;i<selOp.length;i++ ) {
		if ( i == op ) {
			selOp[i] = null;
			break;
		}
	}
}

function checkCookie () {

var acceptsCookies = false;
if(document.cookie == '') {
    document.cookie = 'acceptsCookies=yes';
    if(document.cookie.indexOf('acceptsCookies=yes') != -1) {
	acceptsCookies = true;
    }
    return acceptsCookies;
} else {
  acceptsCookies = true;
  return acceptsCookies;
}
}


function setCookie (name, value, hours, path, domain, secure) {
    if ( checkCookie () == true ) {
        name = 'b'+name;
	var not_NN2 = (navigator && navigator.appName
		       && (navigator.appName == 'Netscape')
		       && navigator.appVersion
		       && (parseInt(navigator.appVersion) == 2))?false:true;

	if(hours && not_NN2) {
	    if ( (typeof(hours) == 'string') && Date.parse(hours) ) {
		var numHours = hours;
	    } else if (typeof(hours) == 'number') {
		var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	    }
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':'');
    }
}


function getCookie(name) {
    if(document.cookie == '') {
		return false;
    } else {
		var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);
		var NN2Hack = firstChar + name.length;
		if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) {
	    	firstChar += name.length + 1;
	    	lastChar = theBigCookie.indexOf(';', firstChar);
	    	if(lastChar == -1) lastChar = theBigCookie.length;
	    	return unescape(theBigCookie.substring(firstChar, lastChar));
		} else {
	    	return false;
		}
    }
}

function writeToLayer (l, txt) {
	
	if (document.layers) {
		eval ( "var lay = document.layers."+l+"" );
		lay.innerHTML = txt;
	} else if (document.all) {
		eval ( "var lay = document.all."+l+"" );
		lay.innerHTML = txt;
	} else {
		var lay = document.getElementById (l);
		lay.innerHTML = txt;
   	}
}

function getFromLayer (l) {

	if (document.layers) {
		eval ( "var lay = document.layers."+l+";" );
		return lay.innerHTML;
	} else if (document.all) {
		eval ( "var lay = document.all."+l+";" );
		return lay.innerHTML;
	} else {
		var lay = document.getElementById (l);
		return lay.innerHTML;
   	}
}

function getBrowser () {
	var browserName = navigator.appName;
	if ( browserName.search ('Internet Explorer') != -1  ) {
		return 'Internet Explorer';
	} else if ( browserName.search ('Netscape') != -1 ) {
        return 'Netscape';
	} else if ( browserName.search ('Opera') != -1 ) {
        return 'Opera';
	} else if ( browserName.search ('Firefox') != -1 ) {
        return 'Firefox';
	} else {
		return 'Other';
	}
}

function setVisibility (n, act) {
	try {
	if ( getBrowser () == 'Internet Explorer' ) {
        var selOp = eval ("document.all.div_"+n+"");
	} else {
        var selOp = eval ("document.getElementById ('div_"+n+"');");
	}
	//var selOp = eval ("document.all.div_"+n+"");
	if ( act == 't' ) {
       	selOp.style.display='';
	} else if ( act == 'f' ) {
		selOp.style.display='none';
	}
	}
	catch (ex) {}
}

function toggleSongs (_current, _total) {
	for ( _i=1;_i<=_total;_i++ ) {
		_pic = _i + _total;
		$("img_"+_i).src="/styles/style1/images/prizes/"+_pic+"_off.jpg";
	}
	_pic = _current + _total;
	$("img_"+_current).src="/styles/style1/images/prizes/"+_pic+".jpg";
	//_homeboxselected = _current;
}

function toggleVisibility (div) {
		for ( $i=1;$i<=5;$i++ ) {
			try {
				if ( 'div_list_'+$i != 'div_list_'+div ) {
					setVisibility ('list_'+$i, 'f');
	    			//toggleSongs ($i, 5);
					_pic = $i + 5;
					$("img_"+$i).src="/styles/style1/images/prizes/"+_pic+"_off.jpg";
				} else {
					_pic = $i + 5;
					$("img_"+$i).src="/styles/style1/images/prizes/"+_pic+".jpg";
				}
			}
			catch (ex) {}
		}

        var selOp = document.getElementById ('div_list_'+div);
		if ( selOp.style.display == 'none' ) {
       		selOp.style.display='';
		} else {
			selOp.style.display='none';
			for ( $i=1;$i<=5;$i++ ) {
				try {
					_pic = $i + 5;
					$("img_"+$i).src="/styles/style1/images/prizes/"+_pic+".jpg";
				}
				catch (ex) {}
			}
		}
}

function toggleLogin (n) {
	try {
    	var selOp = document.getElementById ('div_'+n);

		if ( selOp.style.display == '' ) {
       		selOp.style.display='none';
       		ret = false;
		} else {
			selOp.style.display='';
			ret = true;
		}
	}
	catch (ex) {}
	return ret;
}

function toggleAdvancedSearch (n) {
    t = toggleVisibility (n);
    if ( t == true ) {
    	setValue ('avansat', 'search', 1);
    } else {
    	setValue ('avansat', 'search', '');
    }
}

function toNumber ( nr ) {
	return parseFloat ( nr );
}

function addBR ( field, f ) {
	
	txt = getValue (field, f);
	i = 1;
	while ( txt.search ('[:::]') != -1 ) {
		txt = txt.replace ("[:::]", '\r\n');
		i++;
		if ( i >= 150 ) {
			break;
		}
	}
	setValue (field, f, txt);
}

function doOpenPopup (url, wid, hei, n) {
	if ( n == "") {
		n = "popup_url";
	}
    var w = (window.screen.width-wid)/2;
	var h = (window.screen.height-hei)/2;
	window.open(url, n, 'scrollbars=yes,resizable=no,menubar=no,statusbar=no,toolbar=no, width='+wid+', height='+hei+', left='+w+',top='+h+',screenX='+w+',screenY='+h+' ');
}

function doOpenPopup2 (url, wid, hei, n) {
	if ( n == "") {
		n = "popup_url";
	}
    var w = (window.screen.width-wid)/2;
	var h = (window.screen.height-hei)/2;
	window.open(url, n, 'scrollbars=no,resizable=no,menubar=no,statusbar=no,toolbar=no, width='+wid+', height='+hei+', left='+w+',top='+h+',screenX='+w+',screenY='+h+' ');
}

function deActivate ( field, f, val ) {
	if ( val ) {
		eval ('document.forms.'+f+'.'+field+'.disabled=false;');
	} else {
		eval ('document.forms.'+f+'.'+field+'.disabled=true;');
	}
}

function isEmail (email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
		return true;
	} else {
		alert ("Va rugam sa introduceti o adresa de email valida");
		return false;
	}
}

function addToField (f, field, val) {
    var fField = eval ('document.forms.'+f+'.'+field);
    fField.value += val;
}

function toWindow (f, e, v) {
	eval ("window.opener.document."+f+"."+e+".value += '"+v+"'");
}

function goTO ( url, val ) {
	if ( val ) {
		window.location=url;
	}
}

function selectMove (f, f1, f2) {
	var F1 = eval ('document.forms.'+f+'.'+f1);
	var F2 = eval ('document.forms.'+f+'.'+f2);
	for ( i=0;i<F1.length;i++ ) {
		if ( F1[i].selected == true ) {
			t = getOptionIndex (f1, f, i, 't');
			v = getOptionIndex (f1, f, i, 'v');
			removeOption (f1, f, i)
			addOption (f2, f, t, v);
		}
	}
}

function checkLeadings ( f, field, l ) {
	var F1 = eval ('document.forms.'+f+'.'+field);
	if ( l > 0 ) {
		if ( F1.length < l ) {
			alert ('Trebuie sa existe 4 leadings');
			return false;
		} else if ( F1.length > l ) {
			alert ('Trebuie sa existe 4 leadings');
			return false;
		}
	}
	return true;
}

function selectSelectAll (f, n) {
	var selOp = eval ('document.forms.'+f+'.'+n+'');
	for ( i=0;i<selOp.length;i++ ) {
		selOp[i].selected = true;
	}
}

function unSelect ( f, field, val ) {
	if ( val ) {
		var F = eval ('document.forms.'+f+'.'+field);
		F.value = "";
	}
}

function changePreview ( f, field, i ) {
	var F1 = eval ('document.forms.'+f+'.'+field);
	if ( i != "" ) {
		F1.src = 'styles/style1/images/leadings/home_'+i+'/preview.gif';
	} else {
		F1.src = 'styles/style1/images/spacer.gif';
	}
}

function uploadedPreview ( f, field, i ) {
	var F1 = eval ('document.forms.'+f+'.'+field);
	if ( i != "" ) {
		F1.src = 'images/upload/t-'+i+'';
	} else {
		F1.src = 'styles/style1/images/spacer.gif';
	}
}

function imagePreview ( f, field, i, path ) {
	var F1 = eval ('document.forms.'+f+'.'+field);
	if ( i != "" ) {
		F1.src = path+'/'+i+'.gif';
	} else {
		F1.src = 'styles/style1/images/spacer.gif';
	}
}

function toImagesWindow (f, e, v) {
	eval ("window.opener.document."+f+"."+e+".value = '"+v+"'");
}

function numberFormat ( number ) {
  laenge = "2";
  sep = ".";
  th_sep = ",";
  number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
  str_number = number+"";

  arr_int = str_number.split(".");
  if(!arr_int[0]) arr_int[0] = "";
  if(!arr_int[1]) arr_int[1] = "";
  if(arr_int[1].length < laenge){
    nachkomma = arr_int[1];
    for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }
    arr_int[1] = nachkomma;
  }
  if(th_sep != "" && arr_int[0].length > 3){
    Begriff = arr_int[0];
    arr_int[0] = "";
    for(j = 3; j < Begriff.length ; j+=3){
      Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
      arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
    }
    str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
    arr_int[0] = str_first + arr_int[0];
  }
  //return arr_int[0];
  return arr_int[0]+sep+arr_int[1];
}

function detectFlashVersion () {
	// flash version detection
	var flash = new Object();

	flash.installed = false;
	flash.version='0.0';

	if (navigator.plugins && navigator.plugins.length)
	{
		for (x=0; x<navigator.plugins.length; x++)
		{
			if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1)
			{
				flash.version=navigator.plugins[x].description.split('Shockwave Flash ')[1];
				flash.installed = true;
				break;
			}
		}
	} else if (window.ActiveXObject) {
		for (x=2; x<10; x++)
		{
			try
			{
				oFlash=eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+x+"');");
				if (oFlash)
				{
					flash.installed = true;
					flash.version=x+'.0';
				}
			}
			catch(e) {}
		}
	}

	flash.ver = (flash.installed && parseInt(flash.version) >= 2) ? parseInt(flash.version) : false;
	if ( flash.ver < 7 ) {
		//goTO ('http://www.iaa.ro/error/index.html', 1);
	}
}

function setFileValue ( val, id ) {
	$_id = document.getElementById (id);
	$_id.value = val;
}

//BANNERE LOADING
function playflash(strId) { 
  // strId format: object.id|embed.id 
  // Check for embed first, if undefined, try the object 
  var player = document.getElementById(strId.split("|")[1]); 
  if (!player) player = document.getElementById(strId.split("|")[0]); 
  player.Play(); 
} 
function replayflash(strId) { 
  // strId format: object.id|embed.id 
  // Check for embed first, if undefined, try the object 
  var player = document.getElementById(strId.split("|")[1]); 
  if (!player) player = document.getElementById(strId.split("|")[0]); 
  player.GoToFrame(24);
  player.Play();
}
function movieIsLoaded () {
	playflash('player2o|player2e');
	//d = document.getElementById ("t");
	//d.innerHTML += numarfl1
	//alert(numarfl1+" <= "+numarfl2);
}
function movieIsVeryLoaded () {
	playflash('player1o|player1e');
	playflash('player2o|player2e');
	//d = document.getElementById ("t");
	//d.innerHTML += numarfl2
	//alert(numarfl1+" => "+numarfl2);
}
//BANNERE LOADING - END

function changeClass (t, c) {
	t.className = c;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/* Script by: www.jtricks.com
 * Version: 20071210
 * Latest version:
 * www.jtricks.com/javascript/navigation/floating.html
 */
 

var floatingMenuId = 'player';
var floatingMenu = {};

floatingMenu.move = function ()
{
    if (document.layers)
    {

        if (floatingMenu.nextX > 754) {
			aaa = (floatingMenu.nextX - 754)/2;
			floatingMenu.menu.left = floatingMenu.nextX - aaa
		} else {
			floatingMenu.menu.left = 754;
		}

		if(floatingMenu.nextY < 425){
			floatingMenu.menu.top = 425;
		} else {
			floatingMenu.menu.top = floatingMenu.nextY;
		}

        //floatingMenu.menu.left = floatingMenu.nextX;
        //floatingMenu.menu.top = floatingMenu.nextY;
    }
    else
    {

        if (floatingMenu.nextX > 754) {
			aaa = (floatingMenu.nextX - 754)/2;
			floatingMenu.menu.style.left = floatingMenu.nextX - aaa + 'px';
		} else {
			floatingMenu.menu.left = 754;
		}

		if(floatingMenu.nextY < 425){
			floatingMenu.menu.style.top = 425 + 'px';
		} else {
			floatingMenu.menu.style.top = floatingMenu.nextY + 'px';
		}
		//$_player = document.getElementById ('player');
		//$_player.innerHTML = floatingMenu.nextY+' - '+floatingMenu.nextX;

        //floatingMenu.menu.style.left = floatingMenu.nextX + 'px';
        //floatingMenu.menu.style.top = floatingMenu.nextY + 'px';
    }
}

floatingMenu.computeShifts = function ()
{
    var de = document.documentElement;

    floatingMenu.shiftX =
        floatingMenu.hasInner
        ? pageXOffset
        : floatingMenu.hasElement
          ? de.scrollLeft
          : document.body.scrollLeft;
    if (floatingMenu.targetX < 0)
    {
        if (floatingMenu.hasElement && floatingMenu.hasInner)
        {
            // Handle Opera 8 problems
            floatingMenu.shiftX +=
                de.clientWidth > window.innerWidth
                ? window.innerWidth
                : de.clientWidth
        }
        else
        {
            floatingMenu.shiftX +=
                floatingMenu.hasElement
                ? de.clientWidth
                : floatingMenu.hasInner
                  ? window.innerWidth
                  : document.body.clientWidth;
        }
    }

    floatingMenu.shiftY =
        floatingMenu.hasInner
        ? pageYOffset
        : floatingMenu.hasElement
          ? de.scrollTop
          : document.body.scrollTop;
    if (floatingMenu.targetY < 0)
    {
        if (floatingMenu.hasElement && floatingMenu.hasInner)
        {
            // Handle Opera 8 problems
            floatingMenu.shiftY +=
                de.clientHeight > window.innerHeight
                ? window.innerHeight
                : de.clientHeight
        }
        else
        {
            floatingMenu.shiftY +=
                floatingMenu.hasElement
                ? document.documentElement.clientHeight
                : floatingMenu.hasInner
                  ? window.innerHeight
                  : document.body.clientHeight;
        }
    }
}

floatingMenu.doFloat = function()
{
    var stepX, stepY;

    floatingMenu.computeShifts();

    stepX = (floatingMenu.shiftX +
        floatingMenu.targetX - floatingMenu.nextX) * .09;
    if (Math.abs(stepX) < .5)
    {
        stepX = floatingMenu.shiftX +
            floatingMenu.targetX - floatingMenu.nextX;
    }

    stepY = (floatingMenu.shiftY +
        floatingMenu.targetY - floatingMenu.nextY) * .09;
    if (Math.abs(stepY) < .5)
    {
        stepY = floatingMenu.shiftY +
            floatingMenu.targetY - floatingMenu.nextY;
    }

    if (Math.abs(stepX) > 0 ||
        Math.abs(stepY) > 0)
    {
        floatingMenu.nextX += stepX;
        floatingMenu.nextY += stepY;
        floatingMenu.move();
    }

    setTimeout('floatingMenu.doFloat()', 20);
};

// addEvent designed by Aaron Moore
floatingMenu.addEvent = function(element, listener, handler)
{
    if(typeof element[listener] != 'function' ||
       typeof element[listener + '_num'] == 'undefined')
    {
        element[listener + '_num'] = 0;
        if (typeof element[listener] == 'function')
        {
            element[listener + 0] = element[listener];
            element[listener + '_num']++;
        }
        element[listener] = function(e)
        {
            var r = true;
            e = (e) ? e : window.event;
            for(var i = element[listener + '_num'] -1; i >= 0; i--)
            {
                if(element[listener + i](e) == false)
                    r = false;
            }
            return r;
        }
    }

    //if handler is not already stored, assign it
    for(var i = 0; i < element[listener + '_num']; i++)
        if(element[listener + i] == handler)
            return;
    element[listener + element[listener + '_num']] = handler;
    element[listener + '_num']++;
};

floatingMenu.init = function()
{
    floatingMenu.initSecondary();
    floatingMenu.doFloat();
};

// Some browsers init scrollbars only after
// full document load.
floatingMenu.initSecondary = function()
{
    floatingMenu.computeShifts();
    floatingMenu.nextX = floatingMenu.shiftX +
        floatingMenu.targetX;
    floatingMenu.nextY = floatingMenu.shiftY +
        floatingMenu.targetY;
    floatingMenu.move();
}

//alert(floatingMenu.nextY);


// 5310 - Toggles
_homeboxselected = 1;

function $ (_el) {
	return document.getElementById (_el);
}

function togglePhoneBox (_current, _total) {
	for ( _i=1;_i<=_total;_i++ ) {
		$("homebox_img_"+_i).src="/styles/style1/images/5310/"+_i+".jpg";
		$("homebox_div_"+_i).style.display="none";
	}
	$("homebox_img_"+_current).src="/styles/style1/images/5310/"+_current+"_on.jpg";
	$("homebox_div_"+_current).style.display="";
	_homeboxselected = _current;
}

function togglePhoneBoxOver (_current, _total) {
	for ( _i=1;_i<=_total;_i++ ) {
		if ( _i != _homeboxselected ) {
			$("homebox_img_"+_i).src="/styles/style1/images/5310/"+_i+".jpg";
		}
	}
	if ( _current > 0 ) {
		$("homebox_img_"+_current).src="/styles/style1/images/5310/"+_current+"_on.jpg";
	}
}
function toggleSuppBox (_current, _total) {
	for ( _i=1;_i<=_total;_i++ ) {
		$("homebox_div_"+_i).style.display="none";
	}
	$("homebox_div_"+_current).style.display="";
	_homeboxselected = _current;
}

function checkBirthDate () {
	_d = parseInt ( $('birthday_day').value );
	_m = parseInt ( $('birthday_month').value );
	_y = parseInt ( $('birthday_year').value );
	_p = $('div_parental');

	if ( _d != "" && _m != "" && _y != "" ) {
		// 1990-04-11
		if ( _y == 1990 ) {
			if ( _m >= 4 ) {
				if ( _m == 4 && _d > 11 ) {
					_p.style.display='';
				} else if ( _m > 4 ) {
					_p.style.display='';
				} else {
					_p.style.display='none';
				}
			} else if ( _m < 4 ) {
				_p.style.display='none';
			}
		} else if ( _y > 1990 ) {
			_p.style.display='';
		} else if ( _y < 1990 ) {
			_p.style.display='none';
		}
	} else {
		_p.style.display='none';
	}
}

function generateSupportCode (_host, _videoid, _userid, _var) {
	// 180x200
	_referer = window.location.hostname;

	_w = $('swidth'+_var).value;
	_h = _w/0.9;
	
	if ( _w != '' ) {
		if ( _w <= 119 ) {
			_w = 120;
		    alert ('Latimea minima este de 120 pixeli!');
			$('swidth'+_var).value = _w;
			_h = _w/0.9;
		} else if ( _w >= 301 ) {
			_w = 300;
		    alert ('Latimea maxima este de 300 pixeli!');
			$('swidth'+_var).value = _w;
			_h = _w/0.9;
		}
	}
	
	if ( _userid ) {
		_url = '&userid='+_userid;
		_type = 2;
	} else if ( _videoid ) {
		_url = '&videoid='+_videoid;
		_type = 1;
	}
	
	_rnd = Math.floor (Math.random()*11);
	//_code = '<!-- start '+_host+' support -->\n';
 	_code = '<script type="text/javascript" src="http://'+_host+'/support.php?width='+_w+'&var='+_var+_url+'&type='+_type+'"></script>\n';
 	//_code += '<!-- end '+_host+' support -->\n';
 	// show the code
 	$('supportjs'+_var).value = _code;
 	
 	// _extravars
 	_extravars = '';
 	if ( _userid ) {
 		_extravars = '&username='+_user['username']+'&sex='+_user['sex']+'&_videoid='+_user['videoid'];
 	}
 	
 	var _fAD = new Flash ('supportpreview'+_var);
	_fAD.setSWF ("http://"+_host+"/support/video"+_var+".swf", _w, _h);
	_fAD.setParam ("quality", "high");
	_fAD.setParam ("wmode", "transparent");
	_fAD.setParam ("menu", "false");
	_fAD.setParam ("salign", "lt");
	_fAD.setParam ("AllowScriptAccess", "always");
	_fAD.setParam ("flashvars", "host="+_host+"&referer="+_referer+"&userid="+_userid+"&videoid="+_videoid+"&dnr=1"+_extravars);
	_fAD.display ();
}

function calcChars (_this, _div) {
	$_div = document.getElementById (_div);
	$_value = _this.value;
	$_div.innerHTML = $_value.length;
}
