function changeLoc(newloc) {
 location.replace(newloc);
}

function VALITATEFORM(form,lang) {
	name = form.name.value;
	phone = form.phone.value;
	if (name == '') {
		if (lang == 'gr') {
			alert("Παρακαλώ εισάγετε το ονομά σας");
		} else if (lang == 'en') {
			alert("Please enter your name");
		}
		return false;
	} else if (phone == '') {
		if (lang == 'gr') {
			alert("Παρακαλώ εισάγετε το τηλεφωνό σας");
		} else if (lang == 'en') {
			alert("Please enter your phone number");
		}
		return false;
	} else {
		return true;
	}
}

function VALITATE_CAR_REQ_FORM(form,lang) {
	var name = form.name.value;
	var phone = form.phone.value;
	if ((name == ' ')||(name == '')) {
		if (lang == 'gr') {
			alert("Παρακαλώ εισάγετε το ονομά σας");
		} else if (lang == 'en') {
			alert("Please enter your name");
		}
		return false;
	} else if ((phone == ' ')||(phone == '')) {
		if (lang == 'gr') {
			alert("Παρακαλώ εισάγετε το τηλεφωνό σας");
		} else if (lang == 'en') {
			alert("Please enter your phone number");
		}
		return false;
	} else {
		return true;
	}
}

function mm_over(id, PAR_1, PAR_4, PAR_2) { 

	var COUNT_AR = PAR_4.split("|");
	var i;
	for(i=0; i<COUNT_AR.length; i++) {
		if (PAR_1 == COUNT_AR[i]) {
			document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'block'; 
		} else {
			document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'none'; 
		}
	}
}
function mm_out(id, PAR_1, PAR_4, PAR_2) { 
	/*var COUNT_AR = PAR_4.split("|");
	var i;
	for(i=0; i<COUNT_AR.length; i++) {
		if (PAR_2 == COUNT_AR[i]) {
			document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'block'; 
		} else {
			document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'none'; 
		}
	}*/
}


function TD_BGCOLOR(CASE, PAR_1, PAR_2, ROOT_PAR_1, PAR_4) {

	var COUNT_AR = PAR_4.split("|");
	var i;
	if (CASE == '1') { //over
		for(i=0; i<COUNT_AR.length; i++) {
			if (PAR_1 == COUNT_AR[i]) {
			  if ((COUNT_AR[i] != PAR_2)&&(COUNT_AR[i] != ROOT_PAR_1)) {
				document.getElementById('mm_'+COUNT_AR[i]).style.backgroundColor = 'D1E0E0';
			  } 
			  document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'block'; 
			} else {
			  if ((COUNT_AR[i] != PAR_2)&&(COUNT_AR[i] != ROOT_PAR_1)) {
				document.getElementById('mm_'+COUNT_AR[i]).style.backgroundColor = 'B2CCCC';
			  } 
			  document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'none'; 
			}
		}
	} 
}

function TD_SUBMENU(PAR_1, PAR_2, PAR_3, PAR_4, CASE, event) {
	
	var COUNT_AR = PAR_4.split("|");
	var i;
	var toElement = null;

	if (event.relatedTarget) {
		toElement = event.relatedTarget;
	} else if (event.toElement) {
		toElement = event.toElement;
	}
	
	while (toElement && toElement.id != 'sub_of_'+PAR_1) {
		toElement = toElement.parentNode;
	}

	if (!toElement) {
		if (document.getElementById) {
		//if (!event.fromElement.contains(event.toElement) &&!document.getElementById('sub_of_'+PAR_1).contains(event.toElement)) {	
			if ((PAR_1 != PAR_2)&&(PAR_1 != PAR_3)) {
				document.getElementById('mm_'+PAR_1).style.backgroundColor = 'B2CCCC';
			}
			for(i=0; i<COUNT_AR.length; i++) {
				if ((PAR_2 == COUNT_AR[i])||(PAR_3 == COUNT_AR[i])) {
					document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'block'; 
				} else {
					document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'none'; 
				}
			}
		//}
		}
	}
}

function TD_SUBMENU_SINGLE(PAR_2, PAR_3, PAR_4, event) {
	
	var COUNT_AR = PAR_4.split("|");
	var i;
	var toElement = null;

	if (event.relatedTarget) {
		toElement = event.relatedTarget;
	} else if (event.toElement) {
		toElement = event.toElement;
	}
	
	while (toElement && toElement.id != 'under_mm') {
		toElement = toElement.parentNode;
	}

	if (!toElement) {
		if (document.getElementById) {
		//if (!event.fromElement.contains(event.toElement) &&!document.getElementById('sub_of_'+PAR_1).contains(event.toElement)) {	
			/*if ((PAR_1 != PAR_2)&&(PAR_1 != PAR_3)) {
				document.getElementById('mm_'+PAR_1).style.backgroundColor = 'B2CCCC';
			}*/
			for(i=0; i<COUNT_AR.length; i++) {
				if ((PAR_2 == COUNT_AR[i])||(PAR_3 == COUNT_AR[i])) {
					document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'block'; 
				} else {
					document.getElementById('sub_of_'+COUNT_AR[i]).style.display = 'none'; 
					document.getElementById('mm_'+COUNT_AR[i]).style.backgroundColor = 'B2CCCC';
				}
			}
		//}
		}
	}
}

