﻿var newwindow;

//function retrieveSelectResult(str1,str2){
//alert(str1+" "+str2);
//}
	
function searchInnerHTML(){
	
	var s = document.getElementById("somediv");
	var t = document.getElementById("visibleSearch");
	t.innerHTML=(s.innerHTML || s.defaultHTML);
	t.style.dispay='inline';

}

function setTitle(str){
	if (str.value=="")
		str.value="<Τίτλος>";
}

function showBlock(object, block){
	  if (object.selectedIndex!=0) document.getElementById(block).style.display='block'; 
	  else document.getElementById(block).style.display='none';
}



function getInfoFromDatabase(index,id){
  var query;
  var idInfo;
  var div;
  
  if (id=="searchBy1"){
	 idInfo="searchdiv1";
	 div="SearchCriteria1";
	 query="1";
  }else if (id=="searchBy2"){
     idInfo="searchdiv2";
     div="SearchCriteria2";
	 query="2";
  }
  else{
     idInfo="searchdiv3";
     div="SearchCriteria3";
	 query="3";
  }
  
  
  if (index==1)
	query = "SELECT DISTINCT Artist_Name AS info FROM mmst_objects ORDER BY Artist_Surname";
  else if (index==2)
 	query = "SELECT DISTINCT Material AS info FROM mmst_objects ORDER BY Material";
  else if (index==0)
	query="0";
   retrieveInfo(query,idInfo,div);
}

