$(document).ready(function() {

	zoomImg();
	screenshotPreview();
	
	$('.wijnbrief_img').click(function(){
		location.href = bhref+'wijnbrief/pagina'+nxt+'.html';		
	});
	
	$('#cat_select').change(function(){
		var wrd = $(this).val();
		var cj = $('#cj').val();
		var url = bhref + 'kerstpakketten-'+cj+'/';
		if (wrd!='') {
			url += 'prijsklasse='+wrd+'/';
		} 
		location.href = url;
	});
	
	$('#cat_holder #nav_select').change(function(){
		if ($(this).val()!=0) { 
			location.href = bhref + 'kerstpakketten-' + $('#cj').val() + '/' + $(this).val(); 
		} else { 
			location.href = bhref + 'kerstpakketten-' + $('#cj').val() + '/'; 
		}
	});
	
	$('#dos_holder #nav_select').change(function(){
		if ($(this).val()!=0) { 
			location.href = bhref + 'rose-wijn-dossier-' + $('#dj').val() + '/' + $(this).val(); 
		} else { 
			location.href = bhref + 'rose-wijn-dossier-' + $('#dj').val() + '/'; 
		}
	});
	
	$('#cat_print').click(function(){
		window.print();
	});
});

function zoomImg(){
	$('#cat_holder .jqzoom').jqzoom({showPreload:false,title:false});
}

function screenshotPreview (){	
	/* CONFIG */
	
	
		xOffset = 10;
		yOffset = 170;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */

	$("a.preview").hover(function(e){ 
		var par =  $(this).parent().attr('id');
		var pos = $(this).position();
		if (par=='rcol') {
			xOffset = -140;
			yOffset = 30;
		}
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		if (this.t=='undefined') { this.t = ""; }
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='image preview' title='"+ this.t +"' /><br />"+ this.t +"</p>");								 

			$("#screenshot")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.show();						  
    },
	function(){
		
		this.title = this.t;	
		$("#screenshot").slideUp().remove();
    });	
	$("a.preview").mousemove(function(e){ 
		var par =  $(this).parent().attr('id');
		var pos = $(this).position();
		//alert(pos.left);

		if (par=='rcol') { 
			xOffset = -100;
			yOffset = 170;
			$("#screenshot")
			.css("left",e.pageX + "-100px")
			.css("top",(e.pageY - yOffset) + "px")				
		  } else {
		$("#screenshot")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
		  }
	});		
		
};

function confirmLink(theLink, what)
{

	var confirmMsg  = 'Wilt u '+what+' echt verwijderen?';
	
	// Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} // end of the 'confirmLink()' function


// START SHOW TIP
function showtip(current,e,text)
{
   if (document.all)
   {
      thetitle=text.split('<br>')
      if (thetitle.length > 1)
      {
        thetitles=""
        for (i=0; i<thetitle.length; i++)
           thetitles += thetitle[i] + "\r\n"
        current.title = thetitles
      }
      else current.title = text
   }

   else if (document.layers)
   {
       document.tooltip.document.write( 
           '<layer bgColor="#cccccc" style="border:2px ' +
           'solid black; font-size:12px;color:#000000;">' + text + '</layer>')
       document.tooltip.document.close()
       document.tooltip.left=e.pageX+5
       document.tooltip.top=e.pageY+5
       document.tooltip.visibility="show"
   }
}

function hidetip()
{
    if (document.layers)
        document.tooltip.visibility="hidden"
}


function photoWindow(url,winwidth,winheight) 
{
NewWindow=window.open(url,'descr','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollable=no,resizable=yes,copyhistory=no,width='+winwidth+',height='+winheight)
}

function newsWindow(url,winwidth,winheight) 
{
NewWindow=window.open(url,'descr',"toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=1,left=0,top=0,resizable=yes,copyhistory=yes,width=700, height=500")
}

function merchandise(img,winwidth,winheight) 
{
NewWindow=window.open(img,'descr','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollable=no,resizable=no,copyhistory=yes,width='+winwidth+',height='+winheight)
}
// TEXTBOX CHARACTER COUNTER
/**
 * DHTML textbox character counter (IE4+) script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

function taCount(visCnt) { 
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;
}
function taLimit2() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength2*1) return false;
}

function taCount2(visCnt) { 
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength2*1) taObj.value=taObj.value.substring(0,taObj.maxLength2*1);
	if (visCnt) visCnt.innerText=taObj.maxLength2-taObj.value.length;
}

// end TEXTBOX counter

var letters=' ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáÀÁéèÈÉíìÍÌïÏóòÓÒúùÚÙüÜ'
var numbers='1234567890'
var time='1234567890\'\".+'
var signs=',.:;@-\''
var mathsigns='+-=()*/'
var custom='<>#$%&?¿'
var dates='1234567890-'
var dob='1234567890/'
var zips='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
var address='0123456789ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáÀÁéèÈÉíìÍÌïÏóòÓÒúùÚÙüÜ-+ '
var phones='+-0123456789'
var emails='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.@'

function alpha(e,allow) {
var k;
k=document.all?parseInt(e.keyCode): parseInt(e.which);
return (allow.indexOf(String.fromCharCode(k))!=-1);
}

function TrowOn(src,OnColor,curs){src.style.cursor = curs; src.bgColor = OnColor;} 
function TrowOff(src,OffColor,curs){src.style.cursor = 'default'; src.bgColor = OffColor;}


function setVis(_what) {
document.getElementById(_what).style.visibility = "visible";
}

function setActionYr(objSelect){
	if (document.form1.race.value !="") {
		document.form1.race.value = '';
 		document.form1.submit(); return 0;
	} else {
		document.form1.race.value = '';
	}

}

function setAction(objSelect){
	if (document.form1.race.value !="") {
 		document.form1.submit(); return 0;
	} else {
		document.form1.race.value = '';
	}

}
function setAct(objSelect){
	if (document.form1.month.value !="") {
 		document.form1.submit(); return 0;
	} else {
		document.form1.month.value = 'all';
	}

}

function confirmDelete () {
	
}
