var thumbs = [];
var duration = 2000;
var slides;
var all_slides = [];
var autoplay = false;
var current;
function initGallery()
{
	if(document.getElementById('gallery'))
	{
		current = 0;
		all_slides = $$('#gallery .video-holder');
		slides = all_slides.length;
		all_slides.setStyles({"position": "absolute", "top": 0, "left": 0, "opacity": 0});
		all_slides[0].setStyle("opacity", 1);

		thumbs = $$('#thumbs li')
		thumbs[0].addClass("active");
		thumbs.each(function(el, i)
		{
			el.onclick = function()
			{
				if(current != i)
				{
					all_slides[current].setStyles({"display": "none"});
					all_slides[current].fade(0);
					thumbs.removeClass("active");
					this.addClass("active");
					all_slides[i].setStyles({"display": "block"});
					all_slides[i].tween("opacity", [0.4, 1]);
					current = i;
					autoplay = false;
				}
			}
		});
		setTimeout('rotate(' + 0 +')', duration);
	}
}
function rotate(_index)
{
	if(autoplay)
	{
		thumbs.removeClass("active");
		all_slides[_index].fade(0);
		if(_index==slides-1)
			_index=-1;
			
		all_slides[++_index].fade(1);
		current = _index;
		
		thumbs[current].addClass("active");
		setTimeout('rotate(' + _index + ')', duration);
	}
}

function initAccordion() 
{
	if(document.getElementById("poker-blogs"))
	{
		var accordion_2 = new Accordion('.opener', '.acc-slider', {
			display: 0,
			alwaysHide: true,
			opacity: false,
			onActive: function(toggler, element) {
				parentelement = element;
				if(toggler.parentNode.className.indexOf("parent-active") == -1) toggler.parentNode.className += ' parent-active';
			},
			onBackground: function(toggler, element) {
				toggler.parentNode.className = toggler.parentNode.className.replace('parent-active','');
			}
		});	
	}
}

//if (window.addEventListener)
//{
	//window.addEventListener("load", initAccordion, false);
	//window.addEventListener("load", initGallery, false);
//}
//Else if (window.attachEvent)
//{
	//window.attachEvent("onload", initAccordion);
	//window.attachEvent("onload", initGallery);
//}

function displayNewsDiv2(sName, sLiName, iSel, iAll){
	for (var i=1;i<=iAll;i++)
		{
			if (i.toString() == iSel) 
			{
				document.getElementById(sName + i).style.display = 'block';
				document.getElementById(sLiName + i).className = 'active';
			}
			else
			{
				document.getElementById(sName + i).style.display = 'none';
				document.getElementById(sLiName + i).className = '';
			}
		}
}

var iMultiID = 1;

function displayNewsDivPrev(sName, sLiName, iAll){
iMultiID -= 1;
if (iMultiID <= 0) {
		iMultiID = iAll;
	}
if (iMultiID > iAll) {
		iMultiID = 1;
	}
	displayNewsDiv2(sName, sLiName, iMultiID, iAll);
}

function displayNewsDivNext(sName, sLiName, iAll){
iMultiID += 1;
if (iMultiID <= 0) {
		iMultiID = iAll;
	}
if (iMultiID > iAll) {
		iMultiID = 1;
	}
	displayNewsDiv2(sName, sLiName, iMultiID, iAll);
}






function doSubmitReviewByEntityId(iId){
document.getElementById('txtName_' + iId).value = Trim(document.getElementById('txtName_' + iId).value)
document.getElementById('txtEmail_' + iId).value = Trim(document.getElementById('txtEmail_' + iId).value)

if (document.getElementById('txtName_' + iId).value.length<3) {alert('Πρέπει να συμπληρώσετε το όνομά σας.'); document.getElementById('txtName_' + iId).focus(); return}
if (!blnValidEmail(document.getElementById('txtEmail_' + iId).value)) {alert('Το e-mail σας δεν είναι σωστό.'); document.getElementById('txtEmail_' + iId).focus(); return}
if (document.getElementById('txtReview_' + iId).value.length<5) {alert('Πρέπει να συμπληρώσετε το μήνυμά σας.'); document.getElementById('txtReview_' + iId).focus(); return}

document.getElementById('frmReview_' + iId).action='/svc/postReview/send.asp?id=' + iId; 
document.getElementById('btnSubmit_' + iId).disabled=true;
document.getElementById('frmReview_' + iId).submit();
}

function Trim(strInputString){
	strInputString = strInputString + ' '
	objRegExp = /(^ +)|( +$)/g
	return strInputString.replace(objRegExp, "");
}
function blnValidEmail(strInputString){
	var objRegExp = /(^[^@]+@[^@]+\..+$)/gi
	if (objRegExp.test(strInputString)) {return true;} else {return false;}
}
function blnValidLatinString(strInputString){
	var objRegExp = /(^[a-z0-9]+$)/gi
	if (objRegExp.test(strInputString)) {return true;} else {return false;}
}

function doSubmitReview(){
document.getElementById('txtName').value = Trim(document.getElementById('txtName').value)
document.getElementById('txtEmail').value = Trim(document.getElementById('txtEmail').value)

if (document.getElementById('txtName').value.length<3) {alert('Πρέπει να συμπληρώσετε το όνομά σας.'); document.getElementById('txtName').focus(); return}
if (!blnValidEmail(document.getElementById('txtEmail').value)) {alert('Το e-mail σας δεν είναι σωστό.'); document.getElementById('txtEmail').focus(); return}
if (document.getElementById('txtReview').value.length<5) {alert('Πρέπει να συμπληρώσετε το μήνυμά σας.'); document.getElementById('txtReview').focus(); return}

document.getElementById('frmReview').action='/svc/postReview/send.asp'; 
document.getElementById('btnSubmit').disabled=true;
document.getElementById('frmReview').submit();
}

function doCheckReviewFields(){
document.getElementById('txtName').value = Trim(document.getElementById('txtName').value)
document.getElementById('txtEmail').value = Trim(document.getElementById('txtEmail').value)

if (document.getElementById('txtName').value.length<3) {alert('Πρέπει να συμπληρώσετε το όνομά σας.'); document.getElementById('txtName').focus(); return false}
if (!blnValidEmail(document.getElementById('txtEmail').value)) {alert('Το e-mail σας δεν είναι σωστό.'); document.getElementById('txtEmail').focus(); return false}
if (document.getElementById('txtReview').value.length<5) {alert('Πρέπει να συμπληρώσετε το μήνυμά σας.'); document.getElementById('txtReview').focus(); return false}

return true
}
