function ShowSubCategoryBox(iBoxId){
	//alert(iBoxId)  ;
	
	if(document.getElementById('leafCat_'+iBoxId).style.display=='inline'){
		document.getElementById('leafCat_'+iBoxId).style.display = 'none';
		document.getElementById('offer_nav_'+iBoxId).src = 'http://images.ciao.com/ide/images/icons/offer_nav_down.gif';		
	}
	else{
		document.getElementById('leafCat_'+iBoxId).style.display = 'inline' ; 
		document.getElementById('offer_nav_'+iBoxId).src = 'http://images.ciao.com/ide/images/icons/offer_nav_up.gif';
	}
}


function ShowMoreCategory(iMoreCategoryBoxId){
	
	//iMoreCategoryBoxId
	
	if(document.getElementById('more_category_'+iMoreCategoryBoxId).style.display=='inline'){
		document.getElementById('more_category_'+iMoreCategoryBoxId).style.display = 'none';
		document.getElementById('more_link_'+iMoreCategoryBoxId).style.display = 'inline';	
		document.getElementById('back_link_'+iMoreCategoryBoxId).style.display = 'none';	
	}
	else{
		document.getElementById('more_category_'+iMoreCategoryBoxId).style.display = 'inline' ; 
		document.getElementById('more_link_'+iMoreCategoryBoxId).style.display = 'none';	
		document.getElementById('back_link_'+iMoreCategoryBoxId).style.display = 'inline';	
	}	
}

// Resize element according to content
function adjustIFrameSize(iframeWindow, iRepetitions)
{
	var iframeElement = parent.document.getElementById(iframeWindow.name);
	var vH = (document.all  && !window.opera)? iframeWindow.document.body.scrollHeight:iframeWindow.document.documentElement.offsetHeight;

	if(window.opera)
		iframeWindow.scrollBy(0,50);
	
	iframeElement.style.height = (vH > 20)? vH + "px":0;

	if(iRepetitions > 2)
		window.clearInterval(oActive);
}

// Resize banner div size
function adjustBannerDiv()
{
	var banner = document.getElementById("banner2");
	var divHeight = (document.all  && !window.opera)? banner.scrollHeight : banner.offsetHeight;
	if( divHeight < 30) {
		banner.style.padding = 0 + "px";
	}
}

// Doubleclick functions
var top_position = 115;
var leftOffset = 380;
var top_position_fs = 0;
var top_start_position = 0 ; 
var top_position_offset = 0;

// For storing mouse coords
var pos = new Object();

function move_sticky()
{
	try{
	var scraper = document.getElementById("scraper");
	if( scraper) {
		scraper.style.top = (getViewportScrollY() < top_position)? top_position + "px": getViewportScrollY() + "px";
	
		if(getViewportWidth() > 850) right_position = getViewportWidth() / 2 + leftOffset;
		else right_position = 800;
	
		scraper.style.left = getActiveStyle() == "fixed" ? scraper.style.left = right_position + "px":scraper.style.left = "90%";
	
		window.setTimeout(move_sticky, 200);
	}
	}
	catch(e){
	}
}

function move_sticky_fullsize(){

	try{
	
		var scraper = document.getElementById("scraper_new");
	
		if( scraper) {
						
			if(top_start_position <= 0 ){
				tmp = findElementPosition(scraper);
				top_start_position = parseInt( tmp['curtop']);
			}
			scraper.style.top = (getViewportScrollY() < top_position_fs+ top_start_position + 30)? top_position_fs + "px": getViewportScrollY()-top_start_position+15-top_position_offset + "px";
			window.setTimeout(move_sticky_fullsize, 25);
		}
	}catch(e){
	}
	
}

function move_sticky_hockey_scraper(){

	try{
	
		var scraper = document.getElementById("hockey_scraper");
	
		if( scraper) {
						
			if(top_start_position <= 0 ){
				tmp = findElementPosition(scraper);
				top_start_position = parseInt( tmp['curtop']);
			}
			scraper.style.top = getViewportScrollY() + "px";
			window.setTimeout(move_sticky_hockey_scraper, 5);
		}
	}catch(e){
	}
	
}

// Links to the page given by a splitted URL.
function jlink()
{
   var url = "";
   for (i = 0; i < arguments.length; i++)
   {
      url = url + arguments[i];
   }
   gotopage(url);
}


// Works like jlink, but returns url instead of going to it
function jlinkBuild()
{
   var url = "";
   for (i = 0; i < arguments.length; i++)
   {
      url = url + arguments[i];
   }
   return url;
}

function gotopage(url) { document.location.href=url; }

// blocks pasting by ctrl+v
function stopPaste(evt)
{
	if(!evt) evt = event;
	
	var ctrl = (typeof evt.modifiers == "undefined") ? evt.ctrlKey : evt.modifiers & evt.CONTROL_MASK;
	var v = (typeof evt.which == "undefined") ? evt.keyCode == 86 : evt.which == 86;

	// If the control and 'V' keys are pressed at the same time
	if (ctrl && v)
	{
		this.value = "";
		return false;
	}

	return true;
}

getViewportScrollY = function()
{
	var scrollY = 0;
	if(document.documentElement && document.documentElement.scrollTop)
	{
		scrollY = document.documentElement.scrollTop;
	}
	else if(document.body && document.body.scrollTop)
	{
		scrollY = document.body.scrollTop;
	}
	else if(window.pageYOffset)
	{
		scrollY = window.pageYOffset;
	}
	else if(window.scrollY) {
		scrollY = window.scrollY;
	}
	return scrollY;
};

getViewportWidth = function()
{
	var width = 0;
	if(document.documentElement && document.documentElement.clientWidth)
	{
		width = document.documentElement.clientWidth;
	}
	else if(document.body && document.body.clientWidth)
	{
		width = document.body.clientWidth;
	}
	else if(window.innerWidth)
	{
		width = window.innerWidth - 18;
	}
	return width;
};

// Stylesheet switcher
function setActiveStyle(title)
{
	for(var i=0; lnk = document.getElementsByTagName("link")[i]; i++)
	{
		if(lnk.getAttribute("rel").indexOf("style") != -1 && lnk.getAttribute("title"))
		{
			if(lnk.getAttribute("title") != title) lnk.disabled = true;
			else
			{
				/* Fix IE */
				lnk.disabled = true;
				lnk.disabled = false;
			}
		}
	}
}

function getActiveStyle()
{
	for(var i=0; lnk = document.getElementsByTagName("link")[i]; i++)
	{
		if(lnk.getAttribute("rel").indexOf("style") != -1 && !lnk.disabled && lnk.getAttribute("title"))
		{
			return lnk.getAttribute("title");
			break;
		}
	}
	
	return null;
}

