//
//  Author:     Zishan Zulfiqar
//  Created:    10 october 2007
//

if (typeof(boolHomepage)=="undefined") {
   var boolHomepage = false;
}

function fixLogo () {
	/*
	if(typeof(logoOff)=="undefined") logoOff = false;
	if (!logoOff) {
		var objLogo, objLeft;
		objLeft = elementById('left');
		objLogo = elementById('logoStamp');
		
		if (objLogo.getAttribute('mleft') == null)
			objLogo.setAttribute('mleft', getStyleValue(objLogo, 'marginLeft'));
			
		if (findPos(objLogo).left < -25) {
			objLogo.style.marginLeft = ((findPos(objLeft).left *- 1) - 30) + 'px';
		} else {
			objLogo.style.marginLeft = objLogo.getAttribute('mleft');
		}
	}
	*/
	if ($('.logoStamp').size() > 0)
	{
		var objLogo, objLeft;
		left = $('#left');
		logo = $('.logoStamp');
		
		if (logo.attr('mleft') == "undefined")
			logo.attr('mleft', logo.css('margin-left'));
		
		if (logo.position().left < -25) {
			logo.css('margin-left', ((logo.position().left *- 1) - 30) + 'px');
		} else {
			logo.css('margin-left', logo.attr('mleft'));
		}
	}
}

// Nivo slider
$(window).load(function(){
	if (typeof(jQuery().nivoSlider) != 'undefined')
	{
		$('#banner_slider').nivoSlider({
			effect: 'fade',
			animSpeed: 250, // Slide transition speed
			pauseTime: 3000, // How long each slide will show
			directionNav: false, // Next & Prev navigation
			directionNavHide: true, // Only show on hover
			controlNav: true, // 1,2,3... navigation
			keyboardNav: false, // Use left & right arrows
			pauseOnHover: false, // Stop animation while hovering
			captionOpacity: 0.8, // Universal caption opacity
			prevText: 'Prev', // Prev directionNav text
			nextText: 'Next', // Next directionNav text
			beforeChange: function(){}, // Triggers before a slide transition
			afterChange: function(){}, // Triggers after a slide transition
			slideshowEnd: function(){}, // Triggers after all slides have been shown
			lastSlide: function(){}, // Triggers when last slide is shown
			afterLoad: function(){} // Triggers when slider has loaded
		});
	}
});

// onload events
//addEvent(window, 'resize', fixLogo);
//addEvent(window, 'load', fixLogo);

// dynamic text tip replacements
$(document).ready(function(){
	
	// Info tips
	$("span.gettext_tip").each(function(){
   	var cont = $(this).html();
		var revl = $(this).attr('revealer');
   	$(this).qtip({
			content: {
				text: cont
			},
			position: {
				corner: {
					target: 'bottomRight',
					tooltip: 'bottomLeft'
				},
				adjust: {
					x: 10,
					y: 0
				}
			},
			style: {
				width: { min: 350 },
				tip: { size: { x: 350, y: 300 } },
				'background-color': '#ededed',
				border: { color: '#e2e2e2' }
			}
		});
		$(this).html((revl.length>0?revl:'[?]')).show();
	});
	
	// Order accessories, qtip
	$(".accessory_info_tip").each(function(){
		
		var artnr, prodName, prodInfo, cont, tipWidth;
		
		// Get information
		artnr    = $(this).attr('artnr');
		prodName = $(this).attr('alt');
		prodInfo = $(this).attr('title');
		
		tipWidth = 350;
		
		// Fill content
   	cont = '<div style="padding: 2px 0 5px 0;"><strong>' + prodName + '</strong></div>'
		     + '<div style="padding: 2px 0 0 0;">' 
		     + '<div '
			   + 'style="'
			   + 'border:1px solid #e2e2e2;width:120px;height:120px;float:left;margin:0 10px 2px 0;'
				+ 'background:#fff url(\'/gfx_content/products/' + artnr + 's.jpg\') no-repeat 50% 50%;'
				+ '"'
			  + '></div>'
			   + prodInfo
			  + '</div>';
							 
		// Remove "title" attribute (current tooltip)
		$(this).attr('title', '');
		
		// Apply tooltip
   	$(this).qtip({
			content: {
				text: cont
			},
			position: {
				corner: {
					target: 'topRight',
					tooltip: 'topLeft'
				},
				adjust: {
					x: 10,
					y: 0
				}
			},
			style: {
				width: (tipWidth + 30),
				tip: { size: { x: tipWidth, y: 220 } },
				'background-color': '#ededed',
				border: { color: '#e2e2e2' }
			}
		});
		
	});
	
});

