/* browser version */
var bIE = false;
var bVer = 0;
if(navigator.appVersion.indexOf("MSIE")!=-1){
	bIE = true;
	temp=navigator.appVersion.split("MSIE");
	bVer=parseFloat(temp[1]);
}

function bookmark(){
  var url = window.location.href;
  var title = document.title;
  if (bIE){
  	window.external.AddFavorite(url,title);
  } 
  else if (navigator.appName == "Netscape"){
    window.sidebar.addPanel(title,url,"");
  } 
  else{
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
  
  return true;
}
function switchCountry(ccode,lang){
	try{
		var f = document.switchCountryFrm;
		f.new_country.value = ccode;
		f.new_language.value = lang;
		f.submit(); 
		return false;
	}
	catch(e){
		return true;
	}
}

/** print page **/
function PrintPage(url){
	var param = "menubar=yes,copyhistory=no,resizable=yes,scrollbars=yes,width=830,height=600";
	var w = window.open(url,"print",param);
	w.focus();
	return false;
}

function clearHtmlElement(obj)
{
	if(obj == null)
	{
		return;
	}
	var tmp = null;
	do{
		tmp = obj.firstChild;
		if(tmp != null)
		{
			obj.removeChild(tmp);
		}
	}while(tmp != null);
}
/** the borders need be set dynamically **/
function setSmallBox(oBox,v,t,b,l,r){
	if(typeof(oBox) == "string"){
    	oBox = document.getElementById(oBox);
    }
    if(oBox == null){
    	return;
    }
	var e = getElementByClassName(oBox,'div','t')[0];
	if(typeof(e) != 'undefined'){
		if(typeof(t) == 'undefined'){
			t = (v == 1) ? 26 : 32;
		}
		e.style.width = (oBox.offsetWidth-t)+'px';
	}
	var e = getElementByClassName(oBox,'div','b')[0];
	if(typeof(e) != 'undefined'){
		if(typeof(b) == 'undefined'){
			b = (v == 1) ? 26 : 32;
		}
		e.style.width = (oBox.offsetWidth-b)+'px';
	}
	var e = getElementByClassName(oBox,'div','l')[0];
	if(typeof(e) != 'undefined'){
		if(typeof(l) == 'undefined'){
			l = (v == 1) ? 28 : 32;
		}
		e.style.height = (oBox.offsetHeight-l)+'px';
	}
	var e = getElementByClassName(oBox,'div','r')[0];
	if(typeof(e) != 'undefined'){
		if(typeof(r) == 'undefined'){
			r = (v == 1) ? 28 : 32;
		}
		e.style.height = (oBox.offsetHeight-r)+'px';
	}
}
var _popupStyle = null;
function showMsgPopup(X,Y,msg,s){
	if(typeof _bodyLoaded == 'undefined' || !_bodyLoaded){
		return;
	}
	removeMsg();
	
	var popup = document.getElementById('popup');
	if(popup == null){
		return;
	}
	
	var content = getElementByClassName(popup,'div','ppcontent')[0];
	content.innerHTML = msg;
	if(s['container']['width'] == 'fit'){
		var testSpan = document.createElement('span');
		testSpan.innerHTML = msg;
		document.body.appendChild(testSpan);
		s['container']['width'] = testSpan.offsetWidth+46;
		document.body.removeChild(testSpan);  
	}
	popup.style.width = s['container']['width']+'px';
	if(typeof s['p']['text-align'] != 'undefined'){
		content.style.textAlign = s['p']['text-align'];
	}
	else{
		content.style.textAlign = 'left';
	}
	if(typeof s['p']['font-weight'] != 'undefined'){
		content.style.fontWeight = s['p']['font-weight'];
	}
	else{
		content.style.fontWeight = 'normal';
	}
	popup.style.display = 'block';
	setSmallBox(popup,1);
	setPopupStyle(popup,'BL',X,Y);
	var style = checkPopup(popup,X,Y);
	setPopupStyle(popup,style,X,Y);
}
function setPopupStyle(popup,style,X,Y){
	if(style != _popupStyle){
		document.getElementById('pp_arrow').className = 'arrow_'+style.toLowerCase();
		_popupStyle = style;
	}

	if(_popupStyle == 'BL'){
		var h = popup.offsetHeight;
		popup.style.left = (X-27)+'px';
		popup.style.top = (Y-h-20)+'px';
	}
	else if(_popupStyle == 'BR'){
		var h = popup.offsetHeight;
		var w = popup.offsetWidth;
		popup.style.left = (X-w+27)+'px';
		popup.style.top = (Y-h-20)+'px';
	}
	else if(_popupStyle == 'TL'){
		var h = popup.offsetHeight;
		popup.style.left = (X-27)+'px';
		popup.style.top = (Y+30)+'px';
	}
	else if(_popupStyle == 'TR'){
		var h = popup.offsetHeight;
		var w = popup.offsetWidth;
		popup.style.left = (X-w+27)+'px';
		popup.style.top = (Y+30)+'px';
	}
}

function checkPopup(popup,X,Y){
	var arPageSize = getPageSize();
	var arScrollPostion = getPageScroll();
	var _popupWindowWidth = arPageSize[2];
	var _popupWindowHeight = arPageSize[3];
	var w = popup.offsetWidth;
	var h = popup.offsetHeight;
	var x1 = _popupWindowWidth - (X+w);
	var x2 = X-w;
	var styleX = '';
	if(x1 < 0 && x2 > 0){
		styleX = 'R';
	}
	else{
		styleX = 'L';
	}
	var y1 = Y - h - arScrollPostion[1] - 20;
	var y2 = (_popupWindowHeight + arScrollPostion[1])- (Y + h);
	var styleY = '';
	if(y1 < 0 && y2 > 0){
		styleY = 'T';
	}
	else{
		styleY = 'B';
	}
	var ret = styleY+styleX;
	return ret;
}

function moveMsg(evt,sender){
	if(typeof _bodyLoaded == 'undefined' || !_bodyLoaded){
		return;
	}
	var d = document.getElementById('popup');
	if(d != null){
		if(d.style.display != 'block'){
			return;
		}
		sender.style.cursor = 'pointer';
		var X = mouseX(evt);
		var Y = mouseY(evt);
		var style = checkPopup(d,X,Y);
		setPopupStyle(d,style,X,Y);
	}
}


function removeMsg(){
	setStyle('popup','display','none');
	setStyle('ifrpopup','display','none');
}
function pricePopup(msg,evt)
{
	removeMsg();
	var s = new Object();
	s['container'] = new Object();
	s['container']['width'] = '100';
	s['p'] = new Object();
	s['p']['text-align'] = 'center';
	s['p']['font-weight'] = 'bold';
	var X = mouseX(evt);
	var Y = mouseY(evt);
	showMsgPopup(X,Y,msg,s);
}
function countryPopup(evt){
	cancelEvent(evt);
	if(typeof _alaCountries == 'undefined'){
		return;
	}
	var msg = '<div class="country_box">';
	msg += '<div style="float:left">'; 
	for(i = 0 ; i < _alaCountries.length ; i++){
		msg += '<a href="'+_alaCountries[i][0]+'" title="'+_alaCountries[i][1]+'">'+_alaCountries[i][1]+'</a>';
	}
	msg += '</div><div class="box_close" onclick="removeMsg();"></div><div class="line-sep"></div>';
	msg += '</div>';
	
	var s = new Object();
	s['container'] = new Object();
	s['container']['width'] = '150';
	s['p'] = new Object();
	s['p']['text-align'] = 'left';
	s['p']['font-weight'] = 'normal';
	var X = mouseX(evt);
	var Y = mouseY(evt);
	showMsgPopup(X,Y,msg,s);
}
function bookmarkPopup(evt){
	cancelEvent(evt);
	if(typeof _bookmarks == 'undefined'){
		return;
	}
	var curUrlEncoded = encodeURIComponent(window.location.href);
	var curTitleEncoded = encodeURIComponent(document.title);
	var onclickStr = '';
	var url = '';
	var msg = '<div class="bookmark_box">';
	msg += '<div style="float:left">'+_langAddTo+'</div><div class="box_close" onclick="removeMsg();"></div><div class="line-sep" style="height:10px"></div>';
	for(i = 0 ; i < _bookmarks.length ; i++){
		if(i == 0){
			onclickStr = "bookmark();"
		}
		else{
			url = _bookmarks[i][4].replace(/{url}/gi,curUrlEncoded);
			url = url.replace(/{title}/gi,curTitleEncoded); 
			onclickStr =  "window.open('"+url+"','bookmark','location=1,menubar=1,status=1,scrollbars=1,resizable=1,width=800,height=600');";
		}
		msg += '<a href="#" onclick="'+onclickStr+'removeMsg();return false;"><img src="'+_bookmarks[i][0]+'" width="'+_bookmarks[i][1]+'" height="'+_bookmarks[i][2]+'" alt="'+_bookmarks[i][3]+'">&nbsp;&nbsp;&nbsp;&nbsp;'+_bookmarks[i][3]+'</a>';
	}
	msg += '</div>';
	var s = new Object();
	s['container'] = new Object();
	s['container']['width'] = '160';
	s['p'] = new Object();
	s['p']['text-align'] = 'left';
	s['p']['font-weight'] = 'normal';
	var X = mouseX(evt);
	var Y = mouseY(evt);
	showMsgPopup(X,Y,msg,s);
}
function smallMsgPopup(msg,evt)
{
	removeMsg();
	var s = new Object();
	s['container'] = new Object();
	s['container']['width'] = 'fit';
	s['p'] = new Object();
	s['p']['text-align'] = 'left';
	var X = mouseX(evt);
	var Y = mouseY(evt);
	showMsgPopup(X,Y,msg,s);
}
function msgPopup(msg,evt){
	removeMsg();
	var s = new Object();
	s['container'] = new Object();
	s['container']['width'] = '220';
	s['p'] = new Object();
	s['p']['text-align'] = 'left';
	s['p']['font-weight'] = 'normal';
	var X = mouseX(evt);
	var Y = mouseY(evt);
	showMsgPopup(X,Y,msg,s);
}
var _alaExplain = new Object();
var _waitAlaScoreTimer = null;
var _curX = 0;
var _curY = 0;
var _curAlid = null;
function hideAlaSCORE(obj,evt){
	if(isOnMouseOut(obj,evt)){
		if(_waitAlaScoreTimer != null){
			window.clearTimeout(_waitAlaScoreTimer);
			_waitAlaScoreTimer = null;
		}
		_curAlid = null;
		removeMsg();
	}
}
function showAlaSCORE(alid,evt){
	if(alid == _curAlid){
		return;
	}
	removeMsg();
	_curAlid = alid;
	_curX = mouseX(evt);
	_curY = mouseY(evt);
	if(_waitAlaScoreTimer != null){
		window.clearTimeout(_waitAlaScoreTimer);
		_waitAlaScoreTimer = null;
	}
	_waitAlaScoreTimer = window.setTimeout('doShowAlaSCORE("'+alid+'")',400);
}
function doShowAlaSCORE(alid){
	if(_waitAlaScoreTimer != null){
		window.clearTimeout(_waitAlaScoreTimer);
		_waitAlaScoreTimer = null;
	}
	if(typeof _alaExplain['ep_'+alid] == 'undefined'){
		_AO.Abort();
		_AO.OnComplete = getAlaSCORE;
		getRequest(_ServerBase+'/xml_index.php?page=_xml_get_alascore_explain&al_id='+alid,null);	
	}
	else{
		showAlaScorePopup(alid);
	}
}
function showAlaScorePopup(alid){
	if(typeof _alaExplain['ep_'+alid] == 'undefined'){
		return;	
	}
	if(_curX == 0 || _curY == 0){
		return;
	}
	var s = new Object();
	s['container'] = new Object();
	s['container']['width'] = '300';
	s['p'] = new Object();
	s['p']['text-align'] = 'left';
	s['p']['font-weight'] = 'normal';
	//showMsgPopup(_curX,_curY,'aa',s);
	showMsgPopup(_curX,_curY,_alaExplain['ep_'+alid],s);
}
function getAlaSCORE(xmlRoot){
	var alid = getFirstValue(xmlRoot,"alid");
 	var msg = getFirstValue(xmlRoot,"message");
 	if(alid.length > 0){ 
 		_alaExplain['ep_'+alid] = msg;
 	}
 	if(_curAlid == alid){
	 	showAlaScorePopup(alid);
 	}
}

function showHeaderSL(){
	try{
		var e = document.getElementById('header_sl');
		if(e == null)return;
		e.style.display = 'block';
		setSmallBox(e,1);
		document.getElementById('award').style.display = 'none';
	}
	catch(e){
	}
}
function hideHeaderSL(evt){
	var e = document.getElementById('header_sl');
	if(e == null)return;
	e.style.display = 'none';
	document.getElementById('award').style.display = 'block';
}
function showAds(bShow){
	var e = document.getElementById('b_leaderboard1');
	if(e != null){
		if(bShow){
			e.style.visibility = 'visible';
		}
		else{
			e.style.visibility = 'hidden';
		}
	}
}
var _FLAGSSHOWED = false;
function showFlags(element,evt){
	if(element != getEventTarget(evt)){
		return;
	}
	cancelEvent(evt);
	try{
		var e = document.getElementById('header_cl');
		if(_FLAGSSHOWED){
			e.style.display = 'none';
			showAds(true);
			_FLAGSSHOWED = false;
		}
		else{
			e.style.display = 'block';
			setSmallBox(e,1);
			showAds(false);
			_FLAGSSHOWED = true;
		}
	}
	catch(e){
	}
}
document.onclick = hideFlags;
function hideFlags(){
	if(_FLAGSSHOWED){
		document.getElementById('header_cl').style.display = 'none';
		showAds(true);
		_FLAGSSHOWED = false;
	}
}
/* show message with javascript */
function showErrMsg(msg)
{
	hideErrMsg();
	if(msg == null || '' == msg){
		return false;
	}
	var arPageSize = getPageSize();
	var arScrollPostion = getPageScroll();
	var e = CreateDiv('newbox','<div class="con"><div class="t"></div><div class="r"></div><div class="b"></div><div class="l"></div><div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div><div class="msg_con"><div id="msg"></div><div onclick="hideErrMsg()" class="box_close"></div><div class="line-sep"></div></div></div>');
	e.setAttribute('id','msg_box');
	
	e.style.zIndex = "450";
	document.body.appendChild(e);
	var e1 = document.getElementById('msg');
	e1.innerHTML = msg;
	e.style.display = 'block';
	setSmallBox(e,1);
	e.style.left = Math.round((arPageSize[0] - e.offsetWidth)/2)+'px';
	if (!(bIE && bVer <= 6)){
		e.style.position = 'fixed';
		e.style.top = (Math.round((arPageSize[3] - e.offsetHeight)/2)) +'px';
	}
	else{
		e.style.position = 'absolute';
		e.style.top = (Math.round((arPageSize[3] - e.offsetHeight)/2)+arScrollPostion[1]) +'px';
	}
	
	var arPageSize = getPageSize();
	var objOverlay = document.getElementById('overlay');
	objOverlay.style.top = '0px';
	objOverlay.style.left = '0px';
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';
	objOverlay.onclick=hideErrMsg;
	showAds(false);
	if(bIE && bVer <= 6){
		selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }
	}
	
	return true;
}
function hideErrMsg(){
	var e = document.getElementById('msg_box');
	if(e != null){
		document.body.removeChild(e);
	}
	var objOverlay = document.getElementById('overlay');
	objOverlay.style.display = 'none';
	showAds(true);
	if(bIE && bVer <= 6){
		selects = document.getElementsByTagName("select");
	    for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "visible";
		}
	}
}