function toggleLayout(img)
{
	var style = "";

	var srcLiquid = "http://images.ciao.com/ide/images/icons/go_liquid.gif";
	var srcFixed = "http://images.ciao.com/ide/images/icons/go_fixed.gif";

	if(getActiveStyle("style") == "fixed")
	{
		style = "";
		img.src = srcFixed;
		img.title = img.fixedTitle;
	}
	else
	{
		style = "fixed";
		img.src = srcLiquid;
		img.title = img.liquidTitle;
	}

	setActiveStyle(style);
}

function getCookie(name)
{
	name += "=";
	var cookies = document.cookie.split(";");

	for(var i=0; i<cookies.length; i++)
	{
		var start = (cookies[i].charAt(0) == " ")? 1:0;
		var c = cookies[i].substr(start);

		if(!c.indexOf(name))
		{
			return unescape(c.substr(name.length));
			break;
		}
	}

	return null;
}

function setCookie(name, value, days)
{
	if(!days) days = 365;

	var oToday = new Date();
	oToday.setTime(oToday.getTime() + (days * 24 * 60 * 60 * 1000));
	document.cookie = name + "=" + escape(value) + "; expires=" + oToday.toGMTString() + "; path=/";
}

function setCookieSimple( name, value ) {
	document.cookie = name + "=" + escape(value);
}


window.onunload = function()
{
	if(window.top == window.self) setCookie("style", getActiveStyle());
}

setActiveStyle(getCookie("style"));

// functions for category tooltip

function _setEltDisplay(a,c){
	if(!document.getElementById){
		return false
	}
	var b=document.getElementById(a);
	if(b){
		b.style.display=c
	}
	return false;
}

function _toggleSection(a){
	var c=a.id.indexOf("_");
	if(c==-1){return false}
	var b="cp"+a.id.substring(c);
	if(a.name=="on"){
		_setEltDisplay(b,"");
		a.name="off";
	} else {
		_setEltDisplay(b,"none");
		a.name="on";
	}
	return false;
}

var tt = null;
var visible = false;
var xOffset = -5;
var yOffset = 20;

var mouseDownX = 0;
var mouseDownY = 0;

// param: event - the mouse event
// return: none
// global: set mouseDownX and mouseDownY
function showPosition(e) {
    e=e||window.event
	mouseDownX = e.clientX + ( document.documentElement.scrollLeft || document.body.scrollLeft );
	mouseDownY = e.clientY + ( document.documentElement.scrollTop || document.body.scrollTop );
	window.status = 'X: ' + mouseDownX + ', Y: ' + mouseDownY
}

//document.onmousemove = showPosition

// param: divId - id of surrounding of the tooltip div
//        anchorId - id of 'mehr' anchor
// return: none
function toggleTt(divId, anchorId, xOffsetUser, yOffsetUser, bDontChangeCoursorStyle ) {
  if (xOffsetUser == undefined)
	  xOffsetUser = 0;
	  
  if (yOffsetUser == undefined)
	  yOffsetUser = 0;	
	  
  var oIframe = null;
	if(visible == true) {
		tt.style.display = "none";
		visible = false;

	} else {
		// get tooltip
		tt = document.getElementById(divId);
		
		var anchorElement = document.getElementById(anchorId);
		
		if ( ! anchorElement ) {
			return false;
		}
		
		//Determine the absolute position of the more link
		var curleft = 0;
		var curtop = 0;
		
		var currentObject = anchorElement;
		if ( currentObject.offsetParent ) {
			curleft = currentObject.offsetLeft;
			curtop = currentObject.offsetTop;
			while ( currentObject = currentObject.offsetParent ) {
				curleft += currentObject.offsetLeft
				curtop += currentObject.offsetTop
			}
		}

		//Make it visible
		tt.style.display = "block";
		visible = true;

		//Insert into the body
		var thisBody = document.getElementsByTagName("body")[0];
		thisBody.insertBefore( tt, thisBody.firstChild );

		//Determine the current window size and visible area
		var windowSize = new WindowSize();

		//Adjust width of the element if >30% of page width to 30%
		if ( tt.offsetWidth > ( 0.3 * windowSize.width ) ) {
			tt.style.width = Math.floor( (0.3 * windowSize.width) ) +"px";
		}

		//Use a help cursor
		if ( bDontChangeCoursorStyle == undefined || !bDontChangeCoursorStyle ) {
  			anchorElement.style.cursor = "help";
		}
		
		//Adjust if they are off-screen
		if ( (curtop + yOffset + tt.offsetHeight + yOffsetUser ) > windowSize.visibleBottom ) {
			//Try to go to the top
			var curtopTmp = (curtop - (anchorElement.offsetHeight + tt.offsetHeight)) - 5;
			if (curtopTmp > windowSize.visibleTop) {
				curtop = curtopTmp;
			}
		}
		if ( (curleft + xOffset + tt.offsetWidth + xOffsetUser ) > (windowSize.width - 10) ) {
			//Go to the left
			curleft = (curleft + anchorElement.offsetWidth + 5) - tt.offsetWidth;
		}

		//Set the position
		tt.style.left = (curleft + xOffset + xOffsetUser ) + "px";
		tt.style.top = (curtop + yOffset + yOffsetUser ) + "px";
		tt.style.position = "absolute";

		if (document.all && tt.firstChild.nodeName.toLowerCase()=='iframe') {
			tt.firstChild.style.width = tt.clientWidth + 'px';
			tt.firstChild.style.height = tt.clientHeight + 'px';
		}
	}	
} 

/**
 * "Class" for determining the size of the current display window
 */
function WindowSize() {

	//The total height of the window
	this.height = 100;

	//The width of the window
	this.width = 100;

	//The top and bottom location of the visible area
	this.visibleTop = 0;
	this.visibleBottom = 100;

	/**
	 * Refreshes the values by re-calculating the window size
	 */
	this.refresh = function() {

		//Cross browser code
		if (window.innerHeight) { // all except Explorer
			this.height = window.innerHeight;
			this.width = window.innerWidth;
			this.visibleTop = window.pageYOffset;
		}
		else if (document.documentElement ) {
			// Explorer 6 Strict Mode
			var docElement = document.documentElement;
			if ( docElement.clientHeight ) {
				this.height = docElement.clientHeight;
				this.width = docElement.clientWidth;
				this.visibleTop = docElement.scrollTop;
			}
		}
		else if (document.body) // other Explorers
		{
			var docBody = document.body;
			this.height = docBody.clientHeight;
			this.width = docBody.clientWidth;
			this.visibleTop = docBody.scrollTop;
		}		
		
		//Use the top to calculate the bottom value
		this.visibleBottom = this.visibleTop + this.height;
	};

	//Execute the function
	this.refresh();
}    

