// JavaScript Document
// JavaScript Document
//Ajax Start
//Pro Class
//Form Validation
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 validate(field,type,err_mes){
	var fld=document.getElementById(field).value;
	var text=/^[a-zA-Z\.\-]*$/;
	var textnum=/^\w+$/;
	var int=/^[\+\-]?\d*$/;
	var phone=/^[\d\.\s\-]+$/;
	var rdate=/^(\d{1,2})\-(\d{1,2})\-(\d{4})$/;
	var email=/^[\w-\.]+\@[\w\.-]+\.[a-z]{2,4}$/;
	var rtrn=true;
	switch (type) {
		case 'text' :				
				if(fld=='') {
					alert ('Λάθος τιμή στο \"'+err_mes+'\"');
					document.getElementById(field).focus();
					document.getElementById(field).value='';
					rtrn=false;
				}
				break;		
		case 'int' :				
				if(!int.test(Number(fld)) || fld=='') {
					alert ('Λάθος τιμή στο \"'+err_mes+'\"');
					document.getElementById(field).focus();
					document.getElementById(field).value='';
					rtrn=false;
				}
				break;						
		case 'date' :				
				if(!rdate.test(fld) || fld=='') {
					alert ('Λάθος τιμή στο \"'+err_mes+'\"');
					document.getElementById(field).focus();
					document.getElementById(field).value='';
					rtrn=false;
				}
				break;	
		case 'mail' :				
				if(!email.test(fld) || fld=='') {
					alert ('Λάθος τιμή στο \"'+err_mes+'\"');
					document.getElementById(field).focus();
					document.getElementById(field).value='';
					rtrn=false;
				}
				break;									
	}
	return rtrn;
}

function chkfrm(){
var flds=new Array('user_eponimia,text,επωνυμία εταιρείας ',
				'user_drastiriotita,text,δραστηριότητα ',
				'user_name,text,υπεύθυνος επικοινωνίας  ',
				'user_thesi,text,θέση στην εταιρεία ',
				'user_address,text,διεύθυνση  ',				
				'user_city,text,πόλη ',
				'user_phone,text,τηλέφωνο ',								
				'user_mail,mail,email ',								
				'user_pass,text,κωδικός ',								
				'retype_pass,text,επαλήθευση κωδικού  ',	
				'validation,text,κλειδί ασφαλείας ');
	for(i=0;i<flds.length;i++) {
		str=flds[i].split(',');
		if(!validate(str[0],str[1],str[2]))
			return false;
	}	
	return true;
}

function chkfrm2(){
var flds=new Array('user_eponimia,text,επωνυμία εταιρείας',	
				'user_name,text,υπεύθυνος επικοινωνίας  ',				
				'user_address,text,διεύθυνση  ',
				'user_zip,text,Τ.Κ.',
				'user_city,text,πόλη ',
				'user_phone,text,τηλέφωνο ',	
				'user_pass,text,κωδικός εισόδου ',					
				'user_repass,text,Eπαλήθευση κωδικού ',					
				'user_mail,mail,email ',												
				'validation,text,κλειδί ασφαλείας');
	for(i=0;i<flds.length;i++) {
		str=flds[i].split(',');
		if(!validate(str[0],str[1],str[2]))
			return false;
	}	
	return true;
}
// End From Validation
function intOnly(i) {
	if(i.value.length>0) {
		i.value = i.value.replace(/[^\d.]+/, ''); 
	}
 
}

function to_cart(data){
	var params=new Array("id","desc","siskevasia","price","quanity","module","pid","cid","cdesc","csubid","csubdesc");
	var values=data.split('|');
	var querystring='?';
	for(i=0;i<params.length;i++)
		querystring+=params[i]+"="+values[i]+"&";	
	querystring+="sec="+Math.round(Math.random()*500000);	
	location.href="to_cart.php"+querystring;
}

function to_cart(data){
	var params=new Array("id","desc","siskevasia","price","quanity","module","pid","cid","cdesc","csubid","csubdesc");
	var values=data.split('|');
	var querystring='?';
	for(i=0;i<params.length;i++)
		querystring+=params[i]+"="+values[i]+"&";	
	querystring+="sec="+Math.round(Math.random()*500000);	
	location.href="to_cart.php"+querystring;
}

