//Shortend GetElementById
function $(id){
	return document.getElementById(id);
}

function ticker(){
				newLeft =currentLeft + stepSize;
				if(newLeft < holder.offsetWidth){
					eval("content.style."+direction+" = newLeft + \"px\";");
					currentLeft = newLeft;
				}else{
					currentLeft = initLeft;
					eval("content.style."+direction+" = currentLeft;");
				}
				setTimeout("ticker()",timeOutSpeed);
			}
			
function changeBigPic(object){
	if(currentPic == object.getAttribute('imgIndex')){
		return false;
	}
	var bigPic = $('bigPic');
	imgId = picsArr[object.getAttribute('imgIndex')];
	ext = object.getAttribute('ext');
	title = object.getAttribute('title');
	photogsName = object.getAttribute('photog');

	object.style.border = '3px solid #000000';
	$('thumb_'+ prevThumb).style.border = '3px solid #FFFFFF';
	prevThumb = imgId;
	currentPic = object.getAttribute('imgIndex');
	bigPic.src = basePath + imgId + "." + ext;
	bigPicLink = "id=" + imgId + "&ext=" + ext;
 	bigPic.setAttribute('bigPicSrc',bigPicLink);
 	$('bigPicTitle').innerHTML = title;
 	$('photog_name').innerHTML = photogsName;
}

function openBigPic(){
	var bigPic = $('bigPic');
	imgLink = bigPic.getAttribute('bigPicSrc');
	window.open('/bigPic_' + galId + "?" + imgLink,'bigPic','width=100,height=100');
}

function moveToImage(num){
	var checkCount = parseInt(currentPic) + (num);
	if(checkCount <0 ){
		if($('prevPagePic')){
			document.location.href = $('prevPagePic').parentNode.href;
		}else{
			document.location.href = $('lastPage').parentNode.href;
		}
	}else if(checkCount > picsArr.length-1){
		if($('nextPagePic')){
			document.location.href = $('nextPagePic').parentNode.href;
		}else{
			document.location.href = $('firstPage').parentNode.href;
		}
	}else{
		var imgId = picsArr[checkCount];
		var thumbPic = $('thumb_' + imgId);
		var ext = thumbPic.getAttribute('ext');
		var title = thumbPic.getAttribute('title');
		
		$('thumb_'+ imgId).style.border = '3px solid #000000';
		$('thumb_'+ prevThumb).style.border = '3px solid #FFFFFF';
		currentPic = checkCount;
		prevThumb = imgId;
		 
		
		var bigPic = $('bigPic');
		bigPic.src = basePath +  imgId + "." + ext;
		bigPicLink = "id=" + imgId + "&ext=" + ext;
	 	bigPic.setAttribute('bigPicSrc',bigPicLink);
	 	$('bigPicTitle').innerHTML = title;
	}
}

function IsEmail(sText) {
	var at="@";
	var dot=".";
	var lat=sText.indexOf(at)
	var lstr=sText.length
	var ldot=sText.indexOf(dot)
	if (sText=="" || sText==null){ return false }
	if (sText.indexOf(at)==-1 || sText.indexOf(at)==0 || sText.indexOf(at)==lstr){ return false }
	if (sText.indexOf(dot)==-1 || sText.indexOf(dot)==0 || sText.indexOf(dot)==lstr){ return false }
	if (sText.indexOf(at,(lat+1))!=-1){ return false }
	if (sText.substring(lat-1,lat)==dot || sText.substring(lat+1,lat+2)==dot){ return false }
	if (sText.indexOf(dot,(lat+2))==-1){ return false }
	if (sText.indexOf(" ")!=-1){ return false }
 	return true					
}

function changeDisplay(id){
	var object = $(id);
	if(object.style.display=='none'){
		object.style.display = '';
	}else{
		object.style.display = 'none';
	}
}

function checkSearch(formObj){
	if(formObj.searchTxt.value!=''){
		formObj.submit();
	}
}

function bookIt(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}