function setVisibility(a,c){
	if(!document.getElementById){
		return false
	}
	var b=document.getElementById(a);
	if(b){
		b.style.display=c
	}
	return false
}

function toggleSection(a){
	var toggleImage = a.getElementsByTagName("img")[0];
	if ( toggleImage === null ) {
		return false;
	}
	var containedList = a.parentNode.getElementsByTagName("ul")[0];
	if ( containedList === null ) {
		return false;
	}
 
	if( toggleImage.src.search(/plus\.gif/) > -1 ) {
		toggleImage.src = toggleImage.src.replace(/plus\.gif/, "minus.gif");
		containedList.style.display = "";
	} else {
		toggleImage.src = toggleImage.src.replace(/minus\.gif/, "plus.gif");
		containedList.style.display = "none";
	}
 
	return false;

}

//check an input if it's blank
function CheckInput( inputName ) {  
  
  var strfield;

	try {
		strfield = document.getElementById(inputName).value; 
	}
	catch(e) { 
		strfield = '';
	}
	if ( strfield.replace(/\s/g,'') == '' ){ return false; }
	
	return true; 	
}


/**
 *	Replaces all occurences of a space to + in a string
 *
 */
function replaceSpaces2Plus( sStringToReplace ) {
	var sReplacedString = encodeURIComponent( sStringToReplace );
	var sTempUrl = sReplacedString;
	do {
		sReplacedString = sTempUrl;
		sTempUrl = sReplacedString.replace( '%20', '+' ).replace( '\'', '%27' ).replace( '~', '%7E' ).replace( '!', '%21' ).replace( '(', '%28' ).replace( ')', '%29' ).replace( '%2F', '/' );
	} while( sReplacedString != sTempUrl );
	return sReplacedString;
}

/**
 * Transforms URLs of advanced search to new format
 * 
 */
function advancedSearchPageUrl( sFormName ) {
	var iTopCategory = document.forms[sFormName].elements['TopCategory'].value;
	var iSearchType = document.forms[sFormName].elements['SearchType'].value;
	var sAdvancedResult = document.forms[sFormName].elements['AdvancedResult'].value;
	var sAll = document.forms[sFormName].elements['advs_wallw'].value;
	var sExact = document.forms[sFormName].elements['advs_wexactw'].value;
	
	var sAny = '';
	try {
		sAny = document.forms[sFormName].elements['advs_wanyw'].value;
	} catch(e) {}
	
	var sOut = document.forms[sFormName].elements['advs_woutw'].value;
	var iFromPrice = document.forms[sFormName].elements['advsc_fromprice'].value;
	var iToPrice = document.forms[sFormName].elements['advsc_toprice'].value;
	var iTopPrice = document.forms[sFormName].elements['advsc_topprice'].value;
	
	var sSearchReferrer = '';
	var sPid = '';
	try {
		sSearchReferrer = document.forms[sFormName].elements['SearchReferrer'].value;
		sPid = document.forms[sFormName].elements['Pid'].value;
	} catch(e) {}
	
	var sURL;
	
	for( counter = 0 ; counter < document.forms[sFormName].elements['advsc_pricesearch'].length ; counter++ ) {
		if( document.forms[sFormName].elements['advsc_pricesearch'][counter].checked ) {
			var iPriceSearchRadio = document.forms[sFormName].elements['advsc_pricesearch'][counter].value;
		}
	}
	
	var sParams = '';
	
	var bEmptySearchString = true;
	
	var sParamsDelimiter = '';
	var sParamsValueSign = '';
	
	if ( getCookie( 'bBing' ) == 1 ) {
		sParamsDelimiter = '&';
		sParamsValueSign = '=';
	} else {
		sParamsDelimiter = ',';
		sParamsValueSign = '-';
	}
	
	if( sAll != '' ) {
		sParams = sParams + sParamsDelimiter + 'qa' + sParamsValueSign + replaceSpaces2Plus( sAll );
		bEmptySearchString = false;
	}
	if( sExact != '' ) {
		sParams = sParams + sParamsDelimiter + 'qe' + sParamsValueSign + replaceSpaces2Plus( sExact );
		bEmptySearchString = false;
	}
	if( sAny != '' ) {
		sParams = sParams + sParamsDelimiter + 'qn' + sParamsValueSign + replaceSpaces2Plus( sAny );
		bEmptySearchString = false;
	}
	if( sOut != '' ) {
		sParams = sParams + sParamsDelimiter + 'qo' + sParamsValueSign + replaceSpaces2Plus( sOut );
		bEmptySearchString = false;
	}
	
	if( bEmptySearchString ) return false;
	
	if( iTopCategory != 0 ) { 
		sParams = sParams + sParamsDelimiter + 'tc' + sParamsValueSign + iTopCategory; 
	}
	
	switch( iPriceSearchRadio ) {
		case '1':
			if( iToPrice != 0 ) sParams = sParams + sParamsDelimiter + 'pt' + sParamsValueSign + iToPrice;
			sParams = sParams + sParamsDelimiter + 'ps' + sParamsValueSign + iPriceSearchRadio;
			break;
		case '2':
			if( iFromPrice != 0 ) sParams = sParams + sParamsDelimiter + 'pm' + sParamsValueSign + iFromPrice;
			if( iTopPrice != 0 ) sParams = sParams + sParamsDelimiter + 'pl' + sParamsValueSign + iTopPrice;
			sParams = sParams + sParamsDelimiter + 'ps' + sParamsValueSign + iPriceSearchRadio;
			break;
	}

	if( iSearchType != 0 ) sParams = sParams + sParamsDelimiter + 'st' + sParamsValueSign + iSearchType;
	
	sParams = sParams + sParamsDelimiter + 'ar' + sParamsValueSign + sAdvancedResult;
	
	if( sSearchReferrer != '' && typeof sSearchReferrer != 'undefined' ) {
		sParams = sParams + sParamsDelimiter + 'sr' + sParamsValueSign + sSearchReferrer;
	}
	if( sPid != '' && typeof sPid != 'undefined' ) {
		sParams = sParams + sParamsDelimiter + 'pd' + sParamsValueSign + escape(sPid);
	}

	sParams = sParams.substr( 1, sParams.length );
	
	if ( getCookie( 'bBing' ) == 1 ) {
		sURL = '/mssr?' + sParams;
	} else {
		sURL = '/sr/' + sParams;
	}
	
	setCookie( "searchPageAction", "1", 0.00012 );
	document.location.href = sURL;
	return false;
}