function getCellByClassName(fObj,cname)
{
	try{
		var rows = fObj.getElementsByTagName("tr");
		for(var i = 0 ; i < rows.length ; i++)
		{
			var cells = rows[i].getElementsByTagName("td");
			for(var j = 0 ; j < rows.length ; j++)
			{
				if(cells[j].className == cname)
				{
					return cells[j];
				}
			}
		}
		return null;
	}
	catch(ex){
		return null;
	}
}
function TCEMouseup(element){
	if(typeof(element['clickdown']) != 'undefined' || element['clickdown']){
		if(typeof(element['old_class']) != 'undefined'){
			element.className = element['old_class'];
		}
		element['clickdown'] = false;
	}
}
function TCEMousedown(element,cn){
	element['old_class'] = element.className;
	element['clickdown'] = true; 
	element.className = cn;
}
var cattabTimeOut = new Object();

function showAllCatTab(id){
	var e = document.getElementById('dd_'+id);
	var els = getElementByClassName(e,'ul','less');
	if(els.length > 0){
		els[0].className = 'more';
	}
	setSmallBox(e,1,26,26,14,14);
}
function showCatTab(id,bShow)
{
	if(typeof cattabTimeOut[id] != 'undefined')
	{
		window.clearTimeout(cattabTimeOut[id]);
		
		delete cattabTimeOut[id];
	}
	
	if(bShow == 'y')
	{
		cattabTimeOut[id] = window.setTimeout("doShowCatTab('"+id+"','"+bShow+"')",100);
	}
	else
	{
		cattabTimeOut[id] = window.setTimeout("doShowCatTab('"+id+"','"+bShow+"')",50);
	}
}
function doShowCatTab(id,bShow)
{
	if(id != 'all')
	{
		if(bShow == 'y')
		{
			setStyle('dd_'+id,'display','block');
			setSmallBox('dd_'+id,1,26,26,14,14);
			showAdsForCatTab(false);		
		}
		else
		{
			setStyle('dd_'+id,'display','none');
			var e = document.getElementById('dd_'+id);
			var els = getElementByClassName(e,'ul','more');
			if(els.length > 0){
				els[0].className = 'less';
			}
			showAdsForCatTab(true);		
		}
	}
}
_timerShowAdsForCatTab = null;
function showAdsForCatTab(bShow){
	if(_timerShowAdsForCatTab != null){
		window.clearTimeout(_timerShowAdsForCatTab);
	}
	_timerShowAdsForCatTab = window.setTimeout('showAds('+bShow+')',200);
}
_bCleanText = true;