function POPUPWindow(PAGE,TITLE,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

    window.POPUP_WINDOW = open(PAGE, 'POPUP_WINDOW', 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');
	
}

function M_POPUP(FILE,w,h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

    window.POPUP_WINDOW = open('../web_images/menu_images/'+FILE, 'PHOTO_POPUP', 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');
	
}

//for stroke

function processTextStroke(selector){
  var v=getElementsBySelector(selector);
  for(i=0;i < v.length;i++){
    processElement(v[i]);
  }
}

function processElement(v){
  var content=v.innerHTML;
  for (j=1;j<=8;j++){
    var d=document.createElement("span");
    d.className = "stroke"+j;
    d.innerHTML = content;
    v.appendChild(d);
  }
  v.removeChild(v.firstChild);
  var dd=document.createElement("span");
  dd.className = "rawtext";
  dd.innerHTML = content;
  v.appendChild(dd);
}
  
function NiftyCheck(){
  if(!document.getElementById || !document.createElement)
    return(false);
  var b=navigator.userAgent.toLowerCase();
  if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
    return(false);
  return(true);
}
////
function getElementsBySelector(selector){
  var i;
  var s=[];
  var selid="";
  var selclass="";
  var tag=selector;
  var objlist=[];
  if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
  }
  if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
  }
  if(selid!=""){
    objlist.push(document.getElementById(selid));
    return(objlist);
  }
  if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
  }
  var v=document.getElementsByTagName(tag);  // tag selector like "tag"
  if(selclass=="")
    return(v);
  for(i=0;i < v.length;i++){
    if(v[i].className==selclass){
      objlist.push(v[i]);
    }
  }
  return(objlist);
}

function NL_PR_PGALLERY (SRC, CONT, IMG_W){
	if (document.getElementById){
        var c = document.getElementById(CONT);
        if (c.style.display != "block"){
			ADD_IMG_W = "";
			if (parseInt(IMG_W) > 534) {
				ADD_IMG_W  = ' width="534"';
			}
            c.innerHTML = '<img src="' + SRC + '"'+ADD_IMG_W+'>';
        }
		else {
            c.style.display="none";
        }
    }
}

function POPUPWindow_RESIZABLE(PAGE,TITLE,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

    window.POPUP_WINDOW = open(PAGE, 'POPUP_WINDOW', 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes');
	
}

function POPUPWindow_RESIZABLE_2(PAGE,TITLE,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

    window.POPUP_WINDOW_W = open(PAGE, 'POPUP_WINDOW_W', 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes');
	
}

function Filter_Recs(REC_ID) {
	
	var SEL_CC_ = document.getElementById("f_cc");
	SEL_CC = SEL_CC_.options[SEL_CC_.selectedIndex].value;

	LOC_RPL = "index.php?action=1&rec="+REC_ID;
	if (SEL_CC != "") {
	  LOC_RPL += "&f_cc="+SEL_CC;
	}
	changeLoc(LOC_RPL);

}

function CHECK_SEARCH_FORM(form, LANG) {return true;
}


/* GLS */
function REFRESH_THUMBS_AREA(CURRENT_MONTH, CURRENT_YEAR, SHOW_CLICKS){
	
var AJAX_REQUEST; 
var SELECTED_MONTH = document.getElementById("month_f").value;
var SELECTED_YEAR = document.getElementById("year_f").value;
document.getElementById("RefreshMessage").style.display = "block";
document.getElementById("OT_IMGS_AREA").style.display = "none";

try { AJAX_REQUEST = new XMLHttpRequest();
} catch (e){
try { AJAX_REQUEST = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try { AJAX_REQUEST = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Something is wrong with your browser!");
return false;
}
}
}

AJAX_REQUEST.onreadystatechange = function(){
if(AJAX_REQUEST.readyState == 4){
var ajaxDisplay = document.getElementById("ThumbPhotos");
ajaxDisplay.innerHTML = AJAX_REQUEST.responseText;
}
}

AJAX_REQUEST.open("GET", "refresh_thumbs.php?month_c="+CURRENT_MONTH+"&year_c="+CURRENT_YEAR+"&month_s="+SELECTED_MONTH+"&year_s="+SELECTED_YEAR+"&show_c="+SHOW_CLICKS, true);
AJAX_REQUEST.send(null); 
}

function REFRESH_GALLERY_AREA(GALLERY_ID){
	
var AJAX_REQUEST_GAL; 
document.getElementById("RefreshGalleryMsg").style.display = "block";
document.getElementById("DISPLAY_PHOTOS").style.display = "none";

try { AJAX_REQUEST_GAL = new XMLHttpRequest();
} catch (e){
try { AJAX_REQUEST_GAL = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try { AJAX_REQUEST_GAL = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Something is wrong with your browser!");
return false;
}
}
}

AJAX_REQUEST_GAL.onreadystatechange = function(){
if(AJAX_REQUEST_GAL.readyState == 4){
var ajaxDisplay = document.getElementById("GALLERY_PHOTO_AREA");
ajaxDisplay.innerHTML = AJAX_REQUEST_GAL.responseText;
}
}

AJAX_REQUEST_GAL.open("GET", "refresh_gallery_02.php?gal_id="+GALLERY_ID, true);
AJAX_REQUEST_GAL.send(null); 
}

function SelectImg(FileName, id) {

var subImages = document.getElementById('previewPane').getElementsByTagName('IMG');
if(subImages.length==0){
var img = document.createElement('IMG');
document.getElementById('previewPane').appendChild(img);
} else img = subImages[0];

document.getElementById('waitMessage').style.display='inline';
img.onload = function() { document.getElementById('waitMessage').style.display='none'; };

img.src = "../web_images/temps_images/"+FileName;
if (img.width > 435) {
img.width = 435;
}

//document.getElementById("normal_photo").src = "../web_images/gallery/"+FileName;

}
