var PHOTO_ORIGINAL = 0;
var PHOTO_LARGE = 1;
var PHOTO_MM = 2;


var MEDIA_PICTURE = 1
var MEDIA_VIDEO	= 2
var MEDIA_SOUND	= 3
var MEDIA_FLASH	= 4
var MEDIA_STREAM = 5

// to use with the 'viewer.asp'
var strURL = "";

function MM_openVDOWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_preloadImages2() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages2.arguments[0]; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function DisplayPhoto(lPhotoID, lSize)
{
	showphoto(lPhotoID, lSize)
}

function DisplayDocument(lDocID)
{
	var i;
	var strURL=top.location.href;
	var strArray1=strURL.split('?');
	var strArray2=strArray1[1].split('&');

	strURL=strArray1[0];
	strURL+='?';
	for (i=0;i<strArray2.length;i++)
		if (strArray2[i].substr(0,2)!='p1')
			strURL+=strArray2[i] + '&';

	strURL+='p1=' + lDocID.toString();

	top.location.href=strURL;	
}

function showphoto(lPhotoID, lSize)
{
	var strFeatures = "top=100,left=400,width=400,height=400,toolbar=no,menubar=yes,location=no,directories=no,resizable=yes";
	if ( lSize == PHOTO_MM )
		strFeatures += ",scrollbars=yes";

	var NewWindow = window.open(strURL + "viewer.asp?media=" + MEDIA_PICTURE + "&id=" + lPhotoID.toString() + "&size=" + lSize.toString(), "PictureViewer", strFeatures);
	try
	{
		if (NewWindow.document.leftmargin==0)
		{
			NewWindow.document.leftmargin=0;
			NewWindow.document.topmargin=0;
		}
	}
	catch(e)
	{
	}
	NewWindow.focus();
}

function showvideo(strFileURL)
{	
	var strFeatures = 'top=100,left=400,width=260,height=220,toolbar=no,menubar=no,location=no,directories=no';
	var NewWindow = window.open("viewer.asp?media=" + MEDIA_VIDEO + "&file=" + strFileURL, 'VideoViewer', strFeatures);
	try
	{
		if (NewWindow.document.leftmargin==0)
		{
			NewWindow.document.leftmargin=0;
			NewWindow.document.topmargin=0;
		}
	}
	catch(e)
	{
	}
	NewWindow.focus();
}

function sendmail(lDocID)
{
	var strFeatures = 'top=100,left=400,width=329,height=279,toolbar=no,menubar=no,location=no,directories=no';
	var NewWindow = window.open('sendmail.asp?p1=' + lDocID.toString(), 'SendMailWindow', strFeatures);
	try
	{
		if (NewWindow.document.leftmargin==0)
		{
			NewWindow.document.leftmargin=0;
			NewWindow.document.topmargin=0;
		}
	}
	catch(e)
	{
	}
	NewWindow.focus();	
}


function SendDocumentMail(strURL, lPar1, lPar2, lPar3)
{
	window.open(strURL + "?p1=" + lPar1 + "&p2=" + lPar2 + "&p3=" + lPar3, "SEND_MAIL", "width=329,height=279,toolbar=no,menubar=no,location=no,directories=no");
}

function SendMailPage()
{
}

function PrintTitle(strTitle, strColor)
{
	document.write("<p class='margins14171717'><table border=0 cellpadding=0 cellspacing=0 width='100%'><tr height=21><td width='5%' background='titleimg/titlebck.gif' valign='top' nowrap><font class='fonts16px' color='" + strColor + "'><b>" + strTitle + "&nbsp;</b></font></td><td width='95%'><img src='titleimg/titleright.gif'></td></tr></table></p>");
}

function ChangeVote( lngPoll, lngVote )
{
	document.forms["FormVote" + lngPoll].elements["vote_id"].value = lngVote;
}

function doVote( lngPoll )
{
	var lngVote = document.forms["FormVote" + lngPoll].elements["vote_id"].value;
	
	if ( lngVote == 0 )
	{
		alert( "Θα πρέπει να επιλέξετε μια απάντηση." );
		return;
	}
	document.forms["FormVote" + lngPoll].submit();
}