/**
 * Transforms URLs of search to new format
 * 
 */
function searchPageUrl( sFormName , domain ) {
	var sSearchString = document.forms[sFormName].elements['SearchString'].value.toLowerCase();

	try {
		if( CheckInput('SearchString', true) == false ) return false;
	} catch(e) {
		
	}

	var sURL;

	if ( getCookie( 'bBing' ) == 1 ) {
		sURL = '/mssr?q=' + replaceSpaces2Plus( sSearchString );
	} else {
		sURL = '/sr/q-' + replaceSpaces2Plus( sSearchString );
	}
	
	try {
		var oSelect = document.getElementById("category");
		var iField = oSelect.options[oSelect.selectedIndex].value;
		if ( !isNaN( iField ) && iField != 0 ) {
			
			if ( getCookie( 'bBing' ) == 1 ) {
				sURL = sURL + '&tc=' + iField;
			} else {
				sURL = sURL + ',tc-' + iField;
			}

		} else if (isNaN(iField)) {
            if ( iField == 'ciao_lists' ) {
                sURL = '/product_lists_overview.php?q=' + sSearchString + '&v=b';
            } else if ( iField == 'opinions' ) {
                sURL = '/search.php?SearchString=' + sSearchString + '&SearchType=1';
            } else {
				if( typeof( domain ) != 'undefined' )
					iField = domain + '/' + iField;

				setCookieSimple( "searchUserCheck", "checksum: " + sSearchString );
				setCookie( "searchPageAction", "1", 0.00012 );
            	window.location = iField + '-q-' + sSearchString;
                return false;
            }
	  	}
		
	} catch(e) {
		
	}
	
	if( typeof( domain ) != 'undefined' )
		sURL = domain + sURL;
	
	setCookieSimple( "searchUserCheck", "checksum: " + sSearchString );
	setCookie( "searchPageAction", "1", 0.00012 );
	document.location.href = sURL;
	return false;
}



function VideoReviewSearch( inputName ) {
	var strfield;
	var uri;
	if ( ! CheckInput( inputName ) ) return;
	try {
		strfield = document.getElementById(inputName).value; 
	}
	catch(e) { 
		strfield = '';
	}
	uri = encodeURI( 'search.php?hasVideos=1&SearchString=' + strfield );
	document.location.href = uri;
	return;
}


function offerPerformSearch() {
	var template = document.getElementById( 'searchRedirectionTemplate' ).value;
	var term = document.getElementById( 'query' ).value;
	if( term == "" ) return;
	//term = term.replace( /-/, ' ' );
	term = term.replace( /~/, ' ' );
	term = term.replace( / /, '_' );
	term = term.replace( '/', '%2F' );
	term = escape( term );
	// %7E%7E%7E = escape( ~~~ )
	var url = template.replace( /%7E%7E%7E/, term );
	var oExpDate = new Date();
	var sTerm = term;
	oExpDate.setTime( oExpDate.getTime() + 1000 * 60 * 10 ); //set for 10 min
	document.cookie = "noSearchSkipping=" + sTerm + ";expires=" + oExpDate.toGMTString();

	url = url.replace( /-(.*?)-q-/, '-q-' ) ;
	document.location.href = url;
}
// allows to disable seperator option ---------- in IE
// better browsers support HTML option disabled

function changeSortOrder(s) {
	var gourl = s.options[s.selectedIndex].value;
	window.top.location.href = gourl;
}

function disableSeperator(selectField) {
	
	var disabledValues = ["","-2"];
	var chosen = selectField.selectedIndex;
	
	for (var i=0;i<disabledValues.length;i++) {
		if (selectField.options[chosen].value==disabledValues[i]) {
			selectField.options[0].setAttribute('selected','selected');
			break;
		}
		
	}
	return true;	
}

function DisplayTopRightBox() {
	var oTopRightOffers = document.getElementById("top_right_offers");
	var oContentAd      = document.getElementById("doubleclick_contentAd");
  var oEBayAds        = document.getElementById("ebay_ads");
  
  if ( oContentAd != null ) { oContentAd.style.display = "block"; }    
  if ( oTopRightOffers != null ) { oTopRightOffers.style.display = "block"; }  
  if ( oEBayAds != null) { oEBayAds.style.display = "block"; }  
}

// The function displays or covers the box with the offers (compare prices) || ebay ads || content ad
// iPriorityVer -> example use
// 1 => 1 -> Content ad
// 			2 -> Top right offer
// 			3 -> eBay ads

// 2 => 1 -> eBay ads
// 			2 -> Top right offer
// 			3 -> Content ad

// 3 => 1 -> Top right offer
// 			2 -> Content ad
// 			3 -> eBay ads 
function topRightBox(iPriorityVer) {  
	
    if (iPriorityVer == null || isNaN(iPriorityVer)) {
        iPriorityVer = 1;  
    }	
  
	var bExistContentAd      = 0;
    var bExistEBayAds        = 0;
    var bExistTopRightOffers = 0;
    	
	var oTopRightOffers = document.getElementById("top_right_offers");
	var oContentAd      = document.getElementById("doubleclick_contentAd");
    var oEBayAds        = document.getElementById("ebay_ads");
  
    var bPC = 0; // placement empty
	
    function displayContentAd() {
		if ( bExistContentAd == 1 && bPC == 0 ) {
            oContentAd.style.display = "block";
            if ( bExistTopRightOffers == 1 ) { oTopRightOffers.style.display = "none"; }
            if ( bExistEBayAds == 1 )     	 { oEBayAds.style.display = "none"; }
            bPC = 1; // placement taken
        }
	}
	
    function displayEBayAds() {
        if ( bExistEBayAds == 1 && bPC == 0 ) {
            oEBayAds.style.display = "block";
      		if ( bExistContentAd == 1 ) 			 { oContentAd.style.display = "none"; }
      		if ( bExistTopRightOffers == 1 ) { oTopRightOffers.style.display = "none"; }
      		bPC = 1; // placement taken
        }
    }	
	
    function displayTopRightOffers() {
        if ( bExistTopRightOffers == 1 && bPC == 0 ) {
            if ( oTopRightOffers.offsetWidth < 350 ) {
                oTopRightOffers.style.width = '350px';
            }            
            oTopRightOffers.style.display = "block";
    		if ( bExistContentAd == 1 ) { oContentAd.style.display = "none"; }
    		if ( bExistEBayAds == 1 ) { oEBayAds.style.display = "none"; }
    		bPC = 1; // placement taken
    	} 
    }									
  
    if ( oContentAd != null ) {
    	oContentAd.style.display = "block";
    	if ( oContentAd.offsetHeight >= 25 ) {
            bExistContentAd = 1; 
        }
        oContentAd.style.display = "none";
    }
  
    if ( oTopRightOffers != null ) { bExistTopRightOffers = 1; }  
    if ( oEBayAds != null) { bExistEBayAds = 1; } 
  
    switch (iPriorityVer) {
    	case 1:
    		displayContentAd();
    		displayTopRightOffers();
    		displayEBayAds();
    		break;
    	
    	case 2: 
            displayEBayAds();
            displayTopRightOffers();
            displayContentAd();
            break;
    	
    	case 3: 
            displayTopRightOffers();
            displayContentAd();
            displayEBayAds();
            break;
    }  
  
//DisplayTopRightBox();
} //end function topRightBox


