﻿
function disableButton(buttonId) {
if (document.all) {
var btn = document.all[buttonId]; btn.disabled = 'true';
}
else {
var btn = document.getElementById(buttonId); btn.disabled = 'true';
}
}


function openBigPicture(p_ImgSource,p_width, p_height, p_name){
	var winl;
	var wint;
	
	if(screen.width){
		winl = (screen.width-p_width)/2;
		wint = (screen.height-p_height)/2;
	}
	else{winl = 0;wint =0;}
	
	var strFeatures;
	strFeatures = "status=no,toolbar=no,menubar=no,location=no,resizable=no,width="+p_width+",height="+p_height+",top="+wint+",left="+winl+"";
	oWindow = window.open('',p_name, strFeatures);
	oWindow.document.open();  
	oWindow.document.write('<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">');
	oWindow.document.write('<html xmlns=\"http://www.w3.org/1999/xhtml\" ><head><title>'+p_name+'</title></head><body>');
	oWindow.document.write('<a href="JavaScript:window.close();"><img src="'+p_ImgSource+'"style=\"width:'+p_width+'px;height:'+p_height+'px;" border="0" alt=\"'+p_name+'\" /></a>'); 
	oWindow.document.write('</body></html>');	
	oWindow.document.close();
	oWindow.focus();
}

function openGallery(name_fis,p_width,p_height){
	var winl;
	var wint;    
	if(screen.width){
		winl = (screen.width-p_width)/2;
		wint = (screen.height-p_height)/2;
	}
	else{winl = 0;wint =0;}
	
	var strFeatures;
	strFeatures = "status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width="+p_width+",height="+p_height+",top="+wint+",left="+winl+"";
	oWindow = window.open(name_fis,'Galerie', strFeatures);	
	oWindow.focus();
}

function PopUp(p_ImgSource,p_width, p_height, p_name){
    var winl;
	var wint;
		
	if(screen.width){
		winl = (screen.width-p_width)/2;
		wint = (screen.height-p_height)/2;
	}
	else{winl = 0;wint =0;}
  
  var strFeatures;
  strFeatures = "status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=" + p_width + ",height=" + p_height+",top="+wint+",left="+winl+"";
  oWindow = window.open(p_ImgSource, p_name, strFeatures);
  oWindow.focus();			
}

function openPopup(p_strPage, name){
  var strFeatures;
  var p_strPage;
  strFeatures = "status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=417,height=400";
  oWindow = window.open(p_strPage, name, strFeatures);
  oWindow.focus();
}

function submitForm(form, action)
{
    document.forms[form].hdnAction.value = action;
}


function buildLink(link, obj)
{
    if (obj){
        var values = obj.value.split('_');
        location.href = link + values[1];
    }
    else {
        location.href = link ;
    }
}

var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

function copyData()
{
    if ($('same_data').checked)
    {
        
        
        $("denumire_adresa_bil").value = $("denumire_adresa_sh").value;
        $("prenume_adresa_bil").value = $("prenume_adresa_sh").value;
        $("nume_adresa_bil").value = $("nume_adresa_sh").value;
        $("email_adresa_bil").value = $("email_adresa_sh").value;
        $("telefon_adresa_bil").value = $("telefon_adresa_sh").value;
        $("telefon_aux_adresa_bil").value = $("telefon_aux_adresa_sh").value;
        $("adresa1_adresa_bil").value = $("adresa1_adresa_sh").value;
        $("adresa1_aux_adresa_bil").value = $("adresa1_aux_adresa_sh").value;
        $("localitate_adresa_bil").value = $("localitate_adresa_sh").value;
        $("judet_adresa_bil").value = $("judet_adresa_sh").value;
        $("codpostal_adresa_bil").value = $("codpostal_adresa_sh").value;
        $("compania_adresa_bil").value = $("compania_adresa_sh").value;
        $("siteul_compania_bil").value = $("siteul_compania_sh").value;
        
        
        $("denumire_adresa_bil").setAttribute("disabled","disabled");
        $("prenume_adresa_bil").setAttribute("disabled","disabled"); 
        $("nume_adresa_bil").setAttribute("disabled","disabled"); 
        $("email_adresa_bil").setAttribute("disabled","disabled"); 
        $("email_adresa_bil").setAttribute("disabled","disabled"); 
        $("telefon_adresa_bil").setAttribute("disabled","disabled"); 
        $("telefon_aux_adresa_bil").setAttribute("disabled","disabled"); 
        $("adresa1_adresa_bil").setAttribute("disabled","disabled"); 
        $("adresa1_aux_adresa_bil").setAttribute("disabled","disabled"); 
        $("localitate_adresa_bil").setAttribute("disabled","disabled"); 
        $("judet_adresa_bil").setAttribute("disabled","disabled"); 
        $("codpostal_adresa_bil").setAttribute("disabled","disabled"); 
        $("compania_adresa_bil").setAttribute("disabled","disabled"); 
        $("siteul_compania_bil").setAttribute("disabled","disabled"); 
    }
    else
    {
        
        $("denumire_adresa_bil").removeAttribute("disabled");
        $("prenume_adresa_bil").removeAttribute("disabled");
        $("nume_adresa_bil").removeAttribute("disabled");
        $("email_adresa_bil").removeAttribute("disabled");
        $("email_adresa_bil").removeAttribute("disabled");
        $("telefon_adresa_bil").removeAttribute("disabled");
        $("telefon_aux_adresa_bil").removeAttribute("disabled");
        $("adresa1_adresa_bil").removeAttribute("disabled");
        $("adresa1_aux_adresa_bil").removeAttribute("disabled");
        $("localitate_adresa_bil").removeAttribute("disabled");
        $("judet_adresa_bil").removeAttribute("disabled");
        $("codpostal_adresa_bil").removeAttribute("disabled");
        $("compania_adresa_bil").removeAttribute("disabled");
        $("siteul_compania_bil").disabled=false;
    }
}
    
function rollOverImage(img,number)
{
  $('imagine_mare_product').src = img;
  $('imagine_mare_product_number').value = number;    
}

function goPage(page)
{
    $('page').value=page;
    document.aspnetForm.submit();
}
function changeElementsNumber(obj)
{
    $('elementsOnPage').value=$(obj).options[$(obj).selectedIndex].value;
    document.aspnetForm.submit();
}
function goFilter(filter)
{
    $('filterID').value = $(filter).options[$(filter).selectedIndex].value;
    document.aspnetForm.submit();
}
    
    
    
function search(object_input,object_list)
{       
    var objct = document.getElementById(object_list).options;
    var len = objct.length;
    if (len >0) 
    {                       
        var i=0;            
        for (i=0; i<len; i++)
        {                        
            if (objct[i].innerHTML.match(document.getElementById(object_input).value))
            {	                        
                objct.selectedIndex=i;
                return;
            }
        }	                
    }        
}
