var sort;var order;var index=null;var isRowOpen=Array();function contains(array,item){var bool=false;for(var i=0;i<array.length;i++){if(array[i]==item){bool=true;break;}}
return bool;}
function remove(array,item){for(var i=0;i<array.length;i++){if(array[i]==item)array[i]=null;}}
function setDiv(id){div=document.getElementById(id);}
function setVisible(n){document.getElementById(n).style.visibility="visible";}
function collapseDiv(tdiv){document.getElementById(tdiv).innerHTML="";document.getElementById(tdiv).className="blank";var id=tdiv.substring(1,tdiv.length);var item="p"+id;remove(isRowOpen,item);}
function closeAll(){for(var i=0;i<isRowOpen.length;i++){var id=isRowOpen[i].substring(1,isRowOpen[i].length);var div="i"+id;collapseDiv(div);var r="p"+id;remove(isRowOpen,r);}}
function colorImage(n,b){if(b=="true"){var colored="./img/artist_thumbs/"+n+"_color.jpg";document.getElementById(n).src=colored;}
else{var saturated="./img/artist_thumbs/"+n+".jpg";document.getElementById(n).src=saturated;}}
function hoverPic(id,mode){if(mode=="in"){document.getElementById(id).src="img/"+id+"_hover.jpg";}else if(mode=="out"){document.getElementById(id).src="img/"+id+".jpg";}}
function rowOver(id,mode,oldClass){if(mode=="in"){document.getElementById(id).className="selected";document.getElementById(id).style.cursor="pointer";}else if(mode=="out"&&(isRowOpen.length==0||!contains(isRowOpen,id))){document.getElementById(id).className=oldClass;}}
function initCap(str){var str=str.substring(0,1).toUpperCase()+str.substring(1,str.length).toLowerCase();return str;}
function pause(millis){var date=new Date();var curDate=null;do{curDate=new Date();}
while(curDate-date<millis);}
var div=null;var http=getHTTPObject();function getHTTPObject(){var http=false;if(typeof ActiveXObject!='undefined'){try{http=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{http=new ActiveXObject("Microsoft.XMLHTTP");}
catch(E){http=false;}}}else if(XMLHttpRequest){try{http=new XMLHttpRequest();}
catch(e){http=false;}}
return http;}
function handler(){if(div!=null){if(http.readyState==1){div.innerHTML='Loading...';}
else if(http.readyState==4&&http.status==200){if(http.responseText=="true"){updateCommentCount(mainId);showComments(mainId);}else if(http.responseText=="false"){showCommentForm(mainId);}else div.innerHTML=http.responseText;}}}
function postScript(url,params){http=getHTTPObject();http.open("POST",url,true);http.setRequestHeader("Content-type","application/x-www-form-urlencoded");http.setRequestHeader("Content-length",params.length);http.setRequestHeader("Connection","close");http.onreadystatechange=handler;if(params!=null)http.send(params);}
function getScript(url,params){http=getHTTPObject();http.open("GET",url+"?"+params);http.onreadystatechange=handler;http.send(null);}
function updateServiceInfo(dest,action){setDiv("servicecontent");http.open("GET","service_info.php?action="+action+"&dest="+dest);http.onreadystatechange=handler;http.send(null);}
function updateRates(service){setDiv("ratesbox");http.open("GET","rates.php?service="+service);http.onreadystatechange=handler;http.send(null);}
function updateTests(page){setDiv("testbox");http.open("GET","testimonials.php?page="+page);http.onreadystatechange=handler;http.send(null);}
function imgPreloader(images){for(var i=0;i<images.length;i++){var img=new Image();img.src=images[i];}}
function showItinerary(id,images){var d="i"+id;var p="p"+id;if(contains(isRowOpen,p)){collapseDiv(d);remove(isRowOpen,p);}else{imgPreloader(images);setDiv(d);div.className="itinerary";http.open("GET","service_info.php?action=expand&id="+id);http.onreadystatechange=handler;http.send(null);isRowOpen.push(p);}}
function updatePlace(place,id){var div="pb"+id;setDiv(div);http.open("GET","service_info.php?action=update&place="+place);http.onreadystatechange=handler;http.send(null);}
function showEditRow(table,action,id){var e="e"+id;var p="p"+id;if(contains(isRowOpen,p)){collapseDiv(e);remove(isRowOpen,p);}else{setDiv(e);div.className="editrow";http.open("GET","editpanel.php?table="+table+"&action="+action+"&id="+id);http.onreadystatechange=handler;http.send(null);isRowOpen.push(p);}}
function updateEditPanel(service){setDiv('ratesbox');var params="service="+service;postScript('limopanel.php',params);}
function sendMail(div){var values=Array();var cDiv=document.getElementById(div);var kinds=Array();kinds[0]="input";kinds[1]="select";kinds[2]="textarea";for(var j=0;j<kinds.length;j++){var paramlist=cDiv.getElementsByTagName(kinds[j]);for(var i=0;i<paramlist.length;i++){var tempDiv=paramlist[i];if(tempDiv.id!="submit"&&tempDiv.id!="additional")values.push(wrapValue(tempDiv.id));}}
if(countErrors(values)==0){var url="sendmail.php";var params="";for(var i=0;i<values.length;i++){var tempValue=values[i];var e="&";if(i==values.length-1)e="";params=params+tempValue[0]+"="+tempValue[1]+e;}
setDiv('reservationbox');postScript(url,params);}else setOnErrors(values);}
function submit(){submitValues=new Array();var panel=arguments[0];var action=arguments[1];var id=arguments[2];for(var i=0;i<arguments.length-3;i++){var tempValue=wrapValue(arguments[i+3]);submitValues.push(tempValue);}
if(countErrors(submitValues)==0){var url="submitdata.php";var params="panel="+panel+"&action="+action+"&id="+id+"&";for(var i=0;i<submitValues.length;i++){var tempValue=submitValues[i];var e="&";if(i==submitValues.length-1)e="";params=params+tempValue[0]+"="+tempValue[1]+e;}
var e="e"+id;setDiv(e);postScript(url,params);pause(200);http=getHTTPObject();isRowOpen=Array();updateEditPanel('');}else setOnErrors(submitValues);}
function setOnErrors(values){for(var i=0;i<values.length;i++){var tempArg=values[i];if(tempArg[1]==""){document.getElementById(tempArg[0]).style.background="#ffb19f";}else{document.getElementById(tempArg[0]).style.background="#99ff99";}
document.getElementById('error').innerHTML="Please fill required fields.";}}
function countErrors(values){var errcount=0;for(var i=0;i<values.length;i++){var tempArg=values[i];if(tempArg[1]=="")errcount++;}
return errcount;}
function wrapValue(value){wrap=new Array();wrap[0]=value;wrap[1]=document.getElementById(value).value;return wrap;}
function login(){setDiv("overpanel");submitValues=new Array();for(var i=0;i<arguments.length;i++){var tempValue=wrapValue(arguments[i]);submitValues.push(tempValue);}
if(countErrors(submitValues,0)==0){var url="login.php";var params="";for(var i=0;i<submitValues.length;i++){var tempValue=submitValues[i];var e="&";if(i==submitValues.length-1)e="";params=params+tempValue[0]+"="+tempValue[1]+e;}
postScript("login.php",params);}
else{for(var i=0;i<submitValues.length;i++){var tempArg=submitValues[i];var err="err_"+tempArg[0];if(tempArg[1]==""){document.getElementById(tempArg[0]).style.background="#ffb19f";document.getElementById(err).innerHTML=initCap(tempArg[0])+" required.";}else{document.getElementById(tempArg[0]).style.background="white";document.getElementById(err).innerHTML="";}}}}
function logout(){setDiv("overpanel");http.open("GET","logout.php",true);http.onreadystatechange=handler;http.send(null);document.getElementById('editpanel').innerHTML="";document.getElementById('editpanel').style.visibility="hidden";}
function shiftGallery(genre,id){if(id>=0){setDiv('artistgallery');var url="printgallery.php";var params="genre="+genre+"&id="+id;postScript(url,params);}}
function showEditPanel(id,panel,oldClass){var tempDiv="e"+id;if(isRowOpen==0&&isAddOpen==false){if(isRowOpen!=0){var oldDiv="e"+isRowOpen;collapseDiv(oldDiv);}
setDiv(tempDiv);div.className="editRow";var params="action=edit&panel="+panel+"&id="+id+"&oldClass="+oldClass;postScript('editpanel.php',params);isRowOpen=id;}
else if(isRowOpen==id){collapseDiv(tempDiv);isRowOpen=0;}}
function editItinerary(id){var url="editpanel.php";var params="table=itineraries&action=showplaces&id="+id;setDiv("i"+id);getScript(url,params);}
function editPlace(id){window.open("editplaces.php?id="+id,"","top=10, left=10, width=770, height=480, status=no, menubar=no, location=no, directories=no, toolbar=no scrollbar=no resizable=no");}