function Product(aa,id,desc,loipa,info,odigies,syskevasies,cdesc,csubdesc,pdf,relatives) {
	this.aa=aa;
	this.id=id;
	this.loipa=loipa;
	this.desc=desc;
	this.info=info;
	this.odigies=odigies;
	this.syskevasies=syskevasies;
	this.cdesc=cdesc;
	this.csubdesc=csubdesc;
	this.pdf=pdf;
	this.relatives=relatives;
	
//	this.siskevasies=siskevasies;
	this.show_product=function () {
			return (this.aa+1)+'/'+Products.length+'<br>'+this.id+'<br>'+this.desc+'<br>'+this.info+'<br>'+this.odigies+','+this.syskevasies+','+this.pdf+','+this.relatives;
		}		
}
var car_product=0;
var Products=new Array();
//End Pro Class

var xmlHttp;
var text=new String();
//Banner Ajax
function show_banner(ccid,lang)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="lib/banner_add.php"
url=url+"?data="+ccid
url=url+"&sid="+Math.random()
url=url+"&lang="+lang
xmlHttp.onreadystatechange=banner_stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function banner_stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	text=xmlHttp.responseText;	
	text_array=text.split('|');
	
	if(document.getElementById('produnts_container')){
		document.getElementById('produnts_container').innerHTML='';
		document.getElementById('cc_banner_container').style.display='block';
		document.getElementById('ccid_banner_left').innerHTML=text_array[0];
		//document.getElementById('ccid_text').innerHTML=text_array[1];
		document.getElementById('ccid_photo').style.backgroundImage="url('images/"+text_array[2]+".jpg')";
	}
	
 }
}

//End Banner Ajax
var xmlDoc='';
function loadXML(xmlFile) 
{ 
		feed_file = xmlFile;
		if (window.XMLHttpRequest)		
		  xhttp=new window.XMLHttpRequest() 
		else  
		  xhttp=new ActiveXObject("Microsoft.XMLHTTP")  
		xhttp.open("GET",xmlFile,false);
		xhttp.send("");
		xmlDoc=xhttp.responseXML;
}

function view_pro(lang,aa,cdesc,csubdesc)
{
	car_product=Number(aa);
 	w=document.documentElement.clientWidth;
	h=document.documentElement.clientHeight;
	obj=document.getElementById("ajaxWin");
	document.getElementById("ajaxWinBG").style.visibility='visible';
	document.getElementById("ajaxWinBG").style.marginLeft=0;
	document.getElementById("ajaxWinBG").style.marginTop=0;
	document.getElementById("ajaxWinBG").style.width=w+"px";
	document.getElementById("ajaxWinBG").style.height=h;	
	document.getElementById("ajaxWin").style.visibility='visible';
	document.getElementById("ajaxWinBG").style.opacity=0.5;
	document.getElementById("ajaxWinHdr").innerHTML=cdesc+' | '+csubdesc;	
	loadXML('lang/'+lang+'.xml');
	show_pro(aa);
	dw=obj.offsetWidth.toString();
	dh=obj.offsetHeight.toString();
	obj.style.marginLeft=(w-dw)/2+"px";
	obj.style.marginTop=(h-dh)/2+"px";
}

function  prev_pro(){
	if(car_product>0)
			car_product--;			
	show_pro(car_product);			
}

