/* Alle basis JS functionaliteit */
$(function(){
	/* Value van de input verbergen onClick */
	$(".search input, .product-search input").focus(function () {
		if ($(this).val() == $(this).attr("title")){
			$(this).val("");
		}
	});
	$(".search input, .product-search input").blur(function () {
		if ($(this).val() == ""){
			$(this).val($(this).attr("title"));
		}
	});
	$("a.inactive").parent().addClass("inactive");
	
	//$(window).scroll(function() {
	//	var scrollT = Math.floor( $(window).scrollTop() * 0.4 /* scroll factor */ ) * -1 /* invert number to negative */
	//	$('body, .footer, .content').css('background-position', '100% ' + scrollT + 'px');
	//});
	
	$('#product-scroller li').click(function(i){
		$this = $(this);
		iNr = $this.index();
		$content = $this.find('div').clone().show();
		
		$('#product-scroller li').removeClass('active');
		$this.addClass('active');
		
		$('#product-info').empty().append($content).show();
	});
	//open first
	$('#product-scroller li:first').trigger('click');
});

function mailThisPage() {
		var href;
		href='/tkh_C01/MailThisPage.asp' + document.location.search  ;
		href = changeQueryStringOfURL(href,'kijkglaslink','');
		href = changeQueryStringOfURL(href,'mailthispage','1');
		document.location.href = href;
	}
	
function mailThisPageUFU(icomid,imodid,iitemid, ssessionid) {
		var href;
		href='/tkh_C01/MailThisPage.asp' + document.location.search  ;
		href = changeQueryStringOfURL(href,'kijkglaslink','');
		href = changeQueryStringOfURL(href,'mailthispage','1');
		href = changeQueryStringOfURL(href,'comid',icomid);
		href = changeQueryStringOfURL(href,'modid',imodid);
		href = changeQueryStringOfURL(href,'itemid',iitemid);
		href = changeQueryStringOfURL(href,'sessionid',ssessionid);		
		document.location.href = href;
	}	

function addToFavorites(href,title) {
	var url, iCustID,iComID,iModID,iItemID;
	var iSlashes,iSlashDrie, sDomein;		
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome')>-1;
	getQueryStringVariables(href);
	iCustID = asQueryString['custid'];
	iComID  = asQueryString['comid'];
	iModID  = asQueryString['modid'];
	iItemID = asQueryString['itemid'];
	iSlashes = href.indexOf('//');
	if (iSlashes>0) {
		iSlashDrie = href.indexOf('/',iSlashes+2);
	}  
	if (iSlashDrie>0) {
		sDomein = href.substr(0,iSlashDrie);
	}			
		
	if(!asQueryString['itemid']){
		iItemID = '0';
	}
		
	if (iCustID && iCustID>0) {
		url=sDomein +'/Optelecom_c01/default.asp?custid='+iCustID+'&';
	}else{
		url=sDomein + '/Optelecom_c01/default.asp?'
	}
		
	if (iComID && iComID>0) {
		url+= 'comid='+iComID;
		if (iModID && iModID>0) {
			url+= '&modid='+iModID+'&itemid='+iItemID   ;
		}
	}else if (iModID && iModID>0) {
		url+= 'modid='+iModID+'&itemid='+iItemID   ;
	}						
	
	try {
		if (is_chrome) {
			alert('Warning!\nChrome has no support for automatically adding bookmarks, use CTRL + D instead.');
		}else if (window.sidebar) { 
			// Mozilla Firefox Bookmark	
			alert('Warning!\nPlease adjust the link yourself, else it will only open in the Sidebar.\nFor the moment there is no other way in your browser.');						
			window.sidebar.addPanel(title, url,"");				
		}else if(window.opera && window.print) { 
			// Opera Hotlist<BR>	
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();					
		} else if( window.external ) { 
			// IE Favorite<BR>		
			window.external.AddFavorite( url, title); 	
		}
	}catch(e){}	
}