function kwOnClick(obj,bCleanText)
{
	if(bCleanText && _bCleanText)
	{
		obj.value = '';
	}
	
	setStyle1(obj,'color','#444444');
	
	_bCleanText = false;
}

function searchSubmit(event,bCleanText,warning)
{
	cancelEvent(event);
	//cancel super search
	if(typeof(_ssTimer) != 'undefined'){
		ssShowHide(false);
		if(_ssTimer != null){
			clearTimeout(_ssTimer);
			_ssTimer = null;
		}
	}
	if(bCleanText && _bCleanText)
	{
		showErrMsg(warning);
		document.search.keyword1.value = '';
		setStyle1(document.search.keyword1,'color','#444444');
		document.search.keyword1.focus();
	}
	else
	{
		if (document.search.keyword1.value.length == 0)
		{
			showErrMsg(warning);
			document.search.keyword1.focus();
		}
		else
		{
			document.search.submit();
		}
	}
}
/* style functions */
function setStyle(objId, style, value) {
	if(!document.getElementById) return;
    var el = document.getElementById(objId);
    if(el != null)el.style[toCamelCase(style)] = value;
}

function setStyle1(obj , style , value){
	if(obj != null)obj.style[toCamelCase(style)] = value;
}

function getStyle(objId, style) {
   if(!document.getElementById) return null;  
   var el = document.getElementById(objId);
   return getStyle1(el, style);
}