function  next_pro(){
	if(car_product<(Products.length-1))
		car_product++;		
	show_pro(car_product);		
}
var curpro_data="";
function show_pro(aa){		
	var kodikos=xmlDoc.getElementsByTagName("kodikos")[0].childNodes[0].nodeValue;
	var Perigrafi=xmlDoc.getElementsByTagName("desc")[0].childNodes[0].nodeValue;
	var Loipa=xmlDoc.getElementsByTagName("loipa")[0].childNodes[0].nodeValue;
	var Info=xmlDoc.getElementsByTagName("pinfo")[0].childNodes[0].nodeValue;
	var Odigies=xmlDoc.getElementsByTagName("odigies")[0].childNodes[0].nodeValue;
	var Siskevasies=xmlDoc.getElementsByTagName("siskevasies")[0].childNodes[0].nodeValue;
	var Prev=xmlDoc.getElementsByTagName("prev")[0].childNodes[0].nodeValue;
	var Next=xmlDoc.getElementsByTagName("next")[0].childNodes[0].nodeValue;	
	var Price=xmlDoc.getElementsByTagName("price")[0].childNodes[0].nodeValue;	
	var Temaxia=xmlDoc.getElementsByTagName("temaxia")[0].childNodes[0].nodeValue;		
	var sendtofirend=xmlDoc.getElementsByTagName("sendtofirend")[0].childNodes[0].nodeValue;		
	var printer=xmlDoc.getElementsByTagName("print")[0].childNodes[0].nodeValue;			
	var str=Products[aa].syskevasies;
	var popmess=xmlDoc.getElementsByTagName("popmess")[0].childNodes[0].nodeValue;
	var pro_sys=str.split('|');
	//alert(Products[aa].pdf);
	var pro_text='';
	for (i=0;i<pro_sys.length-1;i++){
		pro_text+="<tr><td class=\"epikefalida_titlos\">"+pro_sys[i]+"</td><td  class=\"epikefalida_timi\">"+pro_sys[i+1]+" &euro;</td><td></td></tr>";
		i++;
	}
	var odigies_text=Url.decode(Products[aa].odigies);
	var info_text=Url.decode(Products[aa].info);
	odigies_text=odigies_text.replace(/&nbsp;/gi,' ');
	info_text=info_text.replace(/&nbsp;/gi,' ');	
	if(Products[aa].pdf==1)
		popup="window.open('docs/"+Products[aa].id.replace(/-/g,'_')+".pdf','_blank')";
	else
		popup="javascript:alert('"+popmess+"')";
	var container="<table width=\"750\" border=\"0\"><tr><td colspan=\"2\" align=\"left\" style=\"font-size:16px\" class=\"titlos_3\">"+Products[aa].desc+"</td></tr><tr><td align=\"left\"><img src=\"images/dyn_img/products/big/"+Products[aa].id+".jpg\" /></td><td align=\"left\" valign=\"top\">"+kodikos+" : <span style=\"color:#000000\"><b>"+Products[aa].id.replace(/_/g,'-')+"</b></span><br /><br />"+Loipa+" : <span style=\"color:#000000\"><b>"+Products[aa].loipa+"</b><br /><br />"+Info+" : <span style=\"color:#000000\"><b>"+info_text.replace('&nbsp;',' ')+"</b><br /><br />"+Odigies+" : <span style=\"color:#000000\"><b>"+odigies_text.replace('&nbsp;',' ')+"<p><table width=\"100%\" cellpadding=\"3\" border=\"0\"><tr bgcolor=\"#e2e2e2\"><td class=\"epikefalida\" align=\"left\">"+Siskevasies+"</td><td  class=\"epikefalida\" align=\"center\">"+Price+"</td><td  class=\"epikefalida\" align=\"right\">"+Temaxia+"</td></tr>"+pro_text+"</table></p></td></tr><tr><td colspan=\"2\">";
	//σχετικά προϊόντα
	if(Products[aa].relatives!=""){
		document.getElementById("ajaxWinBG").style.marginTop=document.getElementById("ajaxWinBG").style.marginTop+50+"px";
		var prodlist=new String(Products[aa].relatives);
		var prods=prodlist.split(",");
		container+="<center><hr width=\"100%\" noshade size=\"1\" color=\"#eeeeee\" /></center>";
		container+="<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\"><tr>";
		for(i=0;i<prods.length;i++){
			curpro=prods[i];
			ajax_load_pro(curpro);			
			container+="<td align=\"center\" valign=\"bottom\"><a href=\"javascript:load_pro('"+curpro+"')\" title=\""+curpro_data[4]+"\"><img alt=\""+curpro_data[4]+"\" border=\"0\" src=\"images/dyn_img/products/"+curpro.replace(/-/g,"_")+".jpg\" hspace=\"5\" /></a><br />"+curpro_data[4]+"</td>";
		}
	}	container+="</tr></table>";
	container+="<table width=\"100%\"><tr><td><div id=\"pro_prev\" onClick=\"prev_pro()\"><a href=\"#\">"+Prev+"</a></div></td><td><div class=\"buttons\" onClick=\""+popup+"\"><img src=\"images/pdf_ico.gif\" align=\"absmiddle\" height=\"20\" hspace=\"10\" />"+sendtofirend+"</div></td><td><div class=\"buttons\" onClick=\"self.print()\"><img src=\"images/print.gif\" align=\"absmiddle\" />"+printer+"</div></td><td><div id=\"pro_next\" onClick=\"next_pro()\"><a href=\"#\">"+Next+"</a></td></tr></table></div></td></tr></table>";
	document.getElementById("ajaxWinBody").innerHTML=container;
	document.getElementById("ajaxWinHdr").innerHTML=Products[aa].cdesc+" | "+Products[aa].csubdesc;
	document.getElementById("pages_data").innerHTML=(car_product+1)+" / "+(Products.length);
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function hide_con(){
	document.getElementById("ajaxWinBG").style.visibility='hidden';
	document.getElementById("ajaxWin").style.visibility='hidden';	
}
//Ajax End
function view_product(catalog_product_id){
		alert(catalog_product_id);
}

function load_cv_form(job_id,job_desc){
	var text="<form style=\"margin:0px;padding:10px;background-color:#e0e0e0;border:solid 1px #cccccc\" action=\"upload_cv.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\" id=\"form1\">Επιλέξτε το αρχείο του βιογραφικού σας :<input type=\"hidden\" name=\"job_id\" value=\""+job_id+"\" /><input type=\"hidden\" name=\"job_desc\" value=\""+job_desc+"\" /><input type=\"file\" name=\"file\" id=\"file\" /><br>Συνοδευτικό σχόλιο : <textarea name=\"jobs_text\"></textarea><br><input type=\"submit\" value=\"  Αποστολή  \" /><br><span style=\"font-size:10px;color:#666666;padding:2px\">Το αρχείο θα πρέπει να είναι σε μορφή Word (.doc) ή Acrobat Reader (.pdf)</span></form>";
	document.getElementById("send_cv").innerHTML=text;
}

function signup(){
	document.getElementById("newsletter_content").innerHTML="<form action=\"lib/signup.php\" method=\"post\">Δώσε email :<br><input type=\"text\" size=\"35\" name=\"email\" /><br><input type=\"submit\" value=\"Sign Up\" /></form>";
}

function prodsListing(editor){	
	var mywin=window.open('prodsListing.php?name='+editor,'','top=100,left=100,width=800,height=500,scrollbars=yes');
}
var xmlhttp;
function set_sub_cats(ccid){	

xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET","admin/get_csubs.php?ccid="+ccid,true);
xmlhttp.send(null);
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
	var i;
	for(i=document.getElementById("catalog_products_subcategory").options.length-1;i>=1;i--)
	{
		//selectbox.options.remove(i);
		document.getElementById("catalog_products_subcategory").remove(i);
	}

	var opts=xmlhttp.responseText;
	var opts_arr=opts.split('|');
	var opt = document.createElement("OPTION");
	for(i=0;i<opts_arr.length-1;i++){
		opt = document.createElement("OPTION");
		var cur_opts=opts_arr[i];
		var final_opts=cur_opts.split(',');
			opt.text=final_opts[1];
			opt.value=final_opts[0];		
		document.getElementById("catalog_products_subcategory").options.add(opt);
	}
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}


// mredkj.com
function NumberFormat(num, inputDecimal)
{
this.VERSION = 'Number Format v1.5.4';
this.COMMA = ',';
this.PERIOD = '.';
this.DASH = '-'; 
this.LEFT_PAREN = '('; 
this.RIGHT_PAREN = ')'; 
this.LEFT_OUTSIDE = 0; 
this.LEFT_INSIDE = 1;  
this.RIGHT_INSIDE = 2;  
this.RIGHT_OUTSIDE = 3;  
this.LEFT_DASH = 0; 
this.RIGHT_DASH = 1; 
this.PARENTHESIS = 2; 
this.NO_ROUNDING = -1 
this.num;
this.numOriginal;
this.hasSeparators = false;  
this.separatorValue;  
this.inputDecimalValue; 
this.decimalValue;  
this.negativeFormat; 
this.negativeRed; 
this.hasCurrency;  
this.currencyPosition;  
this.currencyValue;  
this.places;
this.roundToPlaces; 
this.truncate; 
this.setNumber = setNumberNF;
this.toUnformatted = toUnformattedNF;
this.setInputDecimal = setInputDecimalNF; 
this.setSeparators = setSeparatorsNF; 
this.setCommas = setCommasNF;
this.setNegativeFormat = setNegativeFormatNF; 
this.setNegativeRed = setNegativeRedNF; 
this.setCurrency = setCurrencyNF;
this.setCurrencyPrefix = setCurrencyPrefixNF;
this.setCurrencyValue = setCurrencyValueNF; 
this.setCurrencyPosition = setCurrencyPositionNF; 
this.setPlaces = setPlacesNF;
this.toFormatted = toFormattedNF;
this.toPercentage = toPercentageNF;
this.getOriginal = getOriginalNF;
this.moveDecimalRight = moveDecimalRightNF;
this.moveDecimalLeft = moveDecimalLeftNF;
this.getRounded = getRoundedNF;
this.preserveZeros = preserveZerosNF;
this.justNumber = justNumberNF;
this.expandExponential = expandExponentialNF;
this.getZeros = getZerosNF;
this.moveDecimalAsString = moveDecimalAsStringNF;
this.moveDecimal = moveDecimalNF;
this.addSeparators = addSeparatorsNF;
if (inputDecimal == null) {
this.setNumber(num, this.PERIOD);
} else {
this.setNumber(num, inputDecimal); 
}
this.setCommas(true);
this.setNegativeFormat(this.LEFT_DASH); 
this.setNegativeRed(false); 
this.setCurrency(false); 
this.setCurrencyPrefix('$');
this.setPlaces(2);
}
function setInputDecimalNF(val)
{
this.inputDecimalValue = val;
}
function setNumberNF(num, inputDecimal)
{
if (inputDecimal != null) {
this.setInputDecimal(inputDecimal); 
}
this.numOriginal = num;
this.num = this.justNumber(num);
}
function toUnformattedNF()
{
return (this.num);
}
function getOriginalNF()
{
return (this.numOriginal);
}
function setNegativeFormatNF(format)
{
this.negativeFormat = format;
}
function setNegativeRedNF(isRed)
{
this.negativeRed = isRed;
}
function setSeparatorsNF(isC, separator, decimal)
{
this.hasSeparators = isC;
if (separator == null) separator = this.COMMA;
if (decimal == null) decimal = this.PERIOD;
if (separator == decimal) {
this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
} else {
this.decimalValue = decimal;
}
this.separatorValue = separator;
}
function setCommasNF(isC)
{
this.setSeparators(isC, this.COMMA, this.PERIOD);
}
function setCurrencyNF(isC)
{
this.hasCurrency = isC;
}
function setCurrencyValueNF(val)
{
this.currencyValue = val;
}
function setCurrencyPrefixNF(cp)
{
this.setCurrencyValue(cp);
this.setCurrencyPosition(this.LEFT_OUTSIDE);
}
function setCurrencyPositionNF(cp)
{
this.currencyPosition = cp
}
function setPlacesNF(p, tr)
{
this.roundToPlaces = !(p == this.NO_ROUNDING); 
this.truncate = (tr != null && tr); 
this.places = (p < 0) ? 0 : p; 
}
function addSeparatorsNF(nStr, inD, outD, sep)
{
nStr += '';
var dpos = nStr.indexOf(inD);
var nStrEnd = '';
if (dpos != -1) {
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, '$1' + sep + '$2');
}
return nStr + nStrEnd;
}
function toFormattedNF()
{	
var pos;
var nNum = this.num; 
var nStr;            
var splitString = new Array(2);   
if (this.roundToPlaces) {
nNum = this.getRounded(nNum);
nStr = this.preserveZeros(Math.abs(nNum)); 
} else {
nStr = this.expandExponential(Math.abs(nNum)); 
}
if (this.hasSeparators) {
nStr = this.addSeparators(nStr, this.PERIOD, this.decimalValue, this.separatorValue);
} else {
nStr = nStr.replace(new RegExp('\\' + this.PERIOD), this.decimalValue); 
}
var c0 = '';
var n0 = '';
var c1 = '';
var n1 = '';
var n2 = '';
var c2 = '';
var n3 = '';
var c3 = '';
var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
if (this.currencyPosition == this.LEFT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c0 = this.currencyValue;
} else if (this.currencyPosition == this.LEFT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c1 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c2 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c3 = this.currencyValue;
}
nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
if (this.negativeRed && nNum < 0) {
nStr = '<font color="red">' + nStr + '</font>';
}
return (nStr);
}
function toPercentageNF()
{
nNum = this.num * 100;
nNum = this.getRounded(nNum);
return nNum + '%';
}
function getZerosNF(places)
{
var extraZ = '';
var i;
for (i=0; i<places; i++) {
extraZ += '0';
}
return extraZ;
}
function expandExponentialNF(origVal)
{
if (isNaN(origVal)) return origVal;
var newVal = parseFloat(origVal) + ''; 
var eLoc = newVal.toLowerCase().indexOf('e');
if (eLoc != -1) {
var plusLoc = newVal.toLowerCase().indexOf('+');
var negLoc = newVal.toLowerCase().indexOf('-', eLoc); 
var justNumber = newVal.substring(0, eLoc);
if (negLoc != -1) {
var places = newVal.substring(negLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, true, parseInt(places));
} else {
if (plusLoc == -1) plusLoc = eLoc;
var places = newVal.substring(plusLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, false, parseInt(places));
}
newVal = justNumber;
}
return newVal;
} 
function moveDecimalRightNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, false);
} else {
newVal = this.moveDecimal(val, false, places);
}
return newVal;
}
function moveDecimalLeftNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, true);
} else {
newVal = this.moveDecimal(val, true, places);
}
return newVal;
}
function moveDecimalAsStringNF(val, left, places)
{
var spaces = (arguments.length < 3) ? this.places : places;
if (spaces <= 0) return val; 
var newVal = val + '';
var extraZ = this.getZeros(spaces);
var re1 = new RegExp('([0-9.]+)');
if (left) {
newVal = newVal.replace(re1, extraZ + '$1');
var re2 = new RegExp('(-?)([0-9]*)([0-9]{' + spaces + '})(\\.?)');		
newVal = newVal.replace(re2, '$1$2.$3');
} else {
var reArray = re1.exec(newVal); 
if (reArray != null) {
newVal = newVal.substring(0,reArray.index) + reArray[1] + extraZ + newVal.substring(reArray.index + reArray[0].length); 
}
var re2 = new RegExp('(-?)([0-9]*)(\\.?)([0-9]{' + spaces + '})');
newVal = newVal.replace(re2, '$1$2$4.');
}
newVal = newVal.replace(/\.$/, ''); 
return newVal;
}
function moveDecimalNF(val, left, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimalAsString(val, left);
} else {
newVal = this.moveDecimalAsString(val, left, places);
}
return parseFloat(newVal);
}
function getRoundedNF(val)
{
val = this.moveDecimalRight(val);
if (this.truncate) {
val = val >= 0 ? Math.floor(val) : Math.ceil(val); 
} else {
val = Math.round(val);
}
val = this.moveDecimalLeft(val);
return val;
}
function preserveZerosNF(val)
{
var i;
val = this.expandExponential(val);
if (this.places <= 0) return val; 
var decimalPos = val.indexOf('.');
if (decimalPos == -1) {
val += '.';
for (i=0; i<this.places; i++) {
val += '0';
}
} else {
var actualDecimals = (val.length - 1) - decimalPos;
var difference = this.places - actualDecimals;
for (i=0; i<difference; i++) {
val += '0';
}
}
return val;
}
function justNumberNF(val)
{
newVal = val + '';
var isPercentage = false;
if (newVal.indexOf('%') != -1) {
newVal = newVal.replace(/\%/g, '');
isPercentage = true; 
}
var re = new RegExp('[^\\' + this.inputDecimalValue + '\\d\\-\\+\\(\\)eE]', 'g');	
newVal = newVal.replace(re, '');
var tempRe = new RegExp('[' + this.inputDecimalValue + ']', 'g');
var treArray = tempRe.exec(newVal); 
if (treArray != null) {
var tempRight = newVal.substring(treArray.index + treArray[0].length); 
newVal = newVal.substring(0,treArray.index) + this.PERIOD + tempRight.replace(tempRe, ''); 
}
if (newVal.charAt(newVal.length - 1) == this.DASH ) {
newVal = newVal.substring(0, newVal.length - 1);
newVal = '-' + newVal;
}
else if (newVal.charAt(0) == this.LEFT_PAREN
&& newVal.charAt(newVal.length - 1) == this.RIGHT_PAREN) {
newVal = newVal.substring(1, newVal.length - 1);
newVal = '-' + newVal;
}
newVal = parseFloat(newVal);
if (!isFinite(newVal)) {
newVal = 0;
}
if (isPercentage) {
newVal = this.moveDecimalLeft(newVal, 2);
}
return newVal;
}

