

function changeImages(img_name, new_src)
{
	if(document.images)
		document.images[img_name].src=eval(new_src+".src");
}

function openw(linki,Wwidth,Wheight,namei)
{
	if(namei==null){
		namei="window"
	}
	var	Pwidth=screen.width/2-Wwidth/2;
	var	Pheight=screen.height/2-Wheight/2;
	x=window.open(linki,namei,"width="+Wwidth+",height="+Wheight+",status,scrollbars,top="+Pheight+",left="+Pwidth);
	//,resizable
	x.focus();
}

function openn(num,news){
	openw("news.asp?id="+num+"&news="+news,500,575);
}

if(document.images){
	top10a = new Image;
	top10a.src = "images/hp/top10_1.gif";
		
	top10b = new Image;
	top10b.src = "images/hp/top10_2.gif";
	
	
	prov1a = new Image;
	prov1a.src = "images/wine_providers1.gif";
	prov1b = new Image;
	prov1b.src = "images/wine_providers1b.gif";	

	prov2a = new Image;
	prov2a.src = "images/wine_providers2.gif";
	prov2b = new Image;
	prov2b.src = "images/wine_providers2b.gif";	

	prov3a = new Image;
	prov3a.src = "images/wine_providers3.gif";
	prov3b = new Image;
	prov3b.src = "images/wine_providers3b.gif";	

	tab1a = new Image;
	tab1a.src = "images/hp/tab1a.gif";
	tab1b = new Image;
	tab1b.src = "images/hp/tab1b.gif";		
	
	tab2a = new Image;
	tab2a.src = "images/hp/tab2a.gif";
	tab2b = new Image;
	tab2b.src = "images/hp/tab2b.gif";				
	
	tab3a = new Image;
	tab3a.src = "images/hp/tab3a.gif";
	tab3b = new Image;
	tab3b.src = "images/hp/tab3b.gif";		
	
	tab4a = new Image;
	tab4a.src = "images/hp/tab4a.gif";
	tab4b = new Image;
	tab4b.src = "images/hp/tab4b.gif";	

	rtab1a = new Image;
	rtab1a.src = "images/hp/rec_tab1a.gif";
	rtab1b = new Image;
	rtab1b.src = "images/hp/rec_tab1b.gif";		
	
	rtab2a = new Image;
	rtab2a.src = "images/hp/rec_tab2a.gif";
	rtab2b = new Image;
	rtab2b.src = "images/hp/rec_tab2b.gif";				
	
	rtab3a = new Image;
	rtab3a.src = "images/hp/rec_tab3a.gif";
	rtab3b = new Image;
	rtab3b.src = "images/hp/rec_tab3b.gif";		
	
	rtab4a = new Image;
	rtab4a.src = "images/hp/rec_tab4a.gif";
	rtab4b = new Image;
	rtab4b.src = "images/hp/rec_tab4b.gif";	
	
	hp1 = new Image;
	hp1.src = "images/hp/rec_left2.gif";
	hp2 = new Image;
	hp2.src = "images/hp/rec_left.gif";

	
	search1a = new Image;
	search1a.src = "images/asearch_s3.gif";
	search1b = new Image;
	search1b.src = "images/asearch_s3b.gif";	
	
	search2a = new Image;
	search2a.src = "images/quick_search.gif";
	search2b = new Image;
	search2b.src = "images/quick_searchb.gif";	

	
}


function flipWriter(num){

	var a = document.getElementById("info_general");
	var b = document.getElementById("info_writer1");
	var c = document.getElementById("info_writer2");	

	var d = document.getElementById("w2");
	var e = document.getElementById("w1");
	
	

	switch(num){
		case 0:
			a.style.display="";
			b.style.display="none";
			c.style.display="none";			

			d.style.filter = "alpha(opacity=100)"
			d.style.MozOpacity = "1";

			e.style.filter = "alpha(opacity=100)"
			e.style.MozOpacity = "1";

			
			break;
		case 1:
			a.style.display="none";
			b.style.display="";
			c.style.display="none";			
		
			e.style.filter = "alpha(opacity=20)"
			e.style.MozOpacity = "0.4";
			
			break;
		case 2:
			a.style.display="none";
			b.style.display="none";
			c.style.display="";						
			
			d.style.filter = "alpha(opacity=20)"
			d.style.MozOpacity = "0.4";
						
			break;										
	}
}

function clearHP(){
	clearTimeout(counter2);
	clearTimeout(counter);
	clearTimeout(counter0);
}

function loadRec(num,writer){

	var linki
	linki = "wine_recommendations.asp?category="+(num+1);

	if(writer!=null){
		linki+= "&writer="+writer;
	}
	//clearHP();
	//stage.location = linki;
	stage.location = linki;

}

function insertIt() { 
var _y = document.getElementById('framediv'); 
var _x = window.frames[0].document.body.innerHTML; 
_y.innerHTML = _x;
//document.getElementById("hiddendiv").style.display = "none";
} 

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function showArchive(){
	//document.getElementById("archive").style.display = "inline";
}
var temp_name;