function SubmitVoteForm( poll, questions )
{
	var ar_q = questions.split(",");
	var bSuccess = true;
	
	for (var i=0;i<ar_q.length;i++)
	{
	  if (!bSuccess)
	    break;
	    
	  bSuccess = false;
	  if (document.forms["FormVote" + poll].elements["question" + ar_q[i]].length>0)
	  {
	    for (var j=0;j<document.forms["FormVote" + poll].elements["question" + ar_q[i]].length;j++)
	    {
	      if (document.forms["FormVote" + poll].elements["question" + ar_q[i]][j].checked)
	      {
	        bSuccess = true;
	        break;
	      }
	    }
	  }
	}
	
	if ( !bSuccess )
	{
	  if (ar_q.length==1)
  		alert( "Θα πρέπει να επιλέξετε μια απάντηση στην ερώτηση." );
  	else
  	  alert( "Θα πρέπει να απαντήσετε σε κάθε ερώτηση." );
		return;
	}
	
	document.forms["FormVote" + poll].submit();
}

function ChangeStars(starIndex, starValue, qid)
{
  for(var i=1; i<=starIndex; i++)
    document.getElementById('imgstar' + i).src='images/starfull.gif';
    
  for(var i=starIndex+1; i<=100; i++)
  {
    if (document.getElementById('imgstar' + i))
      document.getElementById('imgstar' + i).src='images/starempty.gif';
    else
      break;
  }
  
  document.forms['FORM_COMMENTS'].elements['question' + qid].value=starValue; 
}

function CreateStars()
{
  var args=CreateStars.arguments;
  var stars=args[0];
  var starsCount=args[1];
  var strBR="<br>";
  var starColor="";
  var strTitle="<b>Αξιολόγηση&nbsp;</b>"
  var strStyle="class='c_body c_bodycolor'";
  var strTStyle="";
  if ((args.length>2) && (!args[2])) strBR="";
  if (args.length>3) starColor=args[3];
  if (args.length>4) strTitle=args[4];
  if (args.length>5) strStyle=args[5];
  if (args.length>6) strTStyle=args[6];
  var strStars=strBR + "<table border=0 cellpadding=2 cellspacing=0 "+strTStyle+">";
  strStars+="<tr><td "+strStyle+">"+strTitle+"</td>";
  for (var i=0;i<stars;i++)
    strStars+="<td><img src='images/starfull"+starColor+".gif' width=16 height=16></td>";
  for (var i=stars;i<starsCount;i++)
    strStars+="<td><img src='images/starempty"+starColor+".gif' width=16 height=16></td>";
  strStars+="</tr></table>";
  document.write(strStars);
}

function SendMailPage(strPP)
{
	if (strPP != "")
	{
		var strFeatures = 'top=100,left=400,width=400,height=200,toolbar=no,menubar=no,location=no,directories=no,status=no';
		var NewWindow = window.open('sendto.asp?pp=' + strPP, 'SendMailWindow', strFeatures);	
		try
		{
			if (NewWindow.document.leftmargin==0)
			{
				NewWindow.document.leftmargin=0;
				NewWindow.document.topmargin=0;
			}
		}
		catch(e)
		{
		}
		NewWindow.focus();
	}
}

function AddPhoto(vurl, iid, func)
{
	openDialog2(vurl+'?iid='+iid, 400, 200, func);	
}
function AddPhoto2(vurl, func)
{
	openDialog2(vurl, 400, 200, func);	
}

function SelectBlogImage(url, func)
{
	openDialog2(url, 400, 500, func);	
}

function WriteDate()
{
  var months=new Array(13);
  months[1]="Ιανουαρίου";
  months[2]="Φεβρουαρίου";
  months[3]="Μαρτίου";
  months[4]="Απριλίου";
  months[5]="Μαίου";
  months[6]="Ιουνίου";
  months[7]="Ιουλίου";
  months[8]="Αυγούστου";
  months[9]="Σεπτεμβρίου";
  months[10]="Οκτωβρίου";
  months[11]="Νοεμβρίου";
  months[12]="Δεκεμβρίου";

  var time=new Date();
  var lmonth=months[time.getMonth() + 1];
  var date=time.getDate();
  var year=time.getYear();
  if (year < 2000)    // Y2K Fix, Isaac Powell
  year = year + 1900; // http://onyx.idbsu.edu/~ipowell
  document.write(" " + date + " ");
  document.write(lmonth + " " + year + " ");
}


function DoMenuType(){
var args=DoMenuType.arguments;if(args.length==8){location.href = strURL+'mtlink.asp?pp='+escape(location.href)+'&mt='+args[0]+'&mid='+args[1]+'&p1='+args[2]+'&p2='+args[3]+'&p3='+args[4]+'&p4='+args[5]+'&p5='+args[6]+'&p6='+args[7];}
else{location.href = strURL+'mtlink.asp?pp='+escape(location.href)+'&mt='+args[0]+'&mid='+0+'&p1='+args[1]+'&p2='+args[2]+'&p3='+args[3]+'&p4='+args[4]+'&p5='+args[5]+'&p6='+args[6];}
}