function sendarticle(newsid){
	var text="<form style=\"margin:10px; padding:5px;border:solid 1px #eee\" action=\"postal.php\" method=\"post\"><input type=\"hidden\" name=\"newsid\" value=\""+newsid+"\" />Όνομα Αποστολέα :<input type=\"text\" name=\"myname\" size=\"30\" /> Email Αποστολέα :<input type=\"text\" name=\"myemail\" size=\"30\" /><br />			Όνομα Παραλήπτη :<input type=\"text\" name=\"hisname\" size=\"30\" /> Email Παραλήπτη :<input type=\"text\" name=\"hisemail\" size=\"30\" /><br /><br /><center><input type=\"submit\" value=\" Αποστολή \" /> <input type=\"reset\" value=\" Καθαρισμός \" /></center></form>";
	document.getElementById('sendarticle').innerHTML=text;	
}

//add a new row to the table   
   function addRow()
   {
	var id=Math.ceil(10000*Math.random());
    //add a row to the rows collection and get a reference to the newly added row
    var newRow = document.getElementById("tblGrid").insertRow(-1);
    
    //add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes
    
    var oCell = newRow.insertCell(0);
    oCell.innerHTML = '<input type="text" size="8" name="id[]" id="item_'+id+'" value="" /><img style="cursor:pointer" alt="Επιβεβαίωση προϊόντος" onclick="confirm_item('+id+')" hspace="5" src="images/confirm.gif" align="absmiddle"/><span id="loading_'+id+'"></span>';
	
    oCell = newRow.insertCell(1);
	oCell.innerHTML ='<span id="'+id+'_desc">&nbsp;</span><input type="hidden" id="per_'+id+'" name="perigrafes[]"/>';
	
    oCell = newRow.insertCell(2);
    oCell.innerHTML = '<span id="'+id+'_sys">&nbsp;</span><input type="hidden" id="sys_'+id+'" size="25" name="syskevasies[]" value="" />';
    
    oCell = newRow.insertCell(3);
    oCell.innerHTML = '<input type="text" size="3" name="temaxia[]" value="1"/>';
    
	oCell = newRow.insertCell(4);
	oCell.innerHTML ='<input type="button" name="'+id+'" id="'+id+'" onclick="removeRow(this);" value="διαγραφή"/>';   
   }
   
   //deletes the specified row from the table
   function removeRow(src)
   {
    /* src refers to the input button that was clicked. 
       to get a reference to the containing <tr> element,
       get the parent of the parent (in this case <tr>)
    */   	
    var oRow = src.parentNode;  
	
    var theRow = oRow.parentNode;
    //once the row reference is obtained, delete it passing in its rowIndex   
    document.getElementById("tblGrid").deleteRow(theRow.rowIndex);  

   }
   var item_id;
   
   function confirm_item(id){	
		
		item_id=id;
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }
		var url="lib/loadid.php"
		url=url+"?data="+document.getElementById("item_"+id).value
		url=url+"&sid="+Math.random()		
		xmlHttp.onreadystatechange=id_stateChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)   	
		document.getElementById("loading_"+id).innerHTML='<img src="images/loading.gif" align="absmiddle" hspace="5"/>';   
   }
   
   //Banner Ajax

