function initPage(){
	initGallery();
	IEhover();
	clearInputs();
}
if (window.addEventListener) window.addEventListener("load", initPage, false);
else if (window.attachEvent && !window.opera) window.attachEvent("onload", initPage);
/*--- clear inputs function ---*/
function clearInputs(){
	var _list = document.getElementsByTagName('input');
	for(var i = 0; i  < _list.length; i++){
		if(_list[i].type == 'text' || _list[i].type == 'password'){
			_list[i].val = _list[i].value;
			_list[i].onfocus = function(){
				if(this.value == this.val) this.value = '';
			}
			_list[i].onblur = function(){
				if(this.value == '') this.value = this.val;
			}
		}
	}
}
/*--- IE6 hover function ---*/
function IEhover(){
	if (window.attachEvent && !window.opera){
		var nav = document.getElementById("nav");
		if (nav){
			var nodes = nav.getElementsByTagName("li");
			for (var i = 0; i < nodes.length; i++){
				nodes[i].onmouseover = function(){
					if (this.className.indexOf("hover") == -1) this.className += " hover";
				}
				nodes[i].onmouseout = function (){
					this.className = this.className.replace(" hover", "");
				}
			}
		}
	}
}
/*--- galllery function ---*/
function initGallery(){
	var _gall = document.getElementById('gallery');
	if(_gall){
		var _hold;
		var btn_h;
		var t_box = _gall.getElementsByTagName('div');
		for(var i = 0; i  < t_box.length; i++){
			if(t_box[i].className.indexOf('visual-box') != -1) _hold = t_box[i];
			if(t_box[i].className.indexOf('bar') != -1 && t_box[i].getElementsByTagName('ul')[0]) btn_h = t_box[i].getElementsByTagName('ul')[0];
		}
		if(_hold && btn_h){
			var _btn = btn_h.getElementsByTagName('li');
			var _a;
			for(var i = 0; i  < _btn.length; i++){
				_btn[i]._i = i;
				_btn[i]._box = _btn[i].getElementsByTagName('div')[0];
				if(_btn[i].className.indexOf('active') != -1){
					_a = i;
					if(_btn[i]._box) _hold.innerHTML = _btn[i]._box.innerHTML;
				}
				_btn[i].onclick = function(){
					if(this._i != _a){
						_btn[_a].className = _btn[_a].className.replace('active','');
						this.className += ' active';
						_a = this._i;
						if(this._box) _hold.innerHTML = this._box.innerHTML;
					}
					return false;
				}
			}
		}
	}
}

function showartdiv(cid) {
	if(document.getElementById('artsdiv_'+cid)) document.getElementById('artsdiv_'+cid).style.display='block';
}
function hideartdiv(cid) {
	if(document.getElementById('artsdiv_'+cid)) document.getElementById('artsdiv_'+cid).style.display='none';
}

function updateBreadcrumb(iflip,b1,b2) {
	flipper_hide(flipper);
	clearTimeout(flipper_timeout);
	if(document.getElementById('brcdiv')) document.getElementById('brcdiv').innerHTML='<ul><li>'+b1+'</li><li>'+b2+'</li></ul>';
	flipper=iflip-1;
	flipper_start();
}

function flipper_show(iflip) {
	if(document.getElementById('adtv_link_'+iflip)) document.getElementById('adtv_link_'+iflip).className='active';			
	if(document.getElementById('adtv_more_'+iflip)) document.getElementById('galdisplay').innerHTML=document.getElementById('adtv_more_'+iflip).innerHTML;					
}

function flipper_hide(iflip) {
	if(document.getElementById('adtv_link_'+iflip)) document.getElementById('adtv_link_'+iflip).className='';			
	//if(document.getElementById('adtv_more_'+iflip)) document.getElementById('adtv_more_'+iflip).style.display='none !important';					
}

function brc_show(iflip) {
	if(document.getElementById('brcdiv')) document.getElementById('brcdiv').innerHTML='<ul><li>'+document.getElementById('brc1_'+iflip).innerHTML+'</li><li>'+document.getElementById('brc2_'+iflip).innerHTML+'</li></ul>';
}
function flipper_start() { 
	try {
			if (flipper_max>0) {
				flipper_hide(flipper);
				if (flipper<flipper_max) flipper++;	else flipper=0; 
				flipper_show(flipper); brc_show(flipper);
				flipper_timeout=setTimeout("flipper_start()",5200);	
			} 
			//initGallery();
	} catch(ex) { }
}


function trexagyreye(o,s,a) {
	var a;
	a = new sack();
	a.requestFile = 'content.php';
	a.setVar('special','trexagyreye');
	a.setVar('sel',s);
	a.setVar('artid',a);
	a.onCompletion = function(){ document.getElementById('moreartsdiv').innerHTML=a.response;}
	document.getElementById('moreartsdiv').innerHTML='<div align="center" width="300"><img src="graphics/loader.gif" /><br/><br/></div>';
	a.runAJAX();	
}


// for modal message
messageObj = new DHTML_modalMessage();
messageObj.setShadowOffset(5);	

function displayRegForm(){
	messageObj.setSize(370,382);
	messageObj.setSource('register.htm');	
	messageObj.setShadowDivVisible(false);	
	messageObj.display();
}
function closeRegForm() {
	messageObj.close();	
}

function doRegSubmit() {
	f=document.rf;
	if(mytrim2(f.fname.value)=='' || mytrim2(f.lname.value)=='' || mytrim2(f.email.value)=='' || mytrim2(f.area.value)=='' || mytrim2(f.pass.value)=='' || mytrim2(f.city.value)=='' || (!f.sex[0].checked && !f.sex[1].checked)) alert('πρέπει να συμπληρώσετε τα υποχρεωτικά πεδία!');
	else go_register();	
}
function mytrim2(str) {
	return str.replace(/^\s*((?:[\S\s]*\S)?)\s*$/, '$1');
}
	
function go_register() {
	var a,f;
	f=document.rf;
	if(f.fname.value=='' || f.lname.value=='' || f.email.value=='' || f.pass.value=='' || f.city.value=='') {
		alert('πρέπει να συμπληρώσετε όλα τα πεδία!');
		return;
	}
	a = new sack();
	a.requestFile = 'register.php';
	a.setVar('fname',f.fname.value);
	a.setVar('lname',f.lname.value);
	a.setVar('email',f.email.value);
	a.setVar('byear',f.ayea.value);
	a.setVar('pass',f.pass.value);
	a.setVar('gender',f.sex[0].checked?'f':'m');
	a.setVar('mobile',f.mobile.value);
	a.setVar('city',f.city.value);
	a.setVar('area',f.area.value);
	a.setVar('getnewsletter',f.newsletter.checked?'Y':'N');
	
	a.onCompletion = function(){ document.getElementById('regformdiv').innerHTML=a.response;}
	a.runAJAX();
}