function overWriterName(obj,tag){
	obj.className='writer_on2';
	temp_name = obj.innerHTML;
	if(tag.indexOf("|")!=-1){
		obj.innerHTML = tag.substr(tag.indexOf("|")+2);
	}
	else{
		obj.innerHTML = tag;
	}
	
}


function outWriterName(obj){
	obj.className='writer';
	obj.innerHTML = temp_name;
}

function providers(cat,comp){
	if(comp!=0){
		openw("providers.asp?category="+cat+"&comp="+comp,600,750,"prov");
	}
	else{
		openw("providers.asp?category="+cat,600,750,"prov");
	}
}

function goWriter(num){
	location = "default.asp?writer="+num;
}

function goArticle(num){
	/**
	var linki
	linki = "article.asp?id="+(num);
	clearHP();
	stage.location = linki;
	*/
	location = "article.asp?id="+(num);
}


function goArchive(writer){
	var linki
	if(writer==null){
		linki = "archive.asp";
		//clearHP();
		//stage.location = linki;
	
	}
	else{
		linki="archive.asp?id=2&writer="+writer
	}
	location = linki;
}

function goRecipe(num){
	openw('recipe.asp?id='+num,525,620,'recipe');
}

function goRec(num){
	openw('rec_archive.asp?id='+num,710,230,'rec');
}


function recipe_archive(){
	opener.clearHP();
	opener.stage.location='archive.asp?id=1';
	self.close();
}


function printArticle() {

	if (window.print) {
		setTimeout('window.print();',200);
	}
	else if (agt.indexOf("mac") != -1) {
		alert("Press 'Cmd+p' on your keyboard to print article.");
	}
	else {
		alert("Press 'Ctrl+p' on your keyboard to print article.")
	}

}

function printArticleWin(num){
	openw('article.asp?id='+num+'&print=1',755,620);
}

function printArticleNews(num,id){
	location="news.asp?news="+num+"&id="+id+"&print=1";
}

function addResponse(table,id){
	linki = "add_response.asp?table="+table+"&id="+id;
	Wwidth = 545;
	Wheight = 340;
	var	Pwidth=screen.width/2-Wwidth/2;
	var	Pheight=screen.height/2-Wheight/2;	
	x=window.open(linki,"window2","width="+Wwidth+",height="+Wheight+",top="+Pheight+",left="+Pwidth);
	x.focus();
}

function showResponses(table,id){
	linki = "show_responses.asp?table="+table+"&id="+id;
	Wwidth = 580;
	if(id==0){
		Wheight = 500;
	}else{
		Wheight = 300;
	}
	var	Pwidth=screen.width/2-Wwidth/2;
	var	Pheight=screen.height/2-Wheight/2;	
	x=window.open(linki,"window3","width="+Wwidth+",scrollbars,status,height="+Wheight+",top="+Pheight+",left="+Pwidth);
	x.focus();
}

var openRes = null;

function openResponse(id){

	if(openRes!=null){
		document.getElementById("res"+openRes).style.display="none";
		document.getElementById("rest"+openRes).style.fontWeight="normal";
		if(top!=this){
			autofitIframe("stage");
		}
	}
	
	if(openRes==id){
		openRes = null;
	}
	else{
		document.getElementById("res"+id).style.display="";
		document.getElementById("rest"+id).style.fontWeight="bold";
		if(top!=this){
			autofitIframe("stage");
		}
		openRes = id;
	}
}

function openArtic(){
	//document.getElementById('artic').style.height='';
	if(location.href.indexOf("&print=2")>0){
		location=location.href.substr(0,location.href.indexOf("&print=2"));
	}
	else{
		location=location.href+"&print=2";
	}
}

function autofitIframe(id){
	if (!window.opera && !document.mimeType && document.all && document.getElementById){
 		parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
 	}
 	else if(document.getElementById) {
 		parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
 	}
}



function bookmark(anchor){
   if(window.external)
   {
	   window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
	   return false;
   }
   return true;
}


function goRecRes(category,writer,rec_id){
	showResponses('rec',rec_id);
	location = "wine_recommendations.asp?category="+category+"&writer="+writer;
	
}

function searchNextPage(){
	document.searchi.nav.value=(parseInt(document.searchi.nav.value)+1);
	document.searchi.submit();
}
function searchPrevPage(){
	document.searchi.nav.value=(parseInt(document.searchi.nav.value)-1);
	document.searchi.submit();
}

function goSearch(query){
	var linki
	linki = "asearch.asp?query="+query.replace(" ","%20");
	stage.location = linki;
	
}

function overSearchTD(){
	changeImages('search1','search1b');
	aaa = document.getElementById("search1td");
	aaa.style.backgroundColor = "#AA9D2E";
}

function outSearchTD(){
	changeImages('search1','search1a');
	aaa = document.getElementById("search1td");
	aaa.style.backgroundColor = "#978844";	
}


function bookmark(anchor){
   if(window.external)
   {
	   window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
	   return false;
   }
   return true;
}