function fixLay () {
	
   var objLeft, objRight;
	
   objLeft = elementById('left');
   objRight = elementById('right');
	
      objLeft.style.height = '';
   if (objRight.offsetHeight > objLeft.offsetHeight) {
      objLeft.style.height = objRight.offsetHeight + 'px';
   }
	
}

var strLoadingImage = '<img src="' + strPageRoot + 'gfx/load_bar1.gif" alt="Loading Bar" title="Loading..." class="loading" width="220" height="19" />';
var strLoadingImage2 = '<img src="' + strPageRoot + 'gfx/load_bar2.gif" alt="Loading Bar" title="Loading..." class="loading" width="220" height="19" />';

function writeRSS (feed, name) {
   elementById(name+'_Content').innerHTML = strLoadingImage + '<br /><div class="loadtext">Laadt '+name.capitalize2()+' feed...</div>';
   
   onSucces = function(){ elementById(name+'_Source').style.display='block'; }
   onFail = function(){ elementById(name+'_Content').innerHTML='Onze Excuses. '+name.capitalize2()+' feed momenteel niet beschikbaar...'; }
   SetInnerHTMLFromAjaxResponse(strPageRoot+'snippets/writeRSS.asp?nocache='+Math.random()+'&feed='+feed, name+'_Content', onSucces, onFail);
}