function findElementPosition(obj) {

	var curleft = curtop = 0;
	if (obj.offsetParent) {
	  curleft = obj.offsetLeft
	  curtop = obj.offsetTop
	  while (obj = obj.offsetParent) {
	   curleft += obj.offsetLeft
	   curtop += obj.offsetTop
	  }
	}
	
	var param = new Object ();
	
	param['curleft']  = curleft ; 
	param['curtop']  = curtop ; 
	
	return param;
}

// START OnloadEventHandler
// Wrapper for BodyEventHandler.AddOnload function. Should not be used anymore.
// Instead of it use BodyEventHandler.AddOnload
function addFunctionToBodyOnloadEvent( oFunction ) {
	BodyEventHandler.AddOnload( oFunction );
}
// END OnloadEventHandler

// Class designed to handle multiple event calls of defined object
var BodyEventHandler = new function(){
	
	// get events from body
	this.aBodyOnloadFunctions = new Array( window.onload );
	this.aBodyOnclickFunctions = new Array( window.onclick );
	this.aBodyOnmousemoveFunctions = new Array( document.onmousemove );
	
	this.AddOnload = function( oFunction ) {
		this.aBodyOnloadFunctions[ this.aBodyOnloadFunctions.length ] = oFunction;
		window.onload = function() {
			BodyEventHandler.InvokeOnloadEvents();
		}
	};
	
	this.RemoveOnload = function( oFunction ) {
		for ( i = 0; i < this.aBodyOnloadFunctions.length; i++ ) {
			if ( this.aBodyOnloadFunctions[i] == oFunction ) {
				this.aBodyOnloadFunctions.splice( i, 1 );
				break;
			}
		}
	};
	
	this.InvokeOnloadEvents = function() {
		for ( i = 0; i < this.aBodyOnloadFunctions.length; i++ ) {
			if ( this.aBodyOnloadFunctions[i] != undefined ) {
				this.aBodyOnloadFunctions[i]();
			}
		}
	}
	
	
	this.AddOnclick = function( oFunction ) {
		this.aBodyOnclickFunctions[ this.aBodyOnclickFunctions.length ] = oFunction;
		window.onclick = function() {
			BodyEventHandler.InvokeOnclickEvents();
		}
	};
	
	this.RemoveOnclick = function( oFunction ) {
		for ( i = 0; i < this.aBodyOnclickFunctions.length; i++ ) {
			if ( this.aBodyOnclickFunctions[i] == oFunction ) {
				this.aBodyOnclickFunctions.splice( i, 1 );
				break;
			}
		}
	};
	
	this.InvokeOnclickEvents = function() {
		for ( i = 0; i < this.aBodyOnclickFunctions.length; i++ ) {
			if ( this.aBodyOnclickFunctions[i] != undefined ) {
				this.aBodyOnclickFunctions[i]();
			}
		}
	}
	
	this.AddOnmousemove = function( oFunction ) {
		this.aBodyOnmousemoveFunctions[ this.aBodyOnmousemoveFunctions.length ] = oFunction;
		document.onmousemove = function( e ) {
			BodyEventHandler.InvokeOnmousemoveEvents( e );
		}
	};
	
	this.RemoveOnmousemove = function( oFunction ) {
		for ( i = 0; i < this.aBodyOnmousemoveFunctions.length; i++ ) {
			if ( this.aBodyOnmousemoveFunctions[i] == oFunction ) {
				this.aBodyOnmousemoveFunctions.splice( i, 1 );
				break;
			}
		}
	};
	
	this.InvokeOnmousemoveEvents = function( e ) {
		for ( i = 0; i < this.aBodyOnmousemoveFunctions.length; i++ ) {
			if ( this.aBodyOnmousemoveFunctions[i] != undefined ) {
				this.aBodyOnmousemoveFunctions[i]( e );
			}
		}
	}
	
}

