
	// Work Space Width
function getClientWidth () {
	return (document.compatMode == 'CSS1Compat' && !window.opera) ? document.documentElement.clientWidth : document.body.clientWidth;
}

	// Work Space Height
function getClientHeight () {
	return (document.compatMode == 'CSS1Compat' && !window.opera) ? document.documentElement.clientHeight : document.body.clientHeight;
}

	/* --- Vriable's --- */

var GalleryObject = null;				// Object

var galleryObjectEx = null;				// Object Element

var reSizePhoto = new Array ();			// open Photo - Array

var photoGallery = new Array ();		// Gallery

var photoGalleryTitle = new Array ();	// Gallery Title

var photoGalleryLine = new Array ();	// Gallery Line

var iisPhotoGalleryEventCheck = false;	// Event's create check

var initContent = function () {
	
		// Init Icon 75px x 75px
	
	var init_Array = $$('div.icon_75px');
	
	if (init_Array.length) {
		
		for (cx = 0; cx != init_Array.length; cx ++) {
			
			init_Array[cx].setStyles ( { 'opacity' : 0.85, 'backgroundColor' : '#FFFFFF' } );
			
			init_Array[cx].addEvents ( {
				'mouseenter' : function () {
					var c;
					if (this.getProperty ('rel') == 'm') c = '#BFDDEB';
					if (this.getProperty ('rel') == 'w') c = '#FECCEB';
					if (this.getProperty ('rel') == 'o') c = '#FEF9CC';
					if (this.getProperty ('rel') == 'a') c = '#C0F8B1';
					if (this.getProperty ('rel') == 'p') c = '#E7A9F9';
					this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'opacity' : 1, 'backgroundColor' : c } );
				},
				'mouseleave' : function () {
					this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'opacity' : 0.85, 'backgroundColor' : '#FFFFFF' } );
				}
			} );
			
		}
		
	}
	
		// Init Icon 50px x 50px
	
	var init_Array = $$('div.icon_50px');
	
	if (init_Array.length) {
		
		for (cx = 0; cx != init_Array.length; cx ++) {
			
			init_Array[cx].setStyles ( { 'opacity' : 0.85, 'backgroundColor' : '#FFFFFF' } );
			
			init_Array[cx].addEvents ( {
				'mouseenter' : function () {
					var c;
					if (this.getProperty ('rel') == 'm') c = '#BFDDEB';
					if (this.getProperty ('rel') == 'w') c = '#FECCEB';
					if (this.getProperty ('rel') == 'o') c = '#FEF9CC';
					if (this.getProperty ('rel') == 'a') c = '#C0F8B1';
					if (this.getProperty ('rel') == 'p') c = '#E7A9F9';
					this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'opacity' : 1, 'backgroundColor' : c } );
				},
				'mouseleave' : function () {
					this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'opacity' : 0.85, 'backgroundColor' : '#FFFFFF' } );
				}
			} );
			
		}
		
	}
	
		// Init Icon 150px x 150px
	
	var init_Array = $$('div.icon_150px');
	
	if (init_Array.length) {
		
		for (cx = 0; cx != init_Array.length; cx ++) {
			
			init_Array[cx].setStyles ( { 'opacity' : 0.85, 'backgroundColor' : '#FFFFFF' } );
			
			init_Array[cx].addEvents ( {
				'mouseenter' : function () {
					var c = '#E7A9F9';
					this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'opacity' : 1, 'backgroundColor' : c } );
				},
				'mouseleave' : function () {
					this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'opacity' : 0.85, 'backgroundColor' : '#FFFFFF' } );
				}
			} );
			
		}
		
	}
	
		// Photo Edit Page (photo align)
	
	var init_Array = $$('div[rel=photo_edit_align]');
	
	if (init_Array.length) {
		
		for (cx = 0; cx != init_Array.length; cx ++) {
			
			var i = init_Array[cx].getElement ('img[alt=Photo]');
			
			var w = parseInt (i.getProperty ('width')) + 6;
			var h = parseInt (i.getProperty ('height')) + 6;
			
			i.setStyle ('margin-left', ((110 - w) / 2) + 'px');
			i.setStyle ('margin-top', ((110 - h) / 2) + 'px');
			
		}
		
	}
	
		// Init ReSize Photo
	
	var init_Array = $$('a[rel="resize"]');
	
	if (init_Array.length) {
		
		var photo; var i; var rel; var size;
		
		for (cx = 0; cx != init_Array.length; cx ++) {
			
			i = reSizePhoto.length;
			
			photo = init_Array[cx].getProperty ('href');
			init_Array[cx].setProperty ('href', '#');
			
			reSizePhoto[i] = new Array ();
			reSizePhoto[i]['photo'] = BASEPATH + '/' + photo;
			
			rel = init_Array[cx].getElement ('img').getProperty ('rel');
			
			size = rel.indexOf ('x');
			
			reSizePhoto[i]['w'] = rel.substring (0, size);
			reSizePhoto[i]['h'] = rel.substring (size + 1, rel.length);
			
			init_Array[cx].setProperty ('index', i);
			
			init_Array[cx].addEvent ('click', function () {
				var i = parseInt (this.getProperty ('index'));
				$$('#open_Photo_IMG').setProperty ('src', reSizePhoto[i]['photo']);
				$$('div#open_Photo').setStyle ('width', reSizePhoto[i]['w'] + 'px');
				$$('div#open_Photo').setStyle ('height', reSizePhoto[i]['h'] + 'px');
				$$('div#open_Photo').setStyle ('left', (getClientWidth () - parseInt (reSizePhoto[i]['w']) - 6) / 2);
				$$('div#open_Photo').setStyle ('top', (getClientHeight () - parseInt (reSizePhoto[i]['h']) - 6) / 2);
				$$('div#sys_BlindWhite').setStyle ('display', 'block');
				$$('div#open_Photo').setStyle ('display', 'block');
			} );
			
		}
		
		$$('div#open_Photo').getElement ('a').addEvent ('click', function () { 
			$$('#open_Photo_IMG').setProperty ('src', '');
			$$('div#sys_BlindWhite').setStyle ('display', 'none');
			$$('div#open_Photo').setStyle ('display', 'none');
		} );
		
	}
	
		// Gallery Line
	
	var init_Array = $$('div[class=gallery_line]');
	
	if (init_Array.length) {
		
		for (dx = 0; dx != init_Array.length; dx ++) {
			
			init_Array[dx].getElement ('div[rel=box]').getElement ('div').setStyles ( {
				'width' : '600px', 'height' : '128px',
				'display' : 'block', 'overflow' : 'hidden'
			} );
			
			var tmp = init_Array[dx];
			
			var ds = tmp.getElement ('div[rel=scroll]');
			
			var a = ds.getElements ('a[rel=gallery]');
			
			ds.setProperty ('rel', a.length);
			
			ds.setStyles ( {
				'left' : '0px',
				'top' : '0px',
				'width' : (120 * a.length) + 'px',
				'height' : '128px'
			} );
			
			photoGalleryLine[dx] = ds;
			
			var bk = tmp.getElement ('a[rel=b]');
			var fw = tmp.getElement ('a[rel=f]');
			
			bk.setProperty ('rel', dx);
			fw.setProperty ('rel', dx);
			
			if (a.length < 6) {
				
				bk.setStyle ('backgroundImage', 'none');
				fw.setStyle ('backgroundImage', 'none');
				
				bk.setStyle ('opacity', 0);
				fw.setStyle ('opacity', 0);
				
			} else {
				
				fw.addEvent ('click', function () {
					var i = parseInt (this.getProperty ('rel'));
					var r = parseInt (photoGalleryLine[i].getProperty ('rel'));
					var s = parseInt (photoGalleryLine[i].getStyle ('left'));
					var m = -(120 * (r - 5));
					if (s != m) {
						s = s - 120;
						if (s < m) s = m;
						photoGalleryLine[i].set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'left' : s } );
					}
				} );
				
				bk.addEvent ('click', function () {
					var i = parseInt (this.getProperty ('rel'));
					var r = parseInt (photoGalleryLine[i].getProperty ('rel'));
					var s = parseInt (photoGalleryLine[i].getStyle ('left'));
					var m = 0;
					if (s != m) {
						s = s + 120;
						if (s > m) s = m;
						photoGalleryLine[i].set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'left' : s } );
					}
				} );
				
			}
			
			if (a.length) {
				
				for (cx = 0; cx != a.length; cx ++) {
					
					var i = a[cx].getElement ('img');
					
					var w = parseInt (i.getProperty ('width')) + 4;
					var h = parseInt (i.getProperty ('height')) + 4;
					
					i.setStyle ('border', '2px solid #CCCCCC');
					i.setStyle ('margin-left', ((120 - w) / 2) + 'px');
					i.setStyle ('margin-top', ((128 - h) / 2) + 'px');
					
					a[cx].addEvents ( {
						'mouseenter' : function () {
							this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'backgroundColor' : '#F0F8FF' } );
						},
						'mouseleave' : function () {
							this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'backgroundColor' : '#FFFFFF' } );
						}
					} );
					
					i.addEvents ( {
						'mouseenter' : function () {
							this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'borderColor' : '#FFE400' } );
						},
						'mouseleave' : function () {
							this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'borderColor' : '#CCCCCC' } );
						}
					} );
					
				}
				
			}
		
		}
		
	}
	
		// Gallery (long photo) Line
	
	var init_Array = $$('div[class=gallery_long_line]');
	
	if (init_Array.length) {
		
		var photo_LL = init_Array[0];
		
		var bk = photo_LL.getElement ('a[rel=b]');
		var fw = photo_LL.getElement ('a[rel=f]');
		
		bk.addEvent ('click', function () { scrollBack (); return false; } );
		fw.addEvent ('click', function () { scrollNext (); return false; } );
		
		var sc = photo_LL.getElement ('div[rel=scroll]');
		
		var a = sc.getElements ('a[rel=gallery]');
		
		sc.setStyles ( {
			'width' : (60 * a.length) + 'px',
			'height' : '60px',
			'display' : 'block',
			'overflow' : 'hidden',
			'margin' : '0px'
		} );
		
		var i, w, h;
		
		for (cx = 0; cx != a.length; cx ++) {
			
			a[cx].setStyles ( { 'width' : '60px', 'height' : '60px', 'display' : 'inline-block', 'overflow' : 'hidden', 'margin' : '0px' } );
			
			a[cx].setProperty ('rel', cx);
			a[cx].setProperty ('href', '#');
			
			a[cx].addEvents ( {
				'mouseenter' : function () {
					this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'backgroundColor' : '#F0F8FF' } );
				},
				'mouseleave' : function () {
					this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'backgroundColor' : '#FFFFFF' } );
				},
				'click' : function () {
					changePhoto (this.getProperty ('rel'));
					this.blur ();
					return false;
				}
			} );
			
			i = a[cx].getElement ('img');
			
			w = i.getProperty ('width');
			h = i.getProperty ('height');
			
			i.setStyles ( { 'margin-left' : ((60 - w) / 2) + 'px', 'margin-top' : ((60 - h) / 2) + 'px' } );
			
		}
		
	}
	
		// Gallery Table
	
	var init_Array = $$('div[class=gallery_table]');
	
	if (init_Array.length) {
		
		for (dx = 0; dx != init_Array.length; dx ++) {
			
			var tmp = init_Array[dx];
			
			var a = tmp.getElements ('a[rel=gallery]');
			
			if (a.length) {
				
				for (cx = 0; cx != a.length; cx ++) {
					
					var i = a[cx].getElement ('img');
					
					i.setStyle ('border', '2px solid #CCCCCC');
					
					i.addEvents ( {
						'mouseenter' : function () {
							this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'borderColor' : '#FFE400' } );
						},
						'mouseleave' : function () {
							this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'borderColor' : '#CCCCCC' } );
						}
					} );
					
				}
				
			}
			
			var td = tmp.getElements ('td');
			
			if (td.length) {
				
				for (cx = 0; cx != td.length; cx ++) {
					
					if (td[cx].getProperty ('title') != 'empty') {
						
						td[cx].addEvents ( {
							'mouseenter' : function () {
								this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'backgroundColor' : '#F0F8FF' } );
							},
							'mouseleave' : function () {
								this.set('morph', { transition: 'cubic:out', duration: 250 } ).morph ( { 'backgroundColor' : '#FFFFFF' } );
							}
						} );
						
					}
					
				}
				
			}
		
		}
		
	}
	
		// Gallery Parse Array
	
	var init_Array = $$('div[rel=gallery]');
	
	if (init_Array.length) {
		
		for (cx = 0; cx != init_Array.length; cx ++) {
			
			photoGalleryTitle[cx] = init_Array[cx].getProperty ('title');
			
			var a = init_Array[cx].getElements ('a[rel=gallery]');
			
			if (a.length) {
				
				photoGallery[cx] = new Array ();
				
				for (dx = 0; dx != a.length; dx ++) {
					
					photoGallery[cx][dx] = Array ();
					
					photoGallery[cx][dx]['PHOTO'] = a[dx].getProperty ('href');
					photoGallery[cx][dx]['TITLE'] = a[dx].getProperty ('title');
					
					var i = a[dx].getElement ('img');
					
					photoGallery[cx][dx]['SMALL'] = i.getProperty ('src');
					
					photoGallery[cx][dx]['SWDTH'] = i.getProperty ('width');
					photoGallery[cx][dx]['SHGHT'] = i.getProperty ('height');
					
					var r = i.getProperty ('rel');
					var x = r.indexOf ('x');
					
					photoGallery[cx][dx]['BWDTH'] = r.substr (0, x);
					photoGallery[cx][dx]['BHGHT'] = r.substr (x + 1, r.length - (x + 1));
					
					a[dx].setProperty ('href', '#')
					a[dx].setProperty ('title', '')
					
					a[dx].setProperty ('gallery', cx);
					a[dx].setProperty ('photo', dx);
					
					a[dx].addEvent ('click', function () { showPhotoGallery (this.getProperty ('gallery'), this.getProperty ('photo')); } );
					
				}
				
			}
			
		}
		
	}
	
}