function doSearch (objForm) {
   
   var boolReturn = true;
	var strQ;
	var budget = $('#budgetSearch');
	var strBudget = '';
	
	var form = $('#topSearchForm').length > 0 ? $("#topSearchForm") : $(objForm);
	var qField = $(form).find("input[name='q']");
   
	if (qField.val().length > 1) {
		if (qField.val().match(/^\s*$/)) {
			boolReturn = false;
		} else {
			
			qField.val( qField.val().replace(/(^\s+|\s+$|%+)/g,'').replace(/(^-*|-*$)/g,'') );
			
			strQ = qField.val();
			strQ = strQ.replace(/\//g, '%2F').replace(/\\/g, '%5C');
			strQ = strQ.replace(/\?/g, '%3F').replace(/&/g, '%26');
			strQ = strQ.replace(/\s/g, '-');
			
			if (budget.length > 0) {
				strBudget = '?b=' + budget.val();
			}
			
			document.location.href = strWebRoot + (asXML_ln.length == 2 ? asXML_ln+'/' : '') + '' + strQ + strBudget;
			
		}
	} else {
		alert(getText.search_minimum);
	}
	
   //return boolReturn;
	return false;
   
}

function putInSearch (strTag) {
	elementById('searchField').value = strTag;
	elementById('searchField').select();
	return false;
}

function toggleBudgetSearch () {
	
	var budget = elementById('budgetSearch');

	if(budget.disabled == false) {
		elementById('elBudgetSearch_normal').style.display = 'block';
		elementById('elBudgetSearch').style.display = 'none';
		budget.disabled = true;
	} else {
		elementById('elBudgetSearch_normal').style.display = 'none';
		elementById('elBudgetSearch').style.display = 'block';
		budget.disabled = false;
		budget.select();
	}
	
}

function toggleComment (elem) {

   var intElemId, intHeight, objTargetElement;
   
   intElemId = parseInt(elem.getAttribute('rel'), 10);
   objTargetElement = elementById('comment_' + intElemId);
   intHeight = elementById('comm_content_' + intElemId).offsetHeight;
   
   if (objTargetElement.getAttribute('rel') != 'busy') {
   
      if (objTargetElement.className.match('open')) {
         objTargetElement.className = 'content';
         elem.className = 'clickBar';
         objTargetElement.style.height = 1 + 'px';
      } else {
         objTargetElement.className = 'content open';
         elem.className = 'clickBar open';
         objTargetElement.style.height = 1 + 'px';
         objTargetElement.setAttribute('rel', 'busy');
         easeResizeUp('comment_' + intElemId, intHeight);
      }
      
		//if (boolHomepage) resizeProductBar();
   
   }

}

function changeCommentPage (id, page, type, link_id) {
	
	var strLink;
	strLink = strPageRoot + 'snippets/writeWebComments.asp?nocache='+Math.random();
	strLink = strLink + '&page='+page+'&type='+type+'&link_id='+link_id+'&commnr='+id;

   var elem = elementById('comm_page_'+id);
	elem.style.height = elem.offsetHeight + 'px';
	elem.style.float = 'left';

	SetInnerHTMLFromAjaxResponse(strLink, 'comm_page_'+id);

   //return false;
}

function easeResizeUp (elemId, intHeight) {
   
   var intDiff, intElemHeight, elem;
   elem = elementById(elemId);
   
   intElemHeight = parseInt(elem.style.height, 10);
   intDiff = parseInt(intHeight, 10) - intElemHeight;
   
   elem.style.height = intElemHeight + Math.ceil(intDiff/3) + 'px';
   
   //if (boolHomepage) resizeProductBar();
	fixLay();
   
   if (parseInt(elem.style.height, 10) < intHeight) {
      setTimeout("easeResizeUp('"+elemId+"', "+intHeight+")", 50);
   } else {
      elem.setAttribute('rel', 'done');
   }
   
}

function commentSuccess (obj) {

   obj.style.display = 'none';
   obj.nextSibling.innerHTML += "<div style=\"margin:5px;font-style:italic;\">Bedankt voor het plaatsen van je reactie!<br/>Het bericht zal eerst worden gecontroleerd door de beheerder.</div>";

}

function checkComment (obj) {
   
   var v1, v2;
   v1 = obj[2].value.length;
   v2 = obj[3].value.length;

   if (v1<2 && v2<2) {
      alert("De velden 'Bericht' en 'Naam' moeten minimaal 2 karakters bevatten.");
      return false;
   } else if (v1<2) {
      alert("Het 'Bericht' veld moet minimaal 2 karakters bevatten.");
      return false;
   } else if (v2<2 || v2>40) {
      alert("Het 'Naam' veld moet minimaal 2 en maximaal 40 karakters bevatten.");
      return false;
   } else if (v1>250) {
      alert("Het 'Bericht' mag het limiet van 250 karakters niet overschrijden.");
      return false;
   }
   
   return true;
   
}


function gotoPage (strUrl) {
	var strLink = String(strUrl).replace("&apos;", "'").replace("&amp;", "&").replace("\"", "%22");
   document.location.href = strPageRoot + strLink;
}

function addToNewsletter (obj) {
 var r = false;
	try {
		ajaxPostForm(strPageRoot + 'snippets/addToNewsletter.asp', obj);
	} catch (e) {
		r = true;
	}
	
	return r;
}

function sendContactForm (obj)
{
	var form = $(obj);
	var telno = form.find("input[name='telnr']");
	var message = form.find("textarea[name='bericht']");
	var name = form.find("input[name='naam']");
	var email = form.find("input[name='email']");
	var cat = form.find("select[name='cat'],input[name='cat']");
	var submitButton = form.find("input[type='submit']");
	
	formButton(submitButton, false);
	
	if (telno.val().length > 0)
	{
		telno.val(telno.val().replace(/\s\s+/g, " ").replace(/\-\-+/g, "-").replace(/(^\D*|\D*$)/g, ""));
		if (!telno.val().match(/^(\-|\d|\s)+$/))
		{
		   alert(getText.cont_failtel);
			formButton(submitButton, true);
			return false;
		}
		else if (!telno.val().replace(/\D/g, "").match(/^\d{10}\d*$/))
		{
		   alert(getText.cont_teldigits);
			formButton(submitButton, true);
			return false;
		}
	}
	
	if (name.val().length > 0 && email.val().length > 0 && message.val().length > 0 && cat.val() != '-1') {
		
		$.ajax({ 
			url: strPageRoot + 'snippets/sendMail.asp', 
			type: 'POST', 
			data: $(obj).serialize(),
			success: function(data, textStatus) { 
				alert(data);
				formButton(submitButton, true);
			} 
		});
		
	} else {
		
		alert(getText.cont_required);
		formButton(submitButton, true);
		
	}

}

function sendToFriend (obj) {
	
	formButton(obj[6]);
	
	if (!obj[5].checked) {
		obj[5].disabled = true;
	} else {
		obj[5].disabled = false;
	}
	
	if (obj[2].value!="" && obj[3].value!="") {
		
		ajaxPostForm(strPageRoot + 'snippets/sendToFriend.asp', obj, function(){ formButton(obj[6],true); obj[5].disabled = false; });
		
	} else {
		
		alert(getText.s2f_reqemails);
		formButton(obj[6],true);
		
	}
		
}

function formButton (button, enable) {
	$(button).attr('disabled', !enable);
	if (enable)
		$(button).val(getText.cont_butsend);
	else
		$(button).val(getText.cont_sending);
}

function resetContactCaptcha() {
	var strCaptUrl, objCapt;
	
	objCapt = elementById('contactcapt');
		
		objCapt.style.visibility='hidden';
		strCaptUrl = objCapt.src;
		
		objCapt.src='';
		
		objCapt.onload = function(){ objCapt.style.visibility='visible'; }
		objCapt.src = strCaptUrl+ '#' + (new Date()).getTime();;
		
		objCapt.nextSibling.value='';
	
}

function toggleProductVideo () {
   var elem = elementById('productVideo');
	
	if (elem.style.display != "block") {
	   elem.style.display = 'block';
	} else {
	   elem.style.display = 'none';
	}
	
	return false;
}

function commentSuccess (obj) {

   obj.style.display = 'none';
   obj.nextSibling.innerHTML += "<div style=\"margin:5px;font-style:italic;\">Bedankt voor het plaatsen van je reactie!<br/>Het bericht zal eerst worden gecontroleerd door de beheerder.</div>";

}

var timerOver, timerOut, timerInterval, mouseOut;
timerOver = new Map();
timerOut = new Map();
mouseOut = true;

function listMouseover (id, artnr) {
   objElem = elementById('listinfo_'+id);
	mouseOut = false;
		
	timerOver.id = id;
	clearTimeout(timerOut.t);
		
   if (timerOut.id != id) {
		
		clearTimeout(timerOver.t);
		if (timerOut.id) elementById('listinfo_'+timerOut.id).style.display = 'none';

		timerOver.id = id;
		timerOver.t  = setTimeout(function(){
			if (!mouseOut) listDisplay(id, artnr);
		   timerOut.id = null;
		}, 500);
		
	}
	

}

function listMouseout (id) {
   objElem = elementById('listinfo_'+id);
	mouseOut = true;
	clearTimeout(timerOver.t);

   if (timerOver.id != id) {
		
		timerOut.id = null;
		clearInterval(timerInterval);
		
	} else {
		
		timerOut.id = id;
		clearInterval(timerInterval);
		timerOut.t  = setTimeout(function(){
		   clearInterval(timerInterval);
			objElem.style.display = 'none';
			timerOut.id  = null;
		}, 1000);
		
	}

}

function listDisplay (id, artnr) {
   objElem = elementById('listinfo_'+id);
	var strInnerHTML = '';
	
	objElem.style.display = 'block';
   objElem.innerHTML = '<div class="laadt">Laadt productinfo.</div>';
	
	timerInterval = setInterval(function(){
		strInnerHTML = objElem.firstChild.innerHTML.replace(/\.{3}$/, '');
	   objElem.firstChild.innerHTML = strInnerHTML + '.';
	}, 200);
   
	setTimeout(function(){
		clearInterval(timerInterval);
      SetInnerHTMLFromAjaxResponse(strPageRoot+'snippets/prodinfo.asp?artnr='+artnr, 'listinfo_'+id);
	}, 900);

}

function checkFormValues (form) {
 var boolReturn = true;
 var eltype = "";
 var i;

   var els = form.getElementsByTagName('input');
	var els2 = form.getElementsByTagName('textarea');
	
	for (i=0; i < els2.length; i++) {
		if (typeof(els2[i].innerText) != "undefined") {
			els2[i].innerText = els2[i].innerText.replace(/(^\s+|\s+$)/g, '');
		} else {
			els2[i].textContent = els2[i].textContent.replace(/(^\s+|\s+$)/g, '');
		}
	}
	for (i=0; i < els.length; i++) {
		els[i].value = els[i].value.replace(/\s\s+/g, ' ').replace(/(^\s+|\s+$)/g, '');
		if (els[i].getAttribute('capitalize')=='true') els[i].value = els[i].value.capitalize2();
	}
	
   for (i=0; i < els.length; i++) {
		
      eltype    = String(els[i].getAttribute('checkValue'));
      eltypeFix = String(els[i].getAttribute('checkValue')).replace('confirm_', '');
			
		if (eltype.length > 0 && eltype!="undefined" && eltype!=null && eltype!="null" && !els[i].disabled) {
			
			if (eltype.match(/^confirm/)) {
				eltype = "confirm";
			}
			
			switch (eltype) {
			
			   case "number":
				   if (!els[i].value.match(/^\d{4,9}$/)) {
						boolReturn = false;
					} // if
				break;
			   case "float":
				   if (!els[i].value.match(/^\d+((,|\.)\d{2})?$/)) {
						boolReturn = false;
					} // if
				break;
			   case "empty":
				   if (els[i].value == "") {
						boolReturn = false;
					} // if
				break;
			   case "telno":
				   if (!els[i].value.match(/^(\-|\d|\s|\+)+$/)) {
						boolReturn = false;
					} // if
				break;
			   case "zipcode":
				   if (!els[i].value.match(/.{3}/)) {
						boolReturn = false;
					} // if
				break;
			   case "confirm":
				   if (els[i].value != elementById(eltypeFix).value || els[i].value == "") {
						boolReturn = false;
					} // if
				break;
			   case "email":
				   if (!els[i].value.match(/^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.(\w)+)|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/i)) {
						boolReturn = false;
					} // if
				break;
			
			} // switch (eltype)
			
			els[i].className = els[i].className.replace(' fielderror', '');
			if (!boolReturn) {
				els[i].className += ' fielderror';
			}
			
			if (els[i].parentNode.tagName.toLowerCase() == "label") {
				els[i].parentNode.className = els[i].parentNode.className.replace(' labelerror', '');
				if (!boolReturn) {
					els[i].parentNode.className += ' labelerror';
				}
			}
			
		} // if (eltype!="")
		
   } // for (var i=0; i < els.length; i++) 
	
 if (!boolReturn) {
	 var errTxt = (errorText!='' ? errorText : getText.form_fail);
	 alert(errTxt);
	 
	 for (var i=0; i < els.length; i++) {
		 if (els[i].className.match('fielderror')) {
			 $('html, body').animate({scrollTop: $(els[i]).offset().top - 30}, 600);
			 els[i].select();
		    break;
		 }
	 }
 }
 
 return boolReturn;
}