var aMouseOverOutEvents = new Array();
function MouseOverOutEvents( sId ) {
	
	this.id = sId;
	this.bMouseOut;
	
	this.oMouseOver = null;
	this.oMouseOut = null;
	
	this.iLastOverEvent = 0;
	this.iLastOutEvent = 0;
	
	this.iMouseOverDelay = 0;
	this.iMouseOutDelay = 200;
	
	this.AssignEvents = function( oOnmouseOver, oOnmouseOut ) {
		this.oMouseOver = oOnmouseOver;
		this.oMouseOut = oOnmouseOut;
	}
	
	this.AssignOverEvent = function( oOnmouseOver, iDelay ) {
		this.oMouseOver = oOnmouseOver;
		this.iMouseOverDelay = iDelay;
	}
	
	this.AssignOutEvent = function( oOnmouseOut, iDelay ) {
		this.oMouseOut = oOnmouseOut;
		this.iMouseOutDelay = iDelay;
	}
	
	this.Init = function() {
		BodyEventHandler.AddOnmousemove( getMousePosition )
		this.oObject = document.getElementById( this.id );
		this.bMouseOut = this.isOut();
		this.oObject.onmouseover = 	aMouseOverOutEvents[this.id].MouseOver;
		this.oObject.onmouseout = 	aMouseOverOutEvents[this.id].MouseOut;
	}
	
	this.MouseOut = function() {
		aMouseOverOutEvents[this.id].iLastOutEvent = (new Date()).getTime() - 200;
		setTimeout( "aMouseOverOutEvents['" + this.id + "'].InvokeMouseOut()", aMouseOverOutEvents[this.id].iMouseOutDelay );
	}
	
	this.InvokeMouseOut = function() {
		// prevent from invoking function too early
		if ( ( (new Date()).getTime() - this.iLastOutEvent ) < this.iMouseOutDelay ) {
			return;
		}
		
		if ( ! this.bMouseOut && this.isOut() ) {
			this.bMouseOut = true;
			
			if ( this.oMouseOut != null ) this.oMouseOut( this.oObject );
		}
	}
	
	this.MouseOver = function() {
		aMouseOverOutEvents[this.id].iLastOverEvent = (new Date()).getTime() - 200;
		setTimeout( "aMouseOverOutEvents['" + this.id + "'].InvokeMouseOver()", aMouseOverOutEvents[this.id].iMouseOverDelay );
	}
	
	this.InvokeMouseOver = function() {
		// prevent from invoking function too early
		if ( ( (new Date()).getTime() - this.iLastOverEvent ) < this.iMouseOverDelay ) {
			return;
		}
		
		if ( this.bMouseOut && ( this.isOut() == false ) ){
			this.bMouseOut = false;
			if ( this.oMouseOver != null ) this.oMouseOver( this.oObject );
		}
	}
	
	this.isOut = function() {
		
		aRect = this.getRectangle();
		
		if ( ( pos['left'] < aRect["x"][0] ) || ( pos['left'] > aRect["x"][1] ) ) {
			return true;
		}
		
		if ( ( pos['top'] < aRect["y"][0] ) || ( pos['top'] > aRect["y"][1] ) ) {
			return true;
		}
		
		return false;
	}
	
	this.getElementPosition = function() {
		var obj = this.oObject;
		var aCoords = new Array(2);
		if (obj.offsetParent) {
			aCoords["left"] = obj.offsetLeft
			aCoords["top"] = obj.offsetTop
			while (obj = obj.offsetParent) {
				aCoords["left"] += obj.offsetLeft
				aCoords["top"] += obj.offsetTop
			}
		}
		return aCoords;
	}
	
	this.getElementSize = function() {
		var aRet = new Array(2);
		aRet["height"] = this.oObject.offsetHeight;
		aRet["width"] = this.oObject.offsetWidth;
		return aRet;
	}
	
	this.getRectangle = function() {
		var aRet = new Array(2);
		
		aSize = this.getElementSize();
		aPos = this.getElementPosition();
		
		aRet["x"] = [ aPos["left"], aPos["left"] + aSize["width"] ];
		aRet["y"] = [ aPos["top"], aPos["top"] + aSize["height"] ];
		
		return aRet;
	}
	
	this.Clean = function() {
		this.oObject.onmouseover = 	null;
		this.oObject.onmouseout = 	null;
		return null;
	}
	
}


// Start of Kiev Part : search field or loginName on login page
function setFocusOnSearchField() {
	if ( document.getElementById('LoginName') ){
		document.getElementById('LoginName').focus();
	} else if ( document.getElementById('SearchString') ) {
		document.getElementById('SearchString').focus();
	}
};
if ( window.location.href.indexOf('#') == -1 ) {
	BodyEventHandler.AddOnload( setFocusOnSearchField );
}
// End of Kiev Part : search field

function wordCount(sText){
	
	var iWordCounter	= 0 ;
	var iMinWordLength 	= 2 ; 
	var sText 	= sText;
	var sExp 	= /[^A-Za-z0-9'`"]+/gi;

	sText = sText.replace(sExp, " ");
			
	var sSplitString = sText.split(" ");

	for(t = 0 ; t < sSplitString.length ; t++)
		if(sSplitString[t].length >= iMinWordLength)
			iWordCounter ++ ;
	
	return iWordCounter ; 
}


function getWindowSize(){	
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  iWidth = window.innerWidth;
	  iHeight = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  iWidth = document.body.offsetWidth;
	  iHeight = document.body.offsetHeight;
	 }
	}
	
	var param = new Object ();
 
 	param['width']  	= iWidth ; 
 	param['height']  	= iHeight ; 
 
 	return param;
}



function getMousePosition(e) {
	var IE = document.all?true:false;
	
	// set up for mouse capture
	if ( ! IE ) document.captureEvents( Event.MOUSEMOVE );
	
	if ( IE ) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}
	
	pos['left'] = tempX;
	pos['top'] = tempY;
}

function showPresentForToday() {
	iDivWidth = 706;
	
	if (self.innerWidth)
	{
		iWidth = self.innerWidth;
		iHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		iWidth = document.documentElement.clientWidth;
		iHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		iWidth = document.body.clientWidth;
		iHeight = document.body.clientHeight;
	}
	
	// Get the middle of the screen
	iCenter = iWidth/2;
	iTopLeft = iCenter-(iDivWidth/2)
	
	var elem = document.getElementById( 'presentForToday' );	
	if( elem.style.display != 'block' ) {
		elem.style.left = iTopLeft + 'px'
		elem.style.display = 'block'
	} else {
		elem.style.display = 'none'	
	}
}

/*
 *	function to popup opening.
 * 	parameters shold be set in following order:
 *  param: popUrl - popup url
 *  param: popOptions - popup properties comma separated (for example: 'scrollbars=yes,resizable=yes') (optional)
 *  param: popWidth - popup width, if popWidth =< 1 then is taken as proportion to actual browser width (optional)
 *  param: popHeight - popup width, if popHeight =< 1 then is taken as proportion to actual browser height (optional)
 *  param: popName - popup (window) name (optional)
 */

function openPopUp(popURL) {
	var scrH = 0;
	var scrW = 0;
	
	/*default values settings*/
	if (!arguments[2] || arguments[2] == null) {
		var propW = 0.67;
	}
	else if (arguments[2] > 1) {
		var popWidth = 	arguments[2];
	}
	else {
		var propW = arguments[2];
	}
	
	if (!arguments[3] || arguments[3] == null) {
		var propH = 0.67;
	}
	else if (arguments[3] > 1) {
		var popHeight = arguments[3];
	}
	else {
		var propH = arguments[3];
	}
	
	if (!arguments[4] || arguments[4] == null) {
		var popName = 'anonymous';
	}
	else {
		var popName = arguments[4];
	}
	/*end of default settings*/
	
	if (propW) {
		if (document.documentElement && document.documentElement.clientHeight) {// IE6 Strict
			var scrW = document.documentElement.clientWidth;
		}
		else if (document.body) {// IE other
			var scrW = document.body.clientWidth;
		}
		else if (document.innerWidth) {// FF, Opera
			var scrW = document.innerWidth;
		}
		else {
			var scrW = screen.width;
		}
		
		var popWidth = scrW * propW;
		popWidth = Math.floor(popWidth);
		
		if (popWidth < 825) {
			popWidth = 825;
		}
	}
	
	if (propH) {
		var scrH = screen.height;
		var popHeight = scrH * propH;
		popHeight = Math.floor(popHeight);
	}

	var popOptions = 'width=' + popWidth + ',height=' + popHeight;
	
	if (arguments[1] && arguments[1] != null) {
		var popOptions = popOptions + ',' + arguments[1];
	} 
	
	var nW = window.open(popURL,popName,popOptions);
	nW.focus();

}




