var vlostptable='<br><form method=\"POST\" name=\"vflostp\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td bgcolor=\"#B0B0B0\"><img border=\"0\" src=\"../images/shim.gif\" width=\"1\" height=\"1\"></td></tr><tr><td><p align=\"justify\"><font color=\"#B0B0B0\">Pentru recuperarea parolei introduceti in campul de mai jos adresa de e-mail cu care v-ati inscris. Veti primi pe aceasta adresa datele de logare.</font></td></tr><tr><td align=\"center\"><br><table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td>E-mail:</td><td><input type=\"text\" name=\"email\" size=\"20\"></td><td><input type=\"button\" value=\"Ok\" name=\"B1\" onclick=\"makeRequest(\'lostp.php?tip=vanzator&email=\'+document.vflostp.email.value);clearTxt(\'vlp\');\"></td><td><input type=\"button\" value=\"Renunta\" name=\"B2\" onclick=\"clearTxt(\'vlp\');\"></td></tr></table></td></tr></table></form>';
var clostptable='<br><form method=\"POST\" name=\"cflostp\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td bgcolor=\"#B0B0B0\"><img border=\"0\" src=\"../images/shim.gif\" width=\"1\" height=\"1\"></td></tr><tr><td><p align=\"justify\"><font color=\"#B0B0B0\">Pentru recuperarea parolei introduceti in campul de mai jos adresa de e-mail cu care v-ati inscris. Veti primi pe aceasta adresa datele de logare.</font></td></tr><tr><td align=\"center\"><br><table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td>E-mail:</td><td><input type=\"text\" name=\"email\" size=\"20\"></td><td><input type=\"button\" value=\"Ok\" name=\"B1\" onclick=\"makeRequest(\'lostp.php?tip=client&email=\'+document.cflostp.email.value);clearTxt(\'clp\');\"></td><td><input type=\"button\" value=\"Renunta\" name=\"B2\" onclick=\"clearTxt(\'clp\');\"></td></tr></table></td></tr></table></form>';
var chgpw='<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"\"><tr><td>Parola veche:</td><td><input type=\"password\" name=\"pold\" size=\"20\"></td><td></td><td></td></tr><tr><td>Parola noua:</td><td><input type=\"password\" name=\"pnew\" size=\"20\"></td><td><input type=\"submit\" value=\"Ok\" name=\"B3\"></td><td><input type=\"button\" value=\"Renunta\" name=\"B4\" onclick=\"clearTxt(\'divchg\');\"></td></tr></table>';

var picerr='<img border=\"0\" src=\"../images/msg.gif\" align=\"absmiddle\" width=\"32\" height=\"32\">';
var loadpic='<center><img border=\"0\" src=\"../images/loading.gif\" align=\"absmiddle\" width=\"16\" height=\"16\"> Asteptati...</center>';


function populateTxt(txt,ndiv) { 
   obj=document.getElementById(ndiv);
   obj.innerHTML=txt;
}
function clearTxt(ndiv){
  obj=document.getElementById(ndiv);
  obj.innerHTML='';
}

function modiq(pid,q,k){
 bucform='<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"right\"><b>Cantitate:</b> <input type=\"text\" name=\"q\" size=\"2\" value=\"'+q+'\"><input type=\"button\" value=\"Actualizeaza\" name=\"bAct\" onclick=\"fcart.pid.value=\''+pid+'\'; fcart.action=\'cos-actualizeaza.htm\'; fcart.submit();\"><input type=\"button\" value=\"Renunta\" name=\"bRst\" onclick=\"clearTxt(\'modibuc\');cOut('+k+');\"></td></tr></table>';
 clearTxt('modibuc');
 populateTxt(bucform,'modibuc');
}

var http_request;

function makeRequest(url,n) {
        http_request = false;
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        if(n==1){
	http_request.onreadystatechange = function1;
        }
       else if(n==2){
	http_request.onreadystatechange = function2;
       }	
       else if(n==3){
	http_request.onreadystatechange = function3;
       }
        else{
        	http_request.onreadystatechange = ContentsTxt;
        }
        if (url.indexOf("?") == -1){
	url+='?dummy=' + new Date().getTime();
        }
        else{		
             url+='&dummy=' + new Date().getTime();
        }
        http_request.open('GET', url, true);
        http_request.send(null);
 }


function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@._-";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}


function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.length-email.lastIndexOf(".") > 4){
        return false;  
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.lastIndexOf("@") == email.length-1) {  // @ must not be the last character
        return false;
    } else if (email.lastIndexOf(".") == email.length-1) {  // . must not be the last character
        return false;
    }

	
    return true;
}



//-------------modificare dimensiuni TEXTAREA -------------------
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));

var is_regexp = (window.RegExp) ? true : false;

var vbDOMtype = '';
if (document.getElementById)
{
vbDOMtype = "std";
}
else if (document.all)
{
vbDOMtype = "ie4";
}
else if (document.layers)
{
vbDOMtype = "ns4";
}

var vBobjects = new Array();

function fetch_object(idname, forcefetch)
{
  if (forcefetch || typeof(vBobjects[idname]) == "undefined")
  {
  switch (vbDOMtype)
  {
  case "std":
  {
  vBobjects[idname] = document.getElementById(idname);
  }
  break;
  
  case "ie4":
  {
  vBobjects[idname] = document.all[idname];
  }
  break;
  
  case "ns4":
  {
  vBobjects[idname] = document.layers[idname];
  }
  break;
  }
  }
  return vBobjects[idname];
}

function alter_box_height(boxid, pixelvalue)
{
var box = fetch_object(boxid);
var boxheight = parseInt(box.style.height);
var newheight = boxheight + pixelvalue;
if (newheight > 0)
{
box.style.height = newheight + "px";
}
return false;
}
//-----------END----------------------

function valButton(btn) {
var cnt = -1;
for (var i=btn.length-1; i > -1; i--) {
   if (btn[i].checked) {cnt = i; i = -1;}
   }
if (cnt > -1) return btn[cnt].value;
else return null;
} 

//-----------------------------------------

function highlight(idlink) {
for (i=1;i<=6;i++){
 obj=document.getElementById('l'+i);
 if (i==idlink){
   obj.style.backgroundColor='white';
 }
 else{
   //obj.style.backgroundColor='#FFE8E8';
 }

}
}
function offlight(idex){
for (i=1;i<=6;i++){
  if(idex != i){
    obj=document.getElementById('l'+i);
    obj.style.backgroundColor='#FFE8E8';
  }
}
}

function lostpass(p){
 var popup = window.open("", "Popup",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
 popup.location = 'lostpopup.php?email='+p;
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}