function openPopUpImage(url,w,h){
	 var iwidth=w, iheight=h;
	 {
		popUpWin=window.open(url,'NewWindow','marginwidth=0,marginheight=0,leftmargin=0,topmargin=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width='+(iwidth)+',height='+(iheight));
	 }
}
function openPopUpZoom(url,w,h){
	 var iwidth=w, iheight=h;
	 {
		popUpWin=window.open(url,'NewWindow','marginwidth=0,marginheight=0,leftmargin=0,topmargin=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width='+(iwidth)+',height='+(iheight));
	 }
}

function openPopUpZoom_scroll(url,w,h){
	 var iwidth=w, iheight=h;
	 {
		popUpWin=window.open(url,'NewWindow','marginwidth=0,marginheight=0,leftmargin=0,topmargin=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width='+(iwidth)+',height='+(iheight));
	 }
}

<!-- functie pt control cimpuri numerice :: accept numai cifre -->
function digONLY(obj) {
	obj.value=obj.value.replace(/\D/g,'')
}

function increment(nume_var, numele, nume_form){
	if(nume_var.value==99){
		alert('Maxim 99 de produse.');
		exit;
	}
	//nume_var=ParseInt(nume_var);
	nume_var.value=nume_var.value*1+1;
	//eval("document."+nume_form+"."+numele+".value='"+nume_var.value+"'");
}
	
function decrement(nume_var, numele, nume_form){
	//nume_var=ParseInt(nume_var);

	if(nume_var.value==1){
		if(confirm('Confirmati stergerea produsului ?')){
			nume_var.value=0;
			eval("document."+nume_form+".submit();");
			alert('Produs sters !');
		}//else
		//	return 0;
	}
	if(nume_var.value>1){
	nume_var.value=nume_var.value*1-1;
		//eval("document."+nume_form+"."+numele+".value='"+nume_var.value+"'");
	}
}
	
function insert_basket(id){
	parent.basket_frame.location='cos_right.php?id='+id;
	//eval("parent.basket_frame.location='cos_right.php?id='+id");
}

function update_basket_right(){
	parent.basket_frame.location.reload();
}
	
function check_mail(mail_input){
	var at_pos = mail_input.value.indexOf("@");
	var dot_pos = mail_input.value.indexOf(".");
	
	if(dot_pos<5)
		dot_pos = mail_input.value.indexOf(".", dot_pos+1);
	if((at_pos>1) && (dot_pos>5))
		alert(dot_pos);
}

//collection of functions => hidden div to display big thumbs 
//mouse position - a part of layer with big pic onclick
function mouse_pos(e) {
	xMousePos = 0; // Horizontal position of the mouse on the screen
	yMousePos = 0; // Vertical position of the mouse on the screen
	xMousePosMax = 0; // Width of the page
	yMousePosMax = 0; // Height of the page
	
	if (document.layers) {
	// When the page scrolls in Netscape, the event's mouse position
	// reflects the absolute position on the screen. innerHight/Width
	// is the position from the top/left of the screen that the user is
	// looking at. pageX/YOffset is the amount that the user has
	// scrolled into the page. So the values will be in relation to
	// each other as the total offsets into the page, no matter if
	// the user has scrolled or not.
		xMousePos = e.pageX;
		yMousePos = e.pageY;

		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
	} else if (document.all) {
	// When the page scrolls in IE, the event's mouse position
	// reflects the position from the top/left of the screen the
	// user is looking at. scrollLeft/Top is the amount the user
	// has scrolled into the page. clientWidth/Height is the height/
	// width of the current page the user is looking at. So, to be
	// consistent with Netscape (above), add the scroll offsets to
	// both so we end up with an absolute value on the page, no
	// matter if the user has scrolled or not.
		xMousePos = window.event.x+document.body.scrollLeft;
		yMousePos = window.event.y+document.body.scrollTop;
		xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
		yMousePosMax = document.body.clientHeight+document.body.scrollTop;
	} else if (document.getElementById) {
	// Netscape 6 behaves the same as Netscape 4 in this regard
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
	}
	//window.status= "x: "+ xMousePos+"y: "+ yMousePos;
	coords= new Array (xMousePos, yMousePos);
	return coords;
}
//
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}

//picture layer functions
function layerObject(id, left, top, visibility) {
	this.obj = document.getElementById(id).style;
	this.obj.left = left+'px';
	this.obj.top = top+'px';
	this.obj.visibility = visibility;
	//alert('left='+left+'\ntop='+top);
	return this.obj;
}

function hide(picLayerId) {
	var visibility = 'hidden';
	floatLyr = new layerObject(picLayerId, -1300, 0, visibility);
	//layerRef = document.getElementById(picLayerId);
	//layerRef.style.visibility = 'hidden';
	//document.floatLyr.style.visibility = 'hidden';
}