function RatingBar(id, isEnabled ,imageOnUrl, imageOffUrl, imageHoverUrl, maxValue,value ,cbMarkedFunction,cbSelectedFunction){
	
	if( cbMarkedFunction == undefined || cbMarkedFunction == null )
		cbMarkedFunction = '' ;
		
	if( cbSelectedFunction == undefined || cbSelectedFunction == null )
		cbSelectedFunction = '' ;
	
	if( isEnabled == undefined || isEnabled == null )
		isEnabled = true;
	
	if( value == undefined || value == null )
		value = 0;
	
	if( maxValue == undefined || maxValue == null )
		maxValue = 5;
	
	// ID contains the client-side unique id of this control
	this.ID = id;
	
	// MaxValue: Get or Set the maximum value for this control
	this.MaxValue = maxValue;
	
	// Value: Get or Set the value for this control.
	this.Value = value;
	
	// ImageOn: name of the image used to represent the selected value
	this.ImageOn = imageOnUrl;
	
	// ImageOff: name of the image used to represent the available values to select
	this.ImageOff = imageOffUrl;
	
	// ImageHover: name of the image used to provide user feedback when hovering over the control
	this.ImageHover = imageHoverUrl;
		
	// AutoLock: (if true) will disable this control once a value has been selected (clicked).
	this.AutoLock = false;

	// IsEnabled returns a boolean value indicating if the user may use this control.  ReadOnly.
	this.IsEnabled = isEnabled ;

	// IsInitialized: returns a boolean value indicating if this rater control has been initialized.  ReadOnly.
	this.IsInitialized = false;
	
	
	// Images: an Array containing an entry for each image in this control.
	this.Images 			= new Array(maxValue + 1);
	
	this.cbMarked 		= cbMarkedFunction ;
	
	this.cbSelected 	= cbSelectedFunction ;
	
	this.Container 		= null;
	
	this.ValueControl 	= null;
	this.ValueControlID = this.ID + "_Value";
	
	this.ImageOnCache 		= new Image().src = this.ImageOn;
	this.ImageOffCache 		= new Image().src = this.ImageOff;
	this.ImageHoverCache 	= new Image().src = this.ImageHover;	
}


RatingBar.Items = Array();


RatingBar.Create = function(id, isEnabled , imageOnUrl, imageOffUrl, imageHoverUrl, maxValue, value ,cbMarkedFunction,cbSelectedFunction){
	
	var obj = new RatingBar(id, isEnabled , imageOnUrl, imageOffUrl, imageHoverUrl, maxValue, value,cbMarkedFunction,cbSelectedFunction);
	
	RatingBar.Items[obj.ID] = obj;

	return obj;
}


RatingBar.CreateBar = function(id, isEnabled , imageOnUrl, imageOffUrl, imageHoverUrl, maxValue, value ,cbMarkedFunction,cbSelectedFunction){

	var rater = RatingBar.Create(id, isEnabled , imageOnUrl, imageOffUrl, imageHoverUrl, maxValue, value ,cbMarkedFunction,cbSelectedFunction);

	rater.Render();

	return rater;
}


RatingBar.InitializeRater = function(rater){
	
	for(i = 1; i <= rater.MaxValue; i++){
		var imgID = rater.ID + "_img" + i;
		var img = document.getElementById(imgID);
		rater.Images[i] = img;
	}
	
	rater.Container = document.getElementById(rater.ID);
	
	var myItems = document.getElementsByName(rater.ValueControlID);
	rater.ValueControl = myItems[0];
	
	rater.IsInitialized = true;
}


RatingBar.Refresh = function(source, raterID){
	var rater = RatingBar.Items[raterID];
	var value = rater.Value;
	
	for(var i = 1; i <= rater.MaxValue; i++){
		if( value >= i )
			rater.Images[i].src = rater.ImageOn;
		else
			rater.Images[i].src = rater.ImageOff;
	}
	
	if( typeof( rater.cbMarked ) == 'function' ) {
		rater.cbMarked( value );
	}
	else {
		if(rater.cbMarked!='') {
			eval(rater.cbMarked+"("+value+");");
		}
	}		
}


RatingBar.Hover = function(source, raterID){
	
	var rater = RatingBar.Items[raterID];
	if( !rater.IsEnabled ) return;
	
	var value = source.getAttribute("value");
	
	for(var i = 1; i <= rater.MaxValue; i++){
		if( value >= i )
			rater.Images[i].src = rater.ImageHover;
		else
			rater.Images[i].src = rater.ImageOff;
	}


	if( typeof( rater.cbMarked ) == 'function' ) {
		rater.cbMarked( value );
	}
	else {
		if(rater.cbMarked!='') {
			eval(rater.cbMarked+"("+value+");");
		}
	}
}



RatingBar.Click = function(source, raterID){

	var rater = RatingBar.Items[raterID];
	
	if( !rater.IsEnabled ) 
		return;

	rater.Value = source.getAttribute("value");

	RatingBar.Refresh(source, raterID);
	
	if( 'function' == typeof rater.cbSelected ) {
		rater.cbSelected.call( null, rater.Value );
	} else if( rater.cbSelected != '' ) {
		eval(rater.cbSelected+"("+rater.Value+");");
	}
	
	if( rater.AutoLock )
		rater.Enable(false);
	
}


RatingBar.prototype.Initialize = function(){
	RatingBar.InitializeRater(this);
}


RatingBar.prototype.Enable = function(enable){
	this.Container.disabled = !enable;
	this.IsEnabled = enable;
}


RatingBar.prototype.Visible = function(visible){
	if( visible )
		this.Container.style.visibility = "Visible";
	else
		this.Container.style.visibility = "Hidden";
}


RatingBar.prototype.Render = function(){

	var bgSpan = document.getElementById(this.ID+'_ratingbar') ;
	
	bgSpan.innerHTML += "<input id=" + this.ValueControlID + " type=hidden>" ;
	bgSpan.innerHTML += "<span id=\"" + this.ID + "\">" ; 
			
	for(var i = 1; i <= this.MaxValue; i++){
		if( this.Value >= i )
			imageName = this.ImageOn;
		else
			imageName = this.ImageOff;	
		
		var index = document.images.length;
		
		
		if(this.IsEnabled)
			bgSpan.innerHTML += "<img id=\"" + this.ID + "_img" + i + "\" " + " onclick=\"RatingBar.Click(this, '" + this.ID + "');\" " + " onmouseover=\"RatingBar.Hover(this, '" + this.ID + "');\" " + " onmouseout=\"RatingBar.Refresh(this, '" + this.ID + "');\" " + " style=\"cursor:pointer;\" >";
		else
			bgSpan.innerHTML += "<img id=\"" + this.ID + "_img" + i + "\" " + " onclick=\"RatingBar.Click(this, '" + this.ID + "');\" " + " onmouseover=\"RatingBar.Hover(this, '" + this.ID + "');\" " + " onmouseout=\"RatingBar.Refresh(this, '" + this.ID + "');\" " + " >";
					
		this.Images[i] = document.images[index];
		
		this.Images[i].src = imageName;
		this.Images[i].setAttribute("imageSrc", imageName);
		this.Images[i].setAttribute("imageHover", this.ImageHover);
		this.Images[i].setAttribute("value", i);
		this.Images[i].border = 0;
	}
	
	bgSpan.innerHTML += "</span>" ;
	
	if( this.IsInitialized == false )
		this.Initialize();
}