function id_stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		text=xmlHttp.responseText;	
		data=text.split('|');
		document.getElementById(item_id+"_desc").innerHTML=data[0];
		document.getElementById("per_"+item_id).value=data[0];
		document.getElementById(item_id+"_sys").innerHTML=data[1];
		document.getElementById("sys_"+item_id).value=data[1];
		document.getElementById("loading_"+item_id).innerHTML='';
	 }	 
		
}
//End Banner Ajax

function ajax_load_pro(id)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="lib/load_pro.php"
url=url+"?id="+id;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=load_pro_stateChanged 
xmlHttp.open("GET",url,false);
xmlHttp.send(null);
}


function load_pro_stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	var text=xmlHttp.responseText;		
	curpro_data=text.split('|');	
 }
}

function prn_pro(lang){
	loadXML('lang/'+lang+'.xml');
	var prnwin=window.open('','','top=0,left=0,width=700,height=500,scrollbars=1');
	prnwin.document.write("<html><head><style> body {font-size:10px;} img{border:0px;}</style><title>..:: Glass Cleaning ::.. Τα πάντα για την καθαριότητα και την υγιεινή</title></head><body style=\"font-family:verdana;font-size:12px\">"+document.getElementById('product_container').innerHTML);
	prnwin.document.getElementById('tp1').innerHTML=" ";
	if(prnwin.document.getElementById('pro_nav'))
		prnwin.document.getElementById('pro_nav').innerHTML="";
	if(prnwin.document.getElementById('product_path'))
		prnwin.document.getElementById('product_path').innerHTML="<img src=\"images/logo_text_gr.gif\"><hr />";	
	if(document.getElementById('pinfotitle'))
		prnwin.document.write(document.getElementById("pinfotitle").innerHTML+"<br/><br/>"+document.getElementById("pinfodata").innerHTML+"<br><br>");	

	if(document.getElementById('odigiestitle'))
		prnwin.document.write(document.getElementById("odigiestitle").innerHTML+"<br/><br/>"+document.getElementById("odigiesdata").innerHTML+"<br><br>");		
	
	if(document.getElementById('loipatitle'))
		prnwin.document.write(document.getElementById("loipatitle").innerHTML+"<br/><br/>"+document.getElementById("loipadata").innerHTML+"<br><br>");				
		
	if(prnwin.document.getElementById('relatives'))
		prnwin.document.getElementById('relatives').innerHTML="";		
	prnwin.document.write("<hr />"+document.getElementById('fcol_b').innerHTML+"</body></html>");	
	prnwin.document.close();
	prnwin.focus();
	prnwin.print();
	prnwin.close();
}
function removeNode(n){    
    n.parentNode.removeChild(n);	
}

