function isEmpty(checkstr){
	var uzunluk = checkstr.length;
	var bosluk = checkstr.indexOf(' ');
	if (uzunluk == 0) return true;
	else
	if (bosluk == 0) return true;
	else
	return false;
}

function validMail(emailStr){
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
	return false;
}

var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
		return false;
 }
}

for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
		return false;
  }
}

if (user.match(userPat)==null) {
		return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
	for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
			return false;
		}
	}
	return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
		return false;
  }
}

if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
	return false;
}

if (len<2) {
		return false;
}

return true;
}


var Images = {
	IntVal : 0,
	i : 0,
	Cycle : function(ImgCnt){
		Images.IntVal = setInterval('Images.Process(' + ImgCnt + ')', 3000);
	},
	Process : function (ImgCnt){
		if (Images.i == ImgCnt) Images.i = 0;
		new Effect.Fade('imgsrc' + Images.i, {duration : 0.2, from: 1.0, to: 0.5, afterFinish : function(effect){ 
																																																	 $('imgsrc' + Images.i).style.display = 'none';
																																																	 Images.i++;
																																																	 if (Images.i == ImgCnt) Images.i = 0;
																																																	 new Effect.Appear('imgsrc' + Images.i, {sduration : 0.2, from: 0.5, to: 1.0} );}} );
	}
};

var Button1 = {
	IntVal : 0,
	i : 0,
	name : "",
	zindex : 65500,
	Cycle : function(ImgCnt, ImgSrc){
		Button1.IntVal = setInterval('Button1.Process(' + ImgCnt + ', \'' + ImgSrc + '\')', 3000);
	},
	Process : function (ImgCnt, ImgSrc){
		if (Button1.i == ImgCnt) Button1.i = 0;
		if (Button1.i == 0) 
			Button1.name = ImgSrc; 
		else Button1.name = ImgSrc + '_a' + Button1.i; 
		new Effect.Fade(Button1.name, {duration : 0.4, from: 1.0, to: 0, afterFinish : function(effect){ 
																																														$(Button1.name).style.zIndex = --Button1.zindex;
																																													  new Effect.Appear(Button1.name, {sduration : 0.1, from: 0.9, to: 1.0} );
																																														Button1.i++;
																																														if (Button1.zindex == 0) Button1.zindex = 65501; } } );
	}
};

var Button2 = {
	IntVal : 0,
	i : 0,
	name : "",
	zindex : 65500,
	Cycle : function(ImgCnt, ImgSrc){
		Button2.IntVal = setInterval('Button2.Process(' + ImgCnt + ', \'' + ImgSrc + '\')', 3000);
	},
	Process : function (ImgCnt, ImgSrc){
		if (Button2.i == ImgCnt) Button2.i = 0;
		if (Button2.i == 0) 
			Button2.name = ImgSrc; 
		else Button2.name = ImgSrc + '_a' + Button2.i; 
		new Effect.Fade(Button2.name, {duration : 0.4, from: 1.0, to: 0, afterFinish : function(effect){ 
																																														$(Button2.name).style.zIndex = --Button2.zindex;
																																													  new Effect.Appear(Button2.name, {sduration : 0.1, from: 0.9, to: 1.0} );
																																														Button2.i++;
																																														if (Button2.zindex == 0) Button2.zindex = 65501; } } );
	}
};

var Button3 = {
	IntVal : 0,
	i : 0,
	name : "",
	zindex : 65500,
	Cycle : function(ImgCnt, ImgSrc){
		Button3.IntVal = setInterval('Button3.Process(' + ImgCnt + ', \'' + ImgSrc + '\')', 3000);
	},
	Process : function (ImgCnt, ImgSrc){
		if (Button3.i == ImgCnt) Button3.i = 0;
		if (Button3.i == 0) 
			Button3.name = ImgSrc; 
		else Button3.name = ImgSrc + '_a' + Button3.i; 
		new Effect.Fade(Button3.name, {duration : 0.4, from: 1.0, to: 0, afterFinish : function(effect){ 
																																														$(Button3.name).style.zIndex = --Button3.zindex;
																																													  $(Button3.name).style.display = 'block';
																																														Button3.i++;
																																														if (Button3.zindex == 0) Button3.zindex = 65501; } } );
	}
};

var Button4 = {
	IntVal : 0,
	i : 0,
	name : "",
	zindex : 65500,
	Cycle : function(ImgCnt, ImgSrc){
		Button4.IntVal = setInterval('Button4.Process(' + ImgCnt + ', \'' + ImgSrc + '\')', 3000);
	},
	Process : function (ImgCnt, ImgSrc){
		if (Button4.i == ImgCnt) Button4.i = 0;
		if (Button4.i == 0) 
			Button4.name = ImgSrc; 
		else Button4.name = ImgSrc + '_a' + Button4.i; 
		new Effect.Fade(Button4.name, {duration : 0.4, from: 1.0, to: 0, afterFinish : function(effect){ 
																																														$(Button4.name).style.zIndex = --Button4.zindex;
																																													  new Effect.Appear(Button4.name, {sduration : 0.1, from: 0.9, to: 1.0} );
																																														Button4.i++;
																																														if (Button4.zindex == 0) Button4.zindex = 65501; } } );
	}
};

var NewClick = {
	Cycle : function() {
		setInterval('NewClick.Process()', 1000);
	},
	Process : function() {
		if ($('r28_c2').src.search('images/r28_c2.jpg') > 0) $('r28_c2').src = 'images/r28_c2_f2.jpg';
		else $('r28_c2').src = 'images/r28_c2.jpg';
	}
}

var Contact = {
	postData : function(){
		if (isEmpty($('name').value)){
			new Effect.Highlight($('name'), {startcolor: '#FFFFFF', duration: 0.5, afterFinish: function(effect){$('name').focus();}});
			return false;
		}
		if (isEmpty($('surname').value)){
			new Effect.Highlight($('surname'), {startcolor: '#FFFFFF', duration: 0.5, afterFinish: function(effect){$('surname').focus();}});
			return false;
		}
		if (!validMail($('email').value)){
			new Effect.Highlight($('email'), {startcolor: '#FFFFFF', duration: 0.5, afterFinish: function(effect){$('email').focus();}});
			return false;
		}
		return true;
		}
};

var Register = {
	postData : function(){
		if (isEmpty($('name').value)){
			new Effect.Highlight($('name'), {startcolor: '#3F3F41', endcolor: '#FFFFFF', duration: 0.5, afterFinish: function(effect){$('name').focus(); $('name').style.backgroundColor = '#FFFFFF';}});
			return false;
		}
		if (isEmpty($('surname').value)){
			new Effect.Highlight($('surname'), {startcolor: '#3F3F41', endcolor: '#FFFFFF', duration: 0.5, afterFinish: function(effect){$('surname').focus(); $('surname').style.backgroundColor = '#FFFFFF';}});
			return false;
		}
		if (!validMail($('email').value)){
			new Effect.Highlight($('email'), {startcolor: '#3F3F41', endcolor: '#FFFFFF', duration: 0.5, afterFinish: function(effect){$('email').focus(); $('email').style.backgroundColor = '#FFFFFF';}});
			return false;
		}
		return true;
		}
};

var ExhibitionGallery = {
	selectImage : function(image) {
		$('srcimg').src = image;
	}
}