window.addEvent ('domready', initContent);

window.addEvent ('domready', function () { 
	
	GalleryObject = new Class ( {
		
		Implements: [Options, Events, Chain],
		
		imgPREV_DRK:	'scheme/blue/img/gallery/PREV_DRK.png',
		imgPREV_LHT:	'scheme/blue/img/gallery/PREV_LHT.png',
		imgNEXT_DRK:	'scheme/blue/img/gallery/NEXT_DRK.png',
		imgNEXT_LHT:	'scheme/blue/img/gallery/NEXT_LHT.png',
		imgSB:			'scheme/blue/img/gallery/SCROLL_BORDER.png',
		imgCLOSE_DRK:	'scheme/blue/img/gallery/CLOSE_DRK.png',
		imgCLOSE_LHT:	'scheme/blue/img/gallery/CLOSE_LHT.png',
		imgLOADING:		'scheme/blue/img/gallery/iis_loading.gif',

		
		iisGallery: null,
		iisBlind: null,
		
		index: 0,
		gallery: null,
		title: null,
		
		divTtl: null,
		
		divLft: null,
		divRht: null,
		
		divScl: null,
		objScl: null,
		
		divInfo: null,
		divClose: null,
		
		divIIS: null,
		phtIIS: null,
		
		imgLoad: null,
		
		ready: false,
		
		initialize: function (gallery, photo, title) {
			
			this.gallery = gallery;
			this.index = photo;
			this.title = title;
			
			this.iisGallery = $('iis_PhotoGallery');
			this.iisBlind = $('sys_BlindBlack');
			
			this.divTtl = this.iisGallery.getElement ('div[rel=title]');
			
			this.createTitle ();
			
			this.divLft = this.iisGallery.getElement ('div[rel=l]');
			this.divLft.set ('drk', this.imgPREV_DRK);
			this.divLft.set ('lht', this.imgPREV_LHT);
			
			this.divRht = this.iisGallery.getElement ('div[rel=r]');
			this.divRht.set ('drk', this.imgNEXT_DRK);
			this.divRht.set ('lht', this.imgNEXT_LHT);
			
			this.createArrow ();
			
			this.divScl = this.iisGallery.getElement ('div[rel=scroll]');
			this.divScl.set ('bg', this.imgSB);
			
			this.createScroll ();
			
			this.divInfo = this.iisGallery.getElement ('div[rel=info]');
			
			this.createInfo ();
			
			this.divClose = this.iisGallery.getElement ('div[rel=close]');
			this.divClose.set ('drk', this.imgCLOSE_DRK);
			this.divClose.set ('lht', this.imgCLOSE_LHT);
			
			this.createClose ();
			
			this.iisBlind.setStyle ('display', 'block');
			this.iisGallery.setStyle ('display', 'block');
			
			this.divIIS = this.iisGallery.getElement ('div[rel=iis]');
			
			this.createIIS ();
				
			iisPhotoGalleryEventCheck = true;
			
			this.loadPhoto ();
			
		},
		
		loadPhoto: function () {
			
			this.divIIS.empty ();
			
			this.fireEvent('onChangeStart');
			
			this.imgLoad = new Asset.image (this.gallery[this.index]['PHOTO'], {
				
				onload: function () {
					
					var img = galleryObjectEx.imgLoad;
					
					galleryObjectEx.divIIS.set ('morph', {
						transition: 'cubic:out',
						duration: 500,
						onComplete: function () {
							
							var img = galleryObjectEx.imgLoad;
							
							img.setStyles ( {
								'margin': '10px 10px 0px 10px',
								'width': img.width,
								'height': img.height,
								'display': 'block'
							} ).set ('morph', {
								transition: 'cubic:out',
								duration: 700,
								onComplete: function () {
									
									var iis = galleryObjectEx;
									
									if (!iis.gallery[iis.index]['TITLE']) {
										
										iis.ready = true;
										
									} else {
										
										new Element ('div').setStyles ( {
											'opacity': 0,
											'width': iis.imgLoad.width,
											'height': '20px',
											'margin-left': '10px',
											'font-family': 'Tahoma',
											'font-size': '11px',
											'padding-top': '3px',
											'color': '#222222'
										} ).inject (iis.divIIS);
										
										iis.divIIS.getElement ('div').innerHTML = iis.gallery[iis.index]['TITLE'];
										
										iis.divIIS.set ('morph', {
											transition: 'cubic:out',
											duration: 300,
											onComplete: function () {
												
												var iis = galleryObjectEx.divIIS.getElement ('div');
												
												iis.set ('morph', {
													transition: 'cubic:out',
													duration: 300,
													onComplete: function () {
														galleryObjectEx.ready = true;
													}
												} ).morph ( {
													'opacity': 1
												} );
												
												iis.ready = true;
												
											}
										} ).morph ( {
											'height': iis.imgLoad.height + 30
										} );
										
									}
									
								}
							} ).morph ( {
								'opacity': 1
							} );
							
						}
						
					} ).morph ( {
						'left': (window.getSize().x / 2) - ((this.width + 20) / 2),
						'width': this.width + 20,
						'height': this.height + 20
					} );
				}
			} ).setStyles ( {
				'opacity': 0,
				'display': 'none'
			} ).inject (this.divIIS);
			
		},
		
		changePhoto: function () {
			
			var index = this.index;
			
			var iis = this.divIIS;
			iis.setStyles ( {
				'background': 'White url(' + this.imgLOADING + ') 20px 20px no-repeat'
			} );
			
			this.fireEvent('onChangeStart');
			
			this.imgLoad.set ('morph', {
				transition: 'cubic:out',
				duration: 700,
				onComplete: function () {
					
					galleryObjectEx.imgLoad = null;
					galleryObjectEx.divIIS.empty ();
					
					galleryObjectEx.divIIS.setStyles ( {
						'background': 'White'
					} );
					
					galleryObjectEx.imgLoad = new Asset.image (galleryObjectEx.gallery[index]['PHOTO'], {
						onload: function () {
							galleryObjectEx.divIIS.set ('morph', {
								transition: 'cubic:out',
								duration: 500,
								onComplete: function () {
									
									var img = galleryObjectEx.imgLoad;
									
									img.setStyles ( {
										'margin': '10px 10px 0px 10px',
										'width': img.width,
										'height': img.height,
										'display': 'block'
									} ).set ('morph', {
										transition: 'cubic:out',
										duration: 700,
										onComplete: function () {
											
											var iis = galleryObjectEx;
											
											if (!iis.gallery[iis.index]['TITLE']) {
												iis.ready = true;
											} else {
												new Element ('div').setStyles ( {
													'opacity': 0,
													'width': iis.imgLoad.width,
													'height': '20px',
													'margin-left': '10px',
													'font-family': 'Tahoma',
													'font-size': '11px',
													'padding-top': '3px',
													'color': '#222222'
												} ).inject (iis.divIIS);
												
												iis.divIIS.getElement ('div').innerHTML = iis.gallery[iis.index]['TITLE'];
												
												iis.divIIS.set ('morph', {
													transition: 'cubic:out',
													duration: 300,
													onComplete: function () {
														
														var iis = galleryObjectEx.divIIS.getElement ('div');
														
														iis.set ('morph', {
															transition: 'cubic:out',
															duration: 300,
															onComplete: function () {
																galleryObjectEx.ready = true;
															}
														} ).morph ( {
															'opacity': 1
														} );
														
													}
												} ).morph ( {
													'height': iis.imgLoad.height + 30
												} );
												
											}
											
										}
									} ).morph ( {
										'opacity': 1
									} );
									
								}
							} ).morph ( {
								'left': (window.getSize().x / 2) - ((this.width + 20) / 2),
								'width': this.width + 20,
								'height': this.height + 20
							} );
						}
					} ).setStyles ( {
						'opacity': 0,
						'display': 'none'
					} ).inject (iis);
					
				}
			} ).morph ( {
				'opacity': 0
			} );
			
		},
		
		createIIS: function () {
			
			this.divIIS.setStyles ( {
				'width': '50px',
				'height': '50px',
				'overflow': 'hidden',
				'position': 'absolute',
				'left': (window.getSize().x / 2) - 25,
				'top': '210px',
				'background': 'White url(' + this.imgLOADING + ') 10px 10px no-repeat'
			} );

		},
		
		createInfo: function () {
			
			this.divInfo.setStyles ( {
				'width': '560px',
				'height': '20px',
				'position': 'absolute',
				'left': '50%',
				'top': '180px',
				'margin': '0px 0px 0px -320px',
				'padding': '3px 0px 0px 0px',
				'text-align': 'right',
				'font-family': 'Tahoma',
				'font-size': '11px',
				'color': 'White'
			} );
			
			this.divInfo.empty ();
			
			this.divInfo.set ('html', (parseInt (this.index) + 1) + '&nbsp;/&nbsp;' + (this.gallery.length));
			
		},
		
		createClose: function () {
			
			this.divClose.setStyles ( {
				'width': '20px',
				'height': '20px',
				'position': 'absolute',
				'left': '50%',
				'top': '180px',
				'margin': '0px 0px 0px 260px',
				'cursor': 'hand',
				'background': 'url(' + this.imgCLOSE_DRK + ')'
			} );
			
			if (!iisPhotoGalleryEventCheck) this.divClose.addEvent ('mouseenter', function () {
				this.setStyle ('background', 'url(' + this.getProperty ('lht') + ')');
			} );
			
			if (!iisPhotoGalleryEventCheck) this.divClose.addEvent ('mouseleave', function () {
				this.setStyle ('background', 'url(' + this.getProperty ('drk') + ')');
			} );
			
			if (!iisPhotoGalleryEventCheck) this.divClose.addEvent ('click', function () {
				closePhotoGallery ();
			} );
			
		},
		
		close: function () {
			
			while (this.objScl.getElement ('div')) {
				this.objScl.getElement ('div').destroy ();
			}
			
			this.iisBlind.setStyle ('display', 'none');
			this.iisGallery.setStyle ('display', 'none');
			
		},
		
		createTitle: function () {
			
			this.divTtl.set ('html', this.title);
			
			this.divTtl.setStyles ( {
				'width': '600px',
				'height': '30px',
				'position': 'absolute',
				'left': '50%',
				'top': '12px',
				'margin': '0px 0px 0px -300px',
				'color': 'White',
				'text-align': 'center',
				'font-family': 'Tahoma',
				'font-size': '21px',
				'font-weight': 'Bold'
			} );
			
		},
		
		createArrow: function () {
			
			this.divLft.setStyles ( {
				'width': '50px',
				'height': '50px',
				'position': 'absolute',
				'left': '50%',
				'top': '85px',
				'margin': '0px 0px 0px -350px',
				'cursor': 'hand',
				'background': 'url(' + this.divLft.getProperty ('drk') + ')'
			} );
			

			if (!iisPhotoGalleryEventCheck) this.divLft.addEvent ('mouseenter', function () {
				this.setStyle ('background', 'url(' + this.getProperty ('lht') + ')');
			} );
			
			if (!iisPhotoGalleryEventCheck) this.divLft.addEvent ('mouseleave', function () {
				this.setStyle ('background', 'url(' + this.getProperty ('drk') + ')');
			} );
			
			if (!iisPhotoGalleryEventCheck) this.divLft.addEvent ('click', function () {
				galleryObjectEx.moveLft ();
			} );
			
			this.divRht.setStyles ( {
				'width': '50px',
				'height': '50px',
				'position': 'absolute',
				'left': '50%',
				'top': '85px',
				'margin': '0px 0px 0px 300px',
				'cursor': 'hand',
				'background': 'url(' + this.divRht.getProperty ('drk') + ')'
			} );
			
			if (!iisPhotoGalleryEventCheck) this.divRht.addEvent ('mouseenter', function () {
				this.setStyle ('background', 'url(' + this.getProperty ('lht') + ')');
			} );
			
			if (!iisPhotoGalleryEventCheck) this.divRht.addEvent ('mouseleave', function () {
				this.setStyle ('background', 'url(' + this.getProperty ('drk') + ')');
			} );
			
			if (!iisPhotoGalleryEventCheck) this.divRht.addEvent ('click', function () {
				galleryObjectEx.moveRht ();
			} );
			
		},
		
		createScroll: function () {
			
			this.divScl.setStyles ( {
				'width': '600px',
				'height': '120px',
				'position': 'absolute',
				'left': '50%',
				'top': '50px',
				'margin': '0px 0px 0px -300px',
				'overflow': 'hidden',
				'background': 'url(' + this.divScl.getProperty('bg') + ')'
			} );
			
			this.objScl = this.divScl.getElement ('div');
			
			this.objScl.empty ();
			
			this.objScl.setStyles ( {
				'width': (120 * this.gallery.length) + 'px',
				'height': '120px',
				'position': 'relative',
				'left': '0px',
				'top': '0px'
			} );
			
			var cx = 0;
			
			var w, h;
			
			var tmp = null;

			
			for (cx = 0; cx != this.gallery.length; cx ++) {
				
				new Element ('div').setStyles ( {
					'width': '120px',
					'height': '120px',
					'float': 'left',
					'cursor': 'hand'
				} ).inject (this.objScl);
				
				tmp = this.objScl.getElements ('div')[this.objScl.getElements ('div').length - 1];
				
				var i = new Asset.image (this.gallery[cx]['SMALL'], {
					onload: function () {
						this.setStyles ( {
							'border': '2px solid Black',
							'position': 'relative',
							'left': 60 - ((this.width + 4) / 2) + 'px',
							'top': 60 - ((this.height + 4) / 2) + 'px'
						} );
					}
				} ).inject (tmp);
				
				i.removeEvents ('load', 'mouseenter', 'mouseleave', 'click');
				
				i.set ('index', cx);
				
				i.addEvents ( {
					'load': function () {
						this.set ('complete', '');
					},
					'mouseenter': function () {
						this.set ('morph', { transition: 'cubic:out', duration: 300 } ).morph ( {
							'border-color': '#FFDE00',
							'opacity': 1
						} );
					},
					'mouseleave': function () {
						this.set ('morph', { transition: 'cubic:out', duration: 300 } ).morph ( {
							'border-color': '#000000',
							'opacity': 0.7
						} );
					},
					'click': function () {
						
						if (galleryObjectEx.ready) {
							galleryObjectEx.index = parseInt (this.getProperty ('index'));
							galleryObjectEx.scrolling ();
							galleryObjectEx.changePhoto ();
						}
						
					}
				} );
				
				i.set ('morph', { transition: 'cubic:out', duration: 300 } ).morph ( {
					'border-color': '#000000',
					'opacity': 0.7
				} );
				
			}
			
			this.scrolling ();
			
		},
		
		scrolling: function () {
			
			var index = this.index;
			
			this.ready = false;
			
			this.objScl.tween('left', -(120 * index) + 240);
						
		},
		
		moveLft: function () {
			
			if (!this.ready) return;
			
			this.ready = false;
			
			var index = parseInt (this.index);
			
			var gallery = this.gallery;
			
			if (index - 1 < 0) {
				this.ready = true;
				return false;
			}
			
			index --;
			
			this.index = index;
			
			this.createInfo ();
			
			this.scrolling ();
			
			this.changePhoto ();
		},
		
		moveRht: function () {
			
			if (!this.ready) return;
			
			this.ready = false;
			
			var index = parseInt (this.index);
			
			var gallery = this.gallery;
			
			if (index + 1 > gallery.length - 1) {
				this.ready = true;
				return false;
			}
			
			index ++;
			
			this.index = index;
			
			this.createInfo ();
			
			this.scrolling ();
			
			this.changePhoto ();
		}
		
	} );
	
} );

function showPhotoGallery (gallery, photo) {
	
	galleryObjectEx = new GalleryObject (photoGallery[gallery], parseInt (photo), photoGalleryTitle[gallery]);
	
}

function closePhotoGallery () {
	
	galleryObjectEx.close ();
	
	galleryObjectEx = null;
	
}
