
function loadDisplayState(elemId)
{
var cookieName= elemId + 'Display';
var changeDisplay= readCookie(cookieName);
if (changeDisplay)
	{
	var elem=document.getElementById(elemId);
	if (elem)
		{elem.style.display=changeDisplay;}
	}

}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) )
{document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

}


function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{expires = expires * 1000 * 60 * 60 * 24;}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );

}

function showHideElementBlock(elemId)
{
 elem=document.getElementById(elemId);
 if (elem)
     {
        if (elem.style.display=="none")
         {  elem.style.display="block";
             Set_Cookie(elemId +  'Display','block',60,'/');

             // document.cookie = elemId +  'Display=inline; expires=Thu, 6 Dec 2007 20:47:11 UTC; path=/';
            }
         else
         {elem.style.display="none";
            Set_Cookie(elemId +  'Display','none',60,'/');
            // document.cookie =  elemId + 'Display=none; expires=Thu, 6 Dec 2007 20:47:11 UTC; path=/';
            }
     }


}

function showHideElementInline(elemId)
{
 elem=document.getElementById(elemId);
 if (elem)
 	 {
 	 	if (elem.style.display=="none")
	 	 {	elem.style.display="inline";
	 		 Set_Cookie(elemId +  'Display','inline',60,'/');
			 // document.cookie = elemId +  'Display=inline; expires=Thu, 6 Dec 2007 20:47:11 UTC; path=/';
			}
	 	 else
	 	 {   elem.style.display="none";
	 	 	Set_Cookie(elemId +  'Display','none',60,'/');
			// document.cookie =  elemId + 'Display=none; expires=Thu, 6 Dec 2007 20:47:11 UTC; path=/';
			}
	 }




}

function loadCssClass(elemId)
{
cookieName= elemId + 'CssClass';
cssClass= readCookie(cookieName);
if (cssClass)
    {
    elem=document.getElementById(elemId);
    if (elem)
        {elem.className = cssClass;}
    }

}
function swapCssClass(elemId , cssClass0 , cssClass1)
{
 elem=document.getElementById(elemId);
 if (elem)
     {
        if (elem.className == cssClass0)
         { elem.className= cssClass1;
           Set_Cookie(elemId +  'CssClass', cssClass1 ,60,'/');
         }
         else
         { elem.className= cssClass0;
           Set_Cookie(elemId +  'CssClass', cssClass0 ,60,'/');
         }
     }
}


function maxLength(fields)
{

	 for (i=0 ;  i<fields.length ; i++ )
		{

		 field =fields[i];
		 fieldId=field[0];

		 fieldMsgId=field[0] + 'message';
		 fieldMaxLen=field[1] ;
		 elem=document.getElementById(fieldId);
		 if (elem)
		 {
		  value=elem.value;
		  if (value.length > fieldMaxLen)
		  {
		   alert(fieldId + '=' + value);
		  }

		 }
		 else
		 {
		 alert ("none");}

		}
}

var uploadClicks=0;

function setReadMore(clipedId , linkId , maxheight)
{
clipElem = document.getElementById(clipedId);

if (clipElem.offsetHeight > maxheight)
    {
    clipElem.style.height =  maxheight + "px";
    }
else
    {
    document.getElementById(linkId).style.display = "none";
    }

}


function hideMessageIn(divId , delay , step , limit , fxTimeout )
 {

setTimeout("hideMessage( '" + divId + "' ," + step + "," + limit + "," + fxTimeout  + " )",delay);
 }


function hideMessage(elemId, step , limit , fxTimeout )
{
//clearTimeout(timerId);
timerId = setTimeout("addToDivHeight('" + elemId + "' ," + step + "," + limit + "," + fxTimeout + ")" , fxTimeout);

}

function addToDivHeight(elemId , step ,limit ,  fxTimeout)
{
limit = limit < 1 ? 1 : limit;
//clearTimeout(timerId);
elem = document.getElementById(elemId);

height = elem.style.height ? elem.style.height :  elem.offsetHeight;
height = parseInt(height);

if (height > limit )
    {
    height = height - step;
    height = height > 0 ? height : 0 ;
    elem.style.height = height + "px";
    //alert(elem.style.height + " " + height + " " + step + " " + limit);
    timerId = setTimeout("addToDivHeight('" + elemId + "'," + step + "," + limit + "," + fxTimeout + " )" , fxTimeout);
    }
else
    {
    elem.style.height = "0px";
    elem.style.display = "none";

    }
}

function submitFormH() {
    //make sure hidden and iframe values are in sync before submitting form
    updateRTEs();
	//return true;
	return submitForm();
    //change the following line to true to submit form

}

function submitForm() {
    /*elems = document.getElementsByTagName('input');
    for (i=0;i<elems.length;i++)
    {
    	elem=elems[i];
    	if (elem.type == "submit")
    	{
    		elem.disabled=true;
    	}
    }
*/

	return (uploadClicks <= 1);

}