function rotateTips (intTimer) {
	if (typeof(intTimer)=="undefined") var intTimer = 10;
	var doRotate = function () {
		/*new Effect.Opacity('tipTotal', { from: 1, to: 0, duration: 0.2 });
		setTimeout(function(){
			SetInnerHTMLFromAjaxResponse(strPageRoot+'snippets/getTip.asp?nc='+Math.random(), 'tipTotal', function(){
				new Effect.Opacity('tipTotal', { from: 0, to: 1, duration: 0.5 });
			});
		}, 200);*/
		SetInnerHTMLFromAjaxResponse(strPageRoot+'snippets/getTip.asp?nc='+Math.random(), 'tipTotal');
	}
	setInterval(doRotate, intTimer*1000);
}

function addToCart (artnr, onSucces) {
	if (typeof(onSucces)=="undefined") var onSucces = function(){};
	SetInnerHTMLFromAjaxResponse(strPageRoot+'snippets/addToCart.asp?nocache='+Math.random()+'&artnr='+artnr, 'cartIt', onSucces);
}

function changeNumCart (artnr, num, onSucces) {
	if (typeof(onSucces)=="undefined") var onSucces = function(){};
	SetInnerHTMLFromAjaxResponse(strPageRoot+'snippets/changeNumCart.asp?nocache='+Math.random()+'&artnr='+artnr+'&num='+num, 'cartIt', onSucces);
}