function ProgressBar(iParentId,sBarType,sNormalImage,sMarkImage,sSelectedImage,iImageCount,cbMarkedFunction,cbSelectedFunction,iBarPossition){

 	var oParentDiv 		= document.getElementById(iParentId);
 	var iOldPossition 	= iBarPossition ;
 		
 	var  iBarWidth=oParentDiv.offsetWidth||oParentDiv.style.width.replace("px",""); 
 	var  iBarHeight=oParentDiv.offsetHeight||oParentDiv.style.height.replace("px",""); 

 	var iProgress   = 0 ; 
 	
 	oParentDiv.innerHTML='';
 	
 	switch(sBarType){
  	case 'display':
   		for( t = 0 ; t < iBarPossition ; t ++ ) 
    		paintImage(t,sMarkImage );    
   		   	
   		for( t = iBarPossition ; t < iImageCount ; t ++ )
    		paintImage(t,sNormalImage);    
   		
  	break; 
 	}
  	
 
 	function paintImage(t,sImageType){
  
  	var oImage = document.createElement('img');
 
  	with(oImage){
   		src=sImageType;
   		with(style){
    		left      = t*oImage.width +'px'
   		};
  	}
  	
  	oParentDiv.appendChild(oImage)  ;   
 	}
}

function changeImage(oMainImage, iCurrentImage, iCurrentImageId, sImgSrc, iWidth, iHeight, iImageNumber, bPage) {
 	
	oImage = new Image();
	oImage.src = sImgSrc;
	document.getElementById(oMainImage).src = oImage.src;
	
	document.getElementById(oMainImage).width = iWidth;
	document.getElementById(oMainImage).height = iHeight;	
	
	for ( a=0; a<iImageNumber; a++ ) {
		sImageId =document.getElementById(oMainImage).id + a;
		if ( !document.getElementById(sImageId) ) {
			break;
		}
		if ( iCurrentImage == a ) {
			if ( bPage ) {
				document.getElementById(sImageId).style.border = "1px solid #93c0ff";
				CurrentImage = iCurrentImageId;
			} else {
				document.getElementById(sImageId).style.border = "1px solid #b50000";
			}
		} else {
			document.getElementById(sImageId).style.border = "1px solid #cfcfcf";
		}
	}
}

function showLatestReviews() {
	var oForm = document.getElementById( 'latest_reviews_form' );
	var sUrl = oForm.action;
	var sPid = oForm.Pid.options[ oForm.Pid.selectedIndex ].value;
	sUrl += sPid != '0' ? '/Pid/' + sPid : '';
	document.location.href=sUrl;
}

function toggleElementVisibility( sID ) {			
	iID = document.getElementById( sID );
	if ( iID.style.display == 'block' ) {				
		iID.style.display = 'none';
	} else {				
		iID.style.display = 'block';
	}
}

function elementVisibilityOn( sID ) {			
	iID = document.getElementById( sID );					
	iID.style.display = 'block';			
}

function elementVisibilityOff( sID ) {				
	iID = document.getElementById( sID );					
	iID.style.display = 'none';	
	
}

function sgcNextTab( iID ) {		
	
	elementVisibilityOff('sgc_tab_' + iID);
	elementVisibilityOn('sgc_tab_' + ( iID + 1 ));
		
	oID = document.getElementById( 'sgc_nav_tab_' + ( iID + 1 ) );	
	oID.className = 'active';
	
	oID = document.getElementById( 'sgc_nav_tab_' + iID );	
	oID.className = '';
				
}

function sgcPreviousTab( iID ) {											
	elementVisibilityOff('sgc_tab_' + iID);
	elementVisibilityOn('sgc_tab_' + ( iID - 1 ));
		
	oID = document.getElementById( 'sgc_nav_tab_' + ( iID - 1 ) );	
	oID.className = 'active';
	
	oID = document.getElementById( 'sgc_nav_tab_' + iID );	
	oID.className = '';
				
}

function sgcSnippetTab( iTabId, iTabCnt ) {
	for ( i = 1; i <= iTabCnt; i++ ) {
		elementVisibilityOff( 'sgc_tab_' + i );
		oID = document.getElementById( 'sgc_nav_tab_' + i );	
		oID.className = '';
	}
	
	elementVisibilityOn( 'sgc_tab_' + iTabId );	
	oID = document.getElementById( 'sgc_nav_tab_' + iTabId );	
	oID.className = 'active';
}

function hoverReviewHeader( hover, what ) {
	if ( hover ) {
		what.className = 'CWReviewsUser CWReviewsUserHover clearfix';
		document.getElementById( 'BingUserShortDescription' ).style.display = 'none';
		document.getElementById( 'BingUserFullDescription' ).style.display = 'block';
		if ( document.getElementById( 'BingUserMoreDetails' ) ) document.getElementById( 'BingUserMoreDetails' ).style.display = 'block';
	} else {
		what.className = 'CWReviewsUser clearfix';
		document.getElementById( 'BingUserShortDescription' ).style.display = 'block';
		document.getElementById( 'BingUserFullDescription' ).style.display = 'none';
		if ( document.getElementById( 'BingUserMoreDetails' ) ) document.getElementById( 'BingUserMoreDetails' ).style.display = 'none';
	}
}


function findPosition( obj ) {
	var iPos = 0;
	
	if ( obj.offsetParent ) {
		do {
			iPos += obj.offsetTop;
		} while ( obj = obj.offsetParent );
	}
	
	return iPos;
}

function alignSkyscraperTopPosition() {
	var ban = document.getElementById('BingNewBanner');
	if ( ban == null ) return;
	var iPos1 = findPosition( ban );
	var obj = document.getElementById('MainRightColumn');
	var iPos2 = findPosition( obj );

	top_position_offset = iPos1 - iPos2;
	
	obj.style.paddingTop = top_position_offset + 'px';
}