var newwindow;
function popWin(url,w,h)
{
    newwindow=window.open(url,'livechat' , 'menubar=0,toolbar=1,status=0,resizable=0,width='+ w + ',height='+ h);
    if (window.focus) {newwindow.focus()}
}



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}



function removeItmFromArr(arr,itm){
var i = 0;
removed = false;
		var len = arr.length;
		while (i < len){

			if (arr[i].toString() == itm.toString()){
				arr.splice(i, 1);
				removed=true;

				len--;
			} else {
				i++;
			}

		}
		return removed;
}
var monthD = new Object;
monthD.el = ['Ιαν','Φεβ','Μαρ','Απρ','Μαϊ','Ιούν','Ιούλ','Αυγ','Σεπ','Οκτ','Νοέ','Δεκ'];
monthD.en = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];


function maDateString(datstr,lang) {
//datstr is in format yyyy-mm-dd
//lang is must be a member of monthD object

monthNames= monthD[lang];
dateparts = datstr.split('-');

monthNum = toInt(dateparts[1]);

dayNum = toInt(dateparts[2]);
dayStr = dayNum.toString();
dstr = dayStr + " " + monthNames[monthNum-1] + " " + dateparts[0];
return dstr;
}


function toInt(intstr) {
if (intstr.length>1){
firstDigit = intstr.slice(0,1);
	if (firstDigit == '0'){
		intstr = intstr.slice(1);
	}
}

integ = parseInt(intstr);
return integ;

}

function showBlogMsg(msgId){
document.getElementById(msgId).style.display="block";
}



function hideBlogMsg(msgId){
document.getElementById(msgId).style.display="none";

}


function showImage(elem,imgsrc){
imgdiv=document.getElementById(imgsrc);
if (imgdiv){
imgdiv.style.display="block";
}else{
imgdiv = document.createElement('div');
imgdiv.id = imgsrc;
imgdiv.style.top=(elem.offsetTop + 50) + "px";

imgdiv.style.position="absolute";
imgdiv.style.left=elem.offsetLeft + "px";

imgdiv.innerHTML = "<img src='"+ imgsrc + "' class='borderedImg'/>";
document.body.appendChild(imgdiv);

}

}

function hideImage(elem,imgsrc){
imgdiv=document.getElementById(imgsrc);
if (imgdiv){
imgdiv.style.display="none";
}
}


function menuh(sender,id){
topLevelDiv=document.getElementById('toplevel_ul');
tahs= topLevelDiv.getElementsByTagName('a');

for(i=0;i<tahs.length;i++){
	d=tahs[i];
	if (d==sender){
		d.className='menuhSelected';
	}
	else{
		d.className='menuh';
	}

	}


menusDiv=document.getElementById('menus');
divs = menusDiv.getElementsByTagName('div');

	for(i=0;i<divs.length;i++){
	d=divs[i];
		if (d.id==id){
			d.style.display="block";
		}
		else{
			d.style.display="none";
		}

	}
}


var IE = document.all?true:false


var popup=document.createElement('img');
popup.id='popupImage';
popup.style.display="none";
popup.className='borderedImg';
document.body.appendChild(popup);
popup=document.getElementById('popupImage');

function popupPhoto(e , im){

// If NS -- that is, !IE -- then set up for mouse capture

 if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY+10;
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}

p=im.src.split('/');
p=p.slice(0,p.length-1);
pa=p.join('/');
pa= pa + '/' + 'image';

popup.style.display="block";
popup.src=pa;

popup.style.top=tempY + 'px';
popup.style.left=tempX + 'px';
popup.setAttribute('onclick',"closePopup(this)");

//If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = movePhoto;

}
function movePhoto(e){

	 if (IE) { // grab the x-y pos.s if browser is IE
		    tempX = event.clientX + document.body.scrollLeft;
		    tempY = event.clientY + document.body.scrollTop;
		  } else {  // grab the x-y pos.s if browser is NS
		    tempX = e.pageX;
		    tempY = e.pageY+10;
		  }
		  // catch possible negative values in NS4
		  if (tempX < 0){tempX = 0;}
		  if (tempY < 0){tempY = 0;}

	popup.style.top=tempY + 'px';
	popup.style.left=tempX + 'px';


}
function photoOut(){

	document.onmousemove = null;
	popup.style.display="none"
}

function closePopup(el){

el.style.display='none';

}


function poMouseOver(el,otherPos){
el.className="payment_option payment_option_enabled";



}


function poMouseOut(el,otherPos){

	el.className="payment_option";

}



function poMouseClick(el,otherPos){

	el.className="payment_option payment_option_enabled";
	el.onmouseout=null;
	for (i=0; i<otherPos.length;i++){
		po=otherPos[i];

		if (po != el.id){
			poel=document.getElementById(po);
			if (poel){
				poel.className="payment_option";
				poel.onmouseover=null;

			}
		}
	}

}


function inlineMap(elid){
	
	showHideElementBlock(elid);
	if (document.getElementById(elid).style.display=='block')
		{map.checkResize();}
	
	
}