function remFromCart (artnr, onSucces) {
	if (typeof(onSucces)=="undefined") var onSucces = function(){};
	SetInnerHTMLFromAjaxResponse(strPageRoot+'snippets/remFromCart.asp?nocache='+Math.random()+'&artnr='+artnr, 'cartIt', onSucces);
}

function swapImage (objSub) {

	var objMain, strMain, strSub;
	objMain = elementById('detailMainImage');
	objRealMain = elementById('realMainImage');
	
	objMain.style.visibility = 'hidden';
	objSub.style.visibility = 'hidden';
	
	strMain = objMain.getAttribute('rel');
	strSub  = objSub.getAttribute('rel');
	
	objMain.onload = function() {
		repositionImage();
	};
	objSub.onload = function() {
		objSub.style.marginTop = 0 + ((120 - objSub.offsetHeight) / 2);
		objSub.style.visibility = 'visible';
	};
	
	objMain.src  = strPageRoot + 'gfx_content/products/' + strSub + '.jpg';
	objSub.src  = strPageRoot + 'gfx_content/products/' + strMain + 's.jpg';
	objRealMain.style.backgroundImage = 'url(' + strPageRoot + 'gfx_content/products/' + strSub + '.jpg)';
	
	objMain.setAttribute('rel', strSub);
	objSub.setAttribute('rel', strMain);
	
	//repositionImage();

}