function linkToPdf(str){
	var strToInt = new Number(str);
//	alert(typeof(str)+" "+str+" "+new Number(str));
	if (strToInt==30 || strToInt==52 || strToInt==3 || strToInt==4 || strToInt==77 || strToInt==39
	|| strToInt==51 || strToInt==38 || strToInt==89 || strToInt==10 || strToInt==43 || strToInt==54
	|| strToInt==90 || strToInt==90 || strToInt==105 || strToInt==35 || strToInt==99 || strToInt==100
	|| strToInt==57){
		var url = "./pdf/"+str+".pdf";
		newwindow=window.open(url,'name','height=600,width=800,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
		if (window.focus) {newwindow.focus()}	
	}else if (strToInt==37){
		var url = "./qtvr/"+str+".html";
		newwindow=window.open(url,'name','height=600,width=800,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
		if (window.focus) {newwindow.focus()}		
	}else if(strToInt == 25 || strToInt == 96 || strToInt == 33 || strToInt == 44 || strToInt == 37){
		var url = "./qtvrs/"+str+".html";
		//alert(url);
		newwindow=window.open(url,'name','height=600,width=800,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
		if (window.focus) {newwindow.focus()}
	}else if(strToInt == 0){
		alert("Επιλέξτε κάποιο τρισδιάστατο έκθεμα!");
	}else{
		//var url = "./popups/large_image.php?img="+str+"";
		var url = "./images/big/"+str+".jpg";
		newwindow=window.open(url,'name','resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
		if (window.focus) {newwindow.focus()}		
	}
   //newwindow=window.open('http://www.google.com','Μακεδονικο Μουσείο Σύγχρονης Τέχνης','height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
}

function showPdf(str){
  document.frm1.pdf.value = str;
}

function showResults(str){
  document.getElementById('exc_num').innerHtml = str;
}
function advanceSearch(index)
{
	var t,alertString;
	var flag=false;

	
	if (index==3)
	{
	t=dhtmlwindow.open('divbox', 'div', 'somediv', 'Σύνθετη Αναζήτηση', 'width=360px,height=200px,left=200px,top=150px,resize=0,scrolling=0');
	}
	else if (index==-1){
		



			var op1,op2,query,crit1,crit2,crit3;
			var crit1Inf, crit2Inf, crit3Inf;
			var type=3;
			
			flag=true;
			/*----------------------------------*/
			/*if (document.AdvanceSearch.search1.selectedIndex==0) op1="";
			else if (document.AdvanceSearch.search1.selectedIndex==1) op1="AND";
			else if (document.AdvanceSearch.search1.selectedIndex==2) op1="OR";
			if (document.AdvanceSearch.search2.selectedIndex==0) op2="";
			else if (document.AdvanceSearch.search2.selectedIndex==1) op2="AND";
			else if (document.AdvanceSearch.search2.selectedIndex==2) op2="OR";
			*/
			if (document.AdvanceSearch.filter1.selectedIndex==0) op1="OR";
			else op1="AND";
			
			if (document.AdvanceSearch.filter2.selectedIndex==0) op2="OR";
			else op2="AND";
			/*----------------------------------*/
			if(document.AdvanceSearch.searchBy1.selectedIndex==0) crit1="";
			else if(document.AdvanceSearch.searchBy1.selectedIndex==1) crit1="Artist_Name";
			else if(document.AdvanceSearch.searchBy1.selectedIndex==2) crit1="Material";
			else if(document.AdvanceSearch.searchBy1.selectedIndex==3) crit1="Year";
			
				
			if(document.AdvanceSearch.searchBy2.selectedIndex==0) crit2="";
			else if(document.AdvanceSearch.searchBy2.selectedIndex==1) crit2="Artist_Name";
			else if(document.AdvanceSearch.searchBy2.selectedIndex==2) crit2="Material";
			else if(document.AdvanceSearch.searchBy2.selectedIndex==3) crit2="Year";
			

			if(document.AdvanceSearch.searchBy3.selectedIndex==0) crit3="";
			else if(document.AdvanceSearch.searchBy3.selectedIndex==1) crit3="Artist_Name";
			else if(document.AdvanceSearch.searchBy3.selectedIndex==2) crit3="Material";
			else if(document.AdvanceSearch.searchBy3.selectedIndex==3) crit3="Year";
			
			if(document.AdvanceSearch.SearchCriteria1.selectedIndex==0) { crit1Inf=""; }
			if(document.AdvanceSearch.SearchCriteria2.selectedIndex==0) {crit2Inf="";}
			if(document.AdvanceSearch.SearchCriteria3.selectedIndex==0) crit3Inf="";
			
			/*----------------------------------*/
			/*
			if(op1!=""){
				if (crit2=="" || crit2Inf=="") {flag=false; alertString = "Παρακαλώ επιλέξτε κριτήριο ή διαγράψτε κάποιο τελεστή!";}
				else if(op2!=""){
					if (crit3=="" || crit3Inf=="") {flag=false; alertString = "Παρακαλώ επιλέξτε κριτήριο ή διαγράψτε κάποιο τελεστή!";}
				}
			}
			else if(op1==""){crit2=""; crit2Inf="";}
			else if(op2==""){crit3=""; crit3Inf="";}
			*/
			if (crit1Inf=="" && crit2Inf=="" && crit3Inf==""){op1=""; op2=""; type=4;}//flag=false; alertString="Παρακαλώ επιλέξτε κάποιο κριτήριο...";}
			/*----------------------------------*/			
			if (crit1=="Artist_Name" || crit1=="Material"){  
					var x=document.getElementById("SearchCriteria1");
					if (x.selectedIndex==0){flag=false; alertString="Παρακαλώ επιλέξτε κάποιο κριτήριο..."; crit1Inf="";}
					else
						crit1Inf=x.options[x.selectedIndex].text;
			} 
			if (crit2=="Artist_Name" || crit2=="Material"){
				var x=document.getElementById("SearchCriteria2");
					if (x.selectedIndex==0){flag=false; alertString="Παρακαλώ επιλέξτε κάποιο κριτήριο..."; crit2Inf="";}
					else
						crit2Inf=x.options[x.selectedIndex].text;
			
			}
			if (crit3=="Artist_Name" || crit3=="Material"){
				var x=document.getElementById("SearchCriteria3");
				if (x.selectedIndex==0){flag=false; alertString="Παρακαλώ επιλέξτε κάποιο κριτήριο..."; crit3Inf="";}
				else
					crit3Inf=x.options[x.selectedIndex].text;
			}
			if (crit1=="Year"){
				var x=document.getElementById("searchInput1");
				if (x.value==""){flag=false; alertString="Παρακαλώ επιλέξτε κάποιο κριτήριο..."; crit1Inf="";}
				else crit1Inf=x.value;
			}
			if (crit2=="Year"){
				var x=document.getElementById("searchInput2");
				if (x.value==""){flag=false; alertString="Παρακαλώ επιλέξτε κάποιο κριτήριο..."; crit2Inf="";}
				else
				crit2Inf=x.value;
			}
			if (crit3=="Year"){
				var x=document.getElementById("searchInput3");
				if (x.value==""){flag=false; alertString="Παρακαλώ επιλέξτε κάποιο κριτήριο..."; crit3Inf="";}
				else crit3Inf=x.value;
			}
		
			
			
		
		//}
	if (flag){
		if (crit1Inf!="" && crit2Inf=="" && crit3Inf=="") {op1=""; op2="";}
		else if (crit1Inf=="" && crit2Inf!="" && crit3Inf=="") {op1=""; op2="";}
		else if (crit1Inf=="" && crit2Inf=="" && crit3Inf!="") {op1=""; op2="";}
		else if (crit1Inf!="" && crit2Inf!="" && crit3Inf=="") {op2="";}
		else if (crit1Inf!="" && crit2Inf=="" && crit3Inf!="") {op2=""; crit2=crit3; crit3=""; crit2Inf=crit3Inf; crit3Inf="";}
		else if (crit1Inf=="" && crit2Inf!="" && crit3Inf!="") {op2=op1; op1="";}
		else if (crit1Inf!="" && crit2Inf!="" && crit3Inf!="") {op2=op1;}
		
		
		query =  crit1 + "/"  + crit1Inf + "/" + op1+"/"+crit2+"/"+crit2Inf+"/"+op2+"/"+crit3+"/"+crit3Inf;
		alertString=query;
		//alert(alertString);
		searchInfo(alertString, type); /*document.search.searchBy.selectedIndex*/
	}else
		alert(alertString);	
	}
}
//----------------
function movement(image){
	var clicks=document.frm1.formovement.value * 1;
	
	
	if (image==1){
		test1.DataIn(clicks);
	}
	else
	{
		test2.DataIn(clicks);
	}
	
	if (clicks==2001) clicks=2002;
	else clicks=2001;
	document.frm1.formovement.value=clicks;
	
	/*if (image==2){
	 document.getElementById('myButton').style.both='clear';
	 document.getElementById('movoff').style.display='none';
	 document.getElementById('movon').style.display='inline';	 
	}
	else{
	 document.getElementById('myButton').style.both='clear';
	document.getElementById('movoff').style.display='inline';
	 document.getElementById('movon').style.display='none';	 
	}*/
}

function openWindow()
{

    //dhtmlwindow.open('divbox', 'div', 'somediv', '#4: DIV Window Title', 'width=450px,height=300px,left=200px,top=150px,resize=1,scrolling=1');
	var ekthema = "Εκθεμα " + document.frm1.formvar1.value;
	var txtHintId = document.getElementById('myframe').contentWindow.document.getElementById('txtHint').id;
	document.getElementById('myframe').contentWindow.document.body.onclick= function() { 
	dhtmlwindow.open('divbox2', 'div2', txtHintId, ekthema, 'width=450px,height=300px,left=200px,top=150px,resize=1,scrolling=1');
	//window.open('blank.html','myframes','width=300,height=200')
	}
}