function show(picLayerId, picHeight, picWidth) {
	var x_left, y_top;
	//create first
	hide(picLayerId);
	//floatLyr = new layerObject(picLayerId, 0, 0);
	//test if in frame
	var test_frame=document.location+"";
	var test2=test_frame.indexOf("_iframe");
	if(test2>=0){
		x_left=10;
		y_top=20;
	}else{
		/*
		var browserName=navigator.appName;
		if(browserName=="Microsoft Internet Explorer"){
			var coords=mouse_pos();
			x_left=Math.round(coords[0]-(picWidth));
			//y_top=(coords[1]-picHeightHalf);
			y_top=Math.round(coords[1]-(picHeight/2));
	
			//window.status="x: "+x_left+"y: "+y_top+" picH: "+picHeight;
			if(!isNumber(x_left) || x_left<1)
			//if(!(typeof x_left =='number') || x_left<1)
				x_left=400;
			if(!isNumber(y_top) || y_top<1)
				y_top=300;
		}else{
		*/
			var coords= new Array(420, 40);
			x_left=coords[0];
			y_top=Math.round((coords[1]-picHeight/2)+100);
			if(y_top<40)
				y_top=40;
		//}
	}
	floatLyr = new layerObject(picLayerId, x_left, y_top, 'visible');
}
//end layer
//end collection of functions

function openPopup(url, w, h, name){
	 var iwidth=w, iheight=h;
	 {
		popUpWin=window.open(url,name,'marginwidth=0,marginheight=0,leftmargin=0,topmargin=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width='+(iwidth)+',height='+(iheight));
	 }
}

//============================================================>check form and mail functions<============================================================
function replaceCharacters(Obj){
	var illegalChars = new Array(28);
	//define illegal characters
	illegalChars[0] = ',';
	illegalChars[1] = '!';
	illegalChars[2] = '#';
	illegalChars[3] = '$';
	illegalChars[4] = '^';
	illegalChars[5] = '*';
	illegalChars[6] = '+';
	illegalChars[7] = '=';
	illegalChars[8] = ')';
	illegalChars[9] = '(';
	illegalChars[10] = '<';
	illegalChars[11] = '>';
	illegalChars[12] = '{';
	illegalChars[13] = '}';
	illegalChars[14] = ']';
	illegalChars[15] = '[';
	illegalChars[16] = '^';
	illegalChars[17] = '|';
	illegalChars[18] = '+';
	illegalChars[19] = '=';
	illegalChars[20] = '`';
	illegalChars[21] = ' ';
	illegalChars[22] = '\\';
	illegalChars[23] = '"';
	illegalChars[24] = '\'';
	illegalChars[25] = '"';
	illegalChars[26] = ';';
	illegalChars[27] = ':';
	//get field contents
	var currentValue = Obj.value;
	var previousValue = currentValue.substr(0, (currentValue.length-1));
	//alert(previousValue);
	
	//replace them with null :)
	for(i=0;i<illegalChars.length;i++){
		var illegalPos = Obj.value.indexOf(illegalChars[i]);
		if(illegalPos>-1)
			Obj.value = previousValue;
	}
	return;
}
//telephone numbers (digits and -/+)
function phoneCharsOnly(obj) {
	obj.value=obj.value.replace(/[^0-9^+^-]/g,'')
}
//check mail function
function basicMailCheck(string){
	var err_mail=0, illegalPos=-1;
	var email = string;
	//define illegal chars:
	var illegalChars = new Array(18);
	illegalChars[0] = ',';
	illegalChars[1] = '!';
	illegalChars[2] = '#';
	illegalChars[3] = '$';
	illegalChars[4] = '^';
	illegalChars[5] = '*';
	illegalChars[6] = '+';
	illegalChars[7] = '=';
	illegalChars[8] = ')';
	illegalChars[9] = '(';
	illegalChars[10] = '<';
	illegalChars[11] = '>';
	illegalChars[12] = '{';
	illegalChars[13] = '}';
	illegalChars[14] = ']';
	illegalChars[15] = '[';
	illegalChars[16] = '^';
	illegalChars[17] = '|';
	//STEP 1: check for illegalChars
	for(i=0;i<illegalChars.length;i++){
		illegalPos = email.indexOf(illegalChars[i])*1;
		if(illegalPos>-1){
			//alert(illegalChars[i]);
			return 1;
		}
	}
	//STEP 2: check for e-mail correct structure
	var posAt = (email.indexOf('@')*1);
	var posDot = (email.indexOf('.', posAt)*1);
	var strLength = email.length*1;
	
	if(posAt<2 || posDot<posAt || (strLength<(posDot+3) || strLength>(posDot+4)))
		err_mail=1;
	//end check
	return err_mail;
}
function verifyForm(formName){
	var text_alert='';
	//define alert texts
	var text_name = 'Va rugam completati numele Dumneavoastra.\n';
	var text_mail = 'Verificati adresa de e-mail.\n';
	var text_telefon = 'Introduceti un numar de telefon sau fax.\n';
	var text_search = 'Sir de cautare prea scurt. Lungimea minima este de 4 caractere.\n';
	var text_adresa = 'Va rugam completati adresa Dumneavoastra.\n';

	if(formName='request'){
		var mail = eval("document."+formName+".fr_email.value");
		var mail_err = basicMailCheck(mail);

		var name = eval("document."+formName+".fr_nume.value");
		var telefon = eval("document."+formName+".fr_telefon.value");
		var adresa = eval("document."+formName+".fr_adresa.value");

		if(mail_err!=1 && name!='' && telefon!=''){
			eval("document."+formName+".submit()");
			return;
		}else{
			if(name=='')
				text_alert+=text_name;
			if(mail_err==1)
				text_alert+=text_mail;
			if(telefon=='')
				text_alert+=text_telefon;
			if(adreasa=='')
				text_alert+=text_adresa;
			alert(text_alert);
			return;
		}

	}
}