function getStyle1(el, style) {
   if(el == null)return null;
    var value = el.style[toCamelCase(style)];
    if(!value)
        if(document.defaultView)
            value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
        else if(el.currentStyle)
            value = el.currentStyle[toCamelCase(style)]; 
     return value;
}

function toCamelCase( sInput ) {
    var oStringList = sInput.split('-');
    if(oStringList.length == 1)   
        return oStringList[0];
    var ret = sInput.indexOf("-") == 0 ?
       oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
    for(var i = 1, len = oStringList.length; i < len; i++){
        var s = oStringList[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1)
    }
    return ret;
} 
var RVPLoadAds = new AjaxObject();
RVPLoadAds.OnComplete = rvpHandle;
function rvpShowAlt(eventObj){
	eventObj = eventObj ? eventObj : window.event;
	smallMsgPopup(this.title,eventObj);
	
}
function rvpMoveAlt(eventObj){
	eventObj = eventObj ? eventObj : window.event;
	moveMsg(eventObj,this);
	
}
function rvpRemoveAlt(){
	removeMsg();
}
function rvpHandle(xmlRoot){
	var e = document.getElementById('rvp');
	if(e != null){
		clearHtmlElement(e);
		
		var title = document.createElement('h3');
		title.innerHTML = _langRVPTitle;
		e.appendChild(title);
		var divC = CreateDiv('c',null);
		e.appendChild(divC);
		var divPC = CreateDiv('page_con bbpage',null);
		divPC.setAttribute('id','rvpCon');
		divC.appendChild(divPC);
		var pGalleryOut = CreateDiv('page_con wpage',null);
		divPC.appendChild(pGalleryOut);
		var pGallery = CreateDiv('p_gallery',null);
		pGalleryOut.appendChild(pGallery);
		var head = CreateDiv('head',null);
		pGallery.appendChild(head);
		var sep = CreateDiv('sep',null);
		pGallery.appendChild(sep);
		var arAlids = getValues(xmlRoot,'al_id');
		var arPNames = getValues(xmlRoot,'product_name');
		var arPUrls = getValues(xmlRoot,'product_url');
		var arPImgs = getValues(xmlRoot,'product_image');
		var arIWidths = getValues(xmlRoot,'image_width');
		var arIHeights = getValues(xmlRoot,'image_height');
		for(var i = 0 ; i < 5 ; i++){
			var pcell = CreateDiv('pcell',null);
			if(typeof (arAlids[i]) != 'undefined'){ 
				var a = document.createElement('a');
				a.href = arPUrls[i];
				a.setAttribute('title',arPNames[i]);
				a.onmouseover = rvpShowAlt;
				a.onmousemove = rvpMoveAlt;
				a.onmouseout = rvpRemoveAlt;
				var img = document.createElement('img');
				img.src = arPImgs[i];
				img.setAttribute('width',arIWidths[i]);
				img.setAttribute('height',arIHeights[i]);
				img.setAttribute('alt',arPNames[i]);
				a.appendChild(img);
				a.style.paddingTop = Math.round(55 - arIHeights[i])/2 + 'px';
				a.style.width = arIWidths[i] + 'px';
				pcell.appendChild(a); 
			}
			pGallery.appendChild(pcell);
			var sep = CreateDiv('sep',null);
			pGallery.appendChild(sep);
		}
		var tail = CreateDiv('head',null);
		pGallery.appendChild(tail);
		pGallery.appendChild(CreateDiv('line-sep',null));
		pGalleryOut.appendChild(CreateDiv('bwtl',null));
		pGalleryOut.appendChild(CreateDiv('bwtr',null));
		pGalleryOut.appendChild(CreateDiv('bwbl',null));
		pGalleryOut.appendChild(CreateDiv('bwbr',null));
		divPC.appendChild(CreateDiv('line-sep',null));
		var head = CreateDiv('head1',null);
		divPC.appendChild(head);
		var sep = CreateDiv('sep1',null);
		divPC.appendChild(sep);
		for(var i = 0 ; i < 5 ; i++){
			var pcell = CreateDiv('pcell1',null);
			if(typeof (arAlids[i]) != 'undefined'){ 
				pcell.innerHTML = '<input type="checkbox" name="rvp_'+i+'" value="'+arAlids[i]+'">';
			}
			divPC.appendChild(pcell);
			var sep = CreateDiv('sep1',null);
			divPC.appendChild(sep);
		}
		var tail = CreateDiv('head1',null);
		divPC.appendChild(tail);
		divPC.appendChild(CreateDiv('line-sep',null));
		divPC.appendChild(CreateDiv('bbtl',null));
		divPC.appendChild(CreateDiv('bbtr',null));
		divPC.appendChild(CreateDiv('bbbl',null));
		divPC.appendChild(CreateDiv('bbbr',null));
		var divCompare = CreateDiv('compare',null);
		var divTmp = CreateDiv('line-sep',null);
		divTmp.style.height='10px';
		divC.appendChild(divTmp);
		divC.appendChild(divCompare);
		var a = document.createElement('a');
		a.href = 'javascript:rvpCompare()';
		a.innerHTML = _langRVPCompare;
		divCompare.appendChild(a);
		var divRemove = CreateDiv('remove',null);
		divC.appendChild(divRemove);
		var a = document.createElement('a');
		a.href = 'javascript:rvpRemove()';
		a.innerHTML = _langRVPRemove;
		divRemove.appendChild(a);
		divC.appendChild(CreateDiv('line-sep',null));
	}
}
function rvpCompare(){
	var e = document.getElementById('rvp');
	if(e != null){
		elements = e.getElementsByTagName('input');
		var selected = 0;
		var strSelected = '';
		for(i = 0 ; i < elements.length ; i++){
			if(elements[i].checked){
				selected++;
				strSelected += elements[i].value+','; 	
			}
		}
		if(selected > 1 && selected <= 5){
    		strSelected = strSelected.substring(0,strSelected.length-1);
        	if(_comparePath.indexOf('?') >= 0){
        		window.location.href = _comparePath+'&product_ids='+strSelected;
        	}
        	else{
        		window.location.href = _comparePath+'?product_ids='+strSelected;
        	}
	   	}
	   	else{
	   		showErrMsg(_langCompareError);
	   	} 
	}
}
function rvpRemove(){
	var e = document.getElementById('rvpCon');
	if(e == null)return;
	elements = e.getElementsByTagName('input');
	var selected = 0;
	var strSelected = '';
	for(i = 0 ; i < elements.length ; i++){
		if(elements[i].checked){
			selected++;
			strSelected += elements[i].value+',';
		}
	}
	if(selected > 0){
   		strSelected = strSelected.substring(0,strSelected.length-1);
       	getRequest('/xml_index.php?page=_xml_rightside_helper&task=remove_recentviewedproducts&alids='+strSelected,RVPLoadAds);
   	}
}
var _bodyLoaded = false; 
function bodyOnLoad()
{
	//lang selection
	if(typeof _firstVisit != 'undefined' && _firstVisit){
		showHeaderSL();
	}
	
	//preLoadImages
	if(typeof arImagesList != "undefined")
  	{
  		var img = new Image();
  		for(var i = 0 ; i < arImagesList.length ; i++)
  		{
  			img.src = arImagesList[i];
  		}
  	}
  	
	if (bIE && bVer <= 6){
		//fix alastar png
		if(typeof _alastars != 'undefined'){
			for(var name in _alastars){
				var o = document.getElementById(name);
				if(o != null){
					o.style.backgroundImage = 'url("'+_ImageBase+'css/1x1.gif")';
					o.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+_alastars[name]+'", sizingMethod="image")';
				}
			}
		}
		//png fixing for IE6
		for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	      {
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='image');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
	}
	
	if(typeof _WindowResize != 'undefined' && !isNaN(_WindowResize)){
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth * ( _WindowResize / 100 ),screen.availHeight * ( _WindowResize / 100 ));
	}
	_bodyLoaded = true;
  	if( typeof _ALERT != "undefined"){
		showErrMsg(_ALERT);
	}
	// do other stuff,
    if(typeof oBodyOnLoad != "undefined")
    {
        for(var i = 0 ; i < oBodyOnLoad.length ; i++)
        {
            try{
            	eval(oBodyOnLoad[i]);
            }
            catch(e){
            }
        }
    }
    //logger banner impression
    if(typeof _BANNER_IDS != 'undefined'){
    	getRequest('/xml_index.php?page=_xml_logging&type=banner_impression&bids='+_BANNER_IDS,null);
    }
    //load recent viewed products
    var e = document.getElementById('rvp');
    if(e != null){
    	getRequest('/xml_index.php?page=_xml_rightside_helper&task=recentviewedproducts',RVPLoadAds);
    }
    if(typeof _NO_ADS == 'undefined'){
		//load ads by ajax
		window.setTimeout('loadAds()',1500);
	}		    
    return true;
}
var AOLoadAds = new AjaxObject();
AOLoadAds.OnComplete = adsHandle;
function loadAds(){
	if(_includeAmz > 0
	|| _includePR > 0
	|| _includeIntelliTXT > 0
	|| _includeNexttag > 0
	){
		var params = 'p='+_page+'&intellitext='+_includeIntelliTXT+'&includeAmz='+_includeAmz+'&includePR='+_includePR+'&includeNexttag='+_includeNexttag;
		if(typeof _al_id != 'undefined'){
			params += '&alid='+_al_id;
		}
		if(typeof _category_id != 'undefined'){
			params += '&cid='+_category_id;
		}
		getRequest(_ServerBase+'/banners.php?'+params,AOLoadAds);
	}
}