function changeBunSelect (bun_id, bun_grp, bun_artnr) {
	
		$.ajax({
			url: strPageRoot+'snippets/getBundleChange.asp?x=1&b_artnr=' + bun_artnr + '&b_id=' + bun_id + '&b_grp=' + bun_grp + '&nc=' + Math.random(),
			cache: false,
			success: function(html){
				$('.bundle_change_window').html(html);
			}
		});
}

function changeBunItem (bun_id, bun_grp, bun_wintitle, bun_num) {
	 
	 // Calc the window dimensions.
	 var num_width, d_width, d_height, i_width, i_height, t_height
	 num_width = 4;
	 bun_num  = parseInt(bun_num, 10);
	 i_height = Math.ceil(bun_num / num_width);
	 i_width  = (bun_num > num_width-1 ? num_width : num_width-1);
	 t_height = (i_width == num_width ? 50 : 63);
	 d_width  = (i_width * 135) + 15;
	 d_height = (t_height + (i_height * 185)) + 10;
	 
	Shadowbox.open({
		content:    '<div id="bundle_change_window" class="bundle_change_window"></div>',
		player:     "html",
		title:      '',
		width:      d_width,
		height:     d_height,
		options:    { 
			onFinish:   function(){
				$.ajax({
					url: strPageRoot + 'snippets/getBundleChange.asp',
					cache: false,
					data: 'x=1&b_id=' + bun_id + '&b_grp=' + bun_grp,
					success: function(html){
						$('#bundle_change_window')
						.empty().append(html)
						.css('background-image', 'none')
						.css('background-color', '#fff');
					}
				});
			}
		}
	});
	
}

function openProductReviews (artnr)
{
	Shadowbox.open({
		content:    '<div id="product_reviews_content" class="sb_html_loader"></div>',
		player:     "html",
		title:      '',
		width:      600,
		height:     450,
		options:    { 
			onFinish:   function(){
				
				$.ajax({
					url: strPageRoot + 'snippets/getProdReviews.asp',
					cache: false,
					data: 'artnr=' + artnr,
					success: function(html){
						$('#product_reviews_content')
						.empty().append(html)
						.css('background-image', 'none')
						.css('background-color', '#fff');
					}
				});
				
			}
		}
	});
	return false;
}

var asXML, asXML_ln='';
try {
	asXML_ln = strPageRoot.split('/').reverse()[1];
} catch(e) {}
if (asXML_ln.length == 2) {
	asXML = strPageRoot + 'xml/zoek.' + asXML_ln + '.xml';
} else {
	asXML = strPageRoot + 'xml/zoek.xml';
}

function attachTwitter (elemText, elemDate, user) {
	try {
		if (typeof(user)=="undefined") var user = "rockpalace1985";
		$.getJSON("http://twitter.com/statuses/user_timeline/" + user + ".json?callback=?",{count:"1"},function(twitter){
			 $('.twitterBox a').fadeIn('fast');
			with (twitter[0]) {
				$(elemText).html(text).fadeIn('fast');
				$(elemDate).html(created_at.formatDate(4)).fadeIn('fast');
			}
		});
	}catch(e){}
};

var initAutosuggest = function () {
	
	var form;
	if ( $('#topSearchForm').length > 0 )
		form = $("#topSearchForm");
	else if ( $('#rpSearchForm').length > 0 )
		form = $("#rpSearchForm");
	else
		return false;
	
	var as_options = {
		callback:		function(){ doSearch(form); },
		script:			asXML + '?',
		varname:			'q',
		cache:			false,
		shownoresults:	false,
		extendtoleft:	true,
		fixwidth:		200,
		delay:			300,
		minchars:		2,
		timeout:			7500
	};
	var as = new bsn.AutoSuggest( form.find("input[name='q']").attr('id') , as_options);
}

function overClass (obj) {
	/* Only IE<=6; It doesn't allow div:hover in css */
}
function outClass (obj) {
	/* Only IE<=6; It doesn't allow div:hover in css */
}