function prn_order(){	
	var prnwin=window.open('','','top=0,left=0,width=700,height=500,scrollbars=1');
	prnwin.document.write("<html><head><style> body,titlos,plain_text {font-size:10px;} img{border:0px;}</style><title>..:: Glass Cleaning ::.. Τα πάντα για την καθαριότητα και την υγιεινή</title></head><body style=\"font-family:verdana;font-size:10px\"><img src=\"images/logo_text_gr.gif\" border=\"0\" height=\"103\" width=\"490\">"+document.getElementById('basorder').innerHTML);		
	prnwin.document.write("<hr />"+document.getElementById('fcol_b').innerHTML+"</body></html>");	
	prnwin.document.close();	
	if(prnwin.document.getElementById('top_menu'))
		prnwin.document.getElementById('top_menu').style.display="none";
	if(prnwin.document.getElementById('infotext'))
		prnwin.document.getElementById('infotext').style.display="none";

	var a = prnwin.document.getElementsByTagName("A");
    for(var i=0;i<a.length;i++){        
            a[i].style.display="none";;     			
    }
	if(prnwin.document.getElementById('bottom_menu_1'))
		prnwin.document.getElementById('bottom_menu_1').style.display="none";
	if(prnwin.document.getElementById('bottom_menu_2'))
		prnwin.document.getElementById('bottom_menu_2').style.display="none";
	prnwin.focus();
	prnwin.print();
	prnwin.close();
}

function prn_order2(){	
	var prnwin=window.open('','','top=0,left=0,width=700,height=500,scrollbars=1');
	prnwin.document.write("<html><head><style> body,titlos,plain_text {font-size:10px;} img{border:0px;}</style><title>..:: Glass Cleaning ::.. Τα πάντα για την καθαριότητα και την υγιεινή</title></head><body style=\"font-family:verdana;font-size:10px\"><img src=\"images/logo_text_gr.gif\" border=\"0\" height=\"103\" width=\"490\"><table style=\"font-size:10px\">"+document.getElementById('recipient_data').innerHTML+"</table><hr /><table style=\"font-size:10px\">"+document.getElementById('cust_data').innerHTML+"</table><hr /><table style=\"font-size:10px\">"+document.getElementById('order_data').innerHTML+"</table><hr /><table style=\"font-size:10px\">"+document.getElementById('products_data').innerHTML+"</table><hr />");		
	prnwin.document.write("<hr />"+document.getElementById('footer_footer_content').innerHTML+"</body></html>");	
	prnwin.document.close();		
	prnwin.focus();
	prnwin.print();
	prnwin.close();
}