function adsHandle(xmlRoot){
	var eRightSkyscraper = document.getElementById('b_rightskyscraper');
	if(eRightSkyscraper != null){
		var nexttagSrc = getFirstValue(xmlRoot,"nexttag");
	  	if(nexttagSrc.length > 0){
	  		var divCon = CreateDiv('bncon',nexttagSrc);
		  	eRightSkyscraper.appendChild(divCon);
	  	}
		
		var amzSrc = getFirstValue(xmlRoot,"amzbanner");
	  	if(amzSrc.length > 0){
	  		var divCon = CreateDiv('bncon',amzSrc);
		  	eRightSkyscraper.appendChild(divCon);
	  	}
			  
	  	var prSrc = getFirstValue(xmlRoot,"prbanner");
	  	if(prSrc.length > 0){
		  	var divCon = CreateDiv('bncon',prSrc);
		  	eRightSkyscraper.appendChild(divCon);
	  	}
	}
	// intelliTXT 
	var intelliSrc = getFirstValue(xmlRoot,"intelli");
	if(intelliSrc.length > 0){
   		var jsel = document.createElement('SCRIPT');
   		jsel.type = 'text/javascript';
   		jsel.src = intelliSrc;
   		document.body.appendChild (jsel);
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}
function is_child_of(parent, child) {
	if( child != null ) {			
		while( child.parentNode ) {
			if( (child = child.parentNode) == parent ) {
				return true;
			}
		}
	}
	return false;
}
function isOnMouseOut(element, event) {
	var current_mouse_target = null;
	if( event.toElement ) {				
		current_mouse_target 			 = event.toElement;
	} else if( event.relatedTarget ) {				
		current_mouse_target 			 = event.relatedTarget;
	}
	if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
		return true;
	}
	else{
		return false;
	}
}
function getElementByClassName(node,tag,cName){
	var classElements = new Array();
	if(node != null){
		var els = node.getElementsByTagName(tag);
		var pattern = new RegExp("(^|\\s)" + cName + "(\\s|$)");
		for(var i = 0, j = 0 ; i < els.length ; i++){
			if (pattern.test(els[i].className)){
				classElements[j] = els[i];
				j++;
			}
		}
	}
	return classElements;
}

