// -----------------------------------------------------------------------------// Generic Javascript Functions//// Copyright (C) 2001 - 2002 BeCom S.A. http://www.becom.gr// Distributed under the terms of the GNU Library General Public License// -----------------------------------------------------------------------------// String trimming functions - S.B.// -----------------------------------------------------------------------------function bjs_ltrim(str){
	for(var i=0;str.charAt(i)==" ";i++);
	return str.substring(i,str.length);
}
function bjs_rtrim(str){
	for(var i=str.length-1;str.charAt(i)==" ";i--);
	return str.substring(0,i+1);
}
function bjs_alltrim(str){return bjs_ltrim(bjs_rtrim(str));}
// -----------------------------------------------------------------------------
//Original:  David Salsinha (david.salsinha@popsi.pt)
// -----------------------------------------------------------------------------function Encrypt(theText) {
output = new String;
Temp = new Array();
Temp2 = new Array();
TextSize = theText.length;
for (i = 0; i < TextSize; i++) {
rnd = Math.round(Math.random() * 122) + 68;
Temp[i] = theText.charCodeAt(i) + rnd;
Temp2[i] = rnd;
}
for (i = 0; i < TextSize; i++) {
output += String.fromCharCode(Temp[i], Temp2[i]);
}
return output;
}
function unEncrypt(theText) {
output = new String;
Temp = new Array();
Temp2 = new Array();
TextSize = theText.length;
for (i = 0; i < TextSize; i++) {
Temp[i] = theText.charCodeAt(i);
Temp2[i] = theText.charCodeAt(i + 1);
}
for (i = 0; i < TextSize; i = i+2) {
output += String.fromCharCode(Temp[i] - Temp2[i]);
}
return output;
}
// -----------------------------------------------------------------------------
//Cookies
// -----------------------------------------------------------------------------
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}
function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

// -----------------------------------------------------------------------------
//Correct IE 5.5 Cursor error (SB)
// -----------------------------------------------------------------------------
var pointer = 'hand';
if (navigator.appName.toLowerCase().indexOf('microsoft') != -1){pointer = 'hand';} else {pointer = 'pointer';}


// -----------------------------------------------------------------------------
// Only Numbers
// -----------------------------------------------------------------------------

function OnlyNUMBERS(price_input, evnt, maxlen, dec)
{
var inp;
var inpchar;
var dec_places = 2;
var msg;

if (price_input.value.length >= maxlen)
	{
	//msg = 'Το πεδίο δέχεται μέχρι ' + maxlen + ' ψηφία'
	msg = 'The field accepted ' + maxlen + ' digit '
	if (dec)
		{
		// msg = msg + ' μαζί με την υποδιαστολή.'
		msg = msg + ' with the comma.'
		}
	else
		{
		msg = msg + '.'
		}
	return false;
	}
if (window.event)
   inp = window.event.keyCode;
else if (e)
   inp = e.which;
else
   return true;
inpchar = String.fromCharCode(inp);

if ((inp==null) || (inp==0) || (inp==8) || 
    (inp==9) || (inp==13) || (inp==27) )
   return true;

else if ((("1234567890").indexOf(inpchar) > -1))
	{
		if ((price_input.value.indexOf('.') > -1 || price_input.value.indexOf(',') > -1) && dec)
			{
			if (((price_input.value.indexOf('.') + price_input.value.indexOf(',') + 2) - price_input.value.length) < (dec * -1))
				{
				return false;
				}
			else
				{
				return true;
				}
			}
   return true;
	}
else if ((inpchar == "." && price_input.value.indexOf('.') == -1)  || (inpchar == "," && price_input.value.indexOf(',') == -1))
   { 
		if (price_input.value.indexOf('.') == -1 && price_input.value.indexOf(',') == -1)
			{
			if (dec)
				{
				return true;
				}
			else
				{
				return false;
				}
			}
		else
			{
			return false;
			}
   }
else
   return false;
}

// -----------------------------------------------------------------------------
// trim
// -----------------------------------------------------------------------------


function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
} 

//-------------------------------------------------------------------

// Browser Slide-Show script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
var slideCache = new Array();
function RunSlideShow(pictureName,imageFiles,displaySecs)
{
  var imageSeparator = imageFiles.indexOf(";");
  var nextImage = imageFiles.substring(0,imageSeparator);
  if (document.all)
  {
    document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
    document.getElementById(pictureName).filters.blendTrans.Apply();
  }
  document.getElementById(pictureName).src = nextImage;
  if (document.all)
  {
    document.getElementById(pictureName).filters.blendTrans.Play();
  }
  var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)
    + ';' + nextImage;
  setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",
    displaySecs*1000);
  // Cache the next image to improve performance.
  imageSeparator = futureImages.indexOf(";");
  nextImage = futureImages.substring(0,imageSeparator);
  if (slideCache[nextImage] == null) {
    slideCache[nextImage] = new Image;
    slideCache[nextImage].src = nextImage;
  }
}

//-----------------------------
//OPEN NEW WINDOW - POP UP
function create_window_profile(page,width,height)
{
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;

    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;

var win1 = window.open(page,'win',',scrollbars=yes,toolbar=no,menubar=no,status=no,resizable=yes,directories=no,width='+width+',height='+height+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',resizable=no');
var win1 = win1.focus();
}



function resize_window_profile(width,height)
{
window.resizeTo(width,height);
if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
			var xMax = window.outerWidth, yMax = window.outerHeight;
            //var xMax = 640, yMax=480;

    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;
    window.moveTo(xOffset,yOffset);
}


//-------------------------------------------------------------------
//Title For All Windows
//document.title='Data Communication - www.datacomm.gr';
//window.name='Data_Communication';
//window.status='Data Communication - Designed and Developed by Profile S.A. Business Solutions';