function setClass(id, cName){
	var el = document.getElementById(id);
	if(el!= null){
		el.className = cName; 
	}
}
function CreateP(elClass, elInnerHTML){
	var el = document.createElement('p');
	return setAttr(el, elClass, elInnerHTML);
}

function CreateA(elClass, elInnerHTML, shref, starget){
	var el = document.createElement('a');
	el = setAttr(el, elClass, elInnerHTML);
	el.href = shref;
	el.target = starget;
	return el;
}
function CreateDiv(elClass, elInnerHTML){
	var el = document.createElement('div');
	return setAttr(el, elClass, elInnerHTML);
}

function setAttr(el, elClass, elInnerHTML){
	if(elClass != null){
		el.className = elClass;
	}
	if(elInnerHTML != null){
		el.innerHTML = elInnerHTML;
	}
	return el;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight); 
	return arrayPageSize;
}
//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
/** events utilites **/
function hookEvent(element, eventName, callback)
{
  if(typeof(element) == "string")
    element = document.getElementById(element);
  if(element == null)
    return;
  if(element.addEventListener)
  {
    element.addEventListener(eventName, callback, false);
  }
  else if(element.attachEvent)
    element.attachEvent("on" + eventName, callback);
}

function unhookEvent(element, eventName, callback)
{
  if(typeof(element) == "string")
    element = document.getElementById(element);
  if(element == null)
    return;
  if(element.removeEventListener)
    element.removeEventListener(eventName, callback, false);
  else if(element.detachEvent)
    element.detachEvent("on" + eventName, callback);
}

function cancelEvent(e)
{
  e = e ? e : window.event;
  if(e.stopPropagation)
    e.stopPropagation();
  if(e.preventDefault)
    e.preventDefault();
  e.cancelBubble = true;
  e.cancel = true;
  e.returnValue = false;
  return false;
}

function getEventTarget(e)
{
  var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	return targ;
}
function enterAction(e,action)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13)
	{
	   action.call();
	   return false;
	}
	else{
	   return true;
	}
}
function Trim(str)
{
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}