function sc(div)
{
	if (document.getElementById(div).style.display=="none")
	{
		document.getElementById(div).style.display="block";
		if (div=='adv_search')
		{
			document.getElementById('search_btn').innerHTML="Simple Search";
		}
		if (div=='detials_block_1')
		{
			document.getElementById('detials_btn_1').src="images/detials_open.gif";
		}
	} 
	else 
	{ 
		document.getElementById(div).style.display="none";
		if (div=='adv_search')
		{
			document.getElementById('search_btn').innerHTML="Advanced Search";
		}
		if (div=='detials_block_1')
		{
			document.getElementById('detials_btn_1').src="images/detials_close.gif";
		}
	}
}

function printPage(url)
{
	window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=780, height=800")
}

function emailFriend(url)
{
	window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=780, height=800")
}

function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}

	if ( start == -1 ) return null;

	var end = document.cookie.indexOf( ';', len );

	if ( end == -1 ) end = document.cookie.length;

	return unescape( document.cookie.substring( len, end ) );

}

function mailFriend(){
	var loc = document.location.href;
	if((p = loc.lastIndexOf("#")) != -1)
		loc = loc.substr(0, p);
	window.open(loc + "&email=", "_blank", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=370, height=130");	
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
	((expires) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
	((path) ? ';path=' + path : '' ) +
	((domain) ? ';domain=' + domain : '' ) +
	((secure) ? ';secure' : '' );
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function removeBar(){
	setCookie("show_bar", 0);
	closeBar();
}

function closeBar(){
	var bar = document.getElementById("bar_popup");
	document.body.removeChild(bar);
	document.getElementsByTagName('html')[0].style.padding= '0';
}


function allowBar(){
	if(PAGE == "loose_diamonds.html"
       && document.location.href.indexOf("sub") == -1){
		return true;
	}
	
	if(PAGE == "create_ring.html" && document.location.href.indexOf("pid") == -1)
		return true;
		
	if(PAGE == "index.html")
		return true;
	
	if(PAGE == "the_4_c.html")
		return true;
		
	return false;
}

function showBar(){
	if(allowBar()){
	   pos = -70;
	   height = 72;
	   head = 20;
	   setTimeout(startSlide, 2500);
	}else{
		document.getElementById("bar_popup").style.visibility = "hidden";
		document.getElementById("bar_popup").style.display = "none";
	}
}

function startSlide(){
	slidetimeout = setInterval(slideBar, 25);
}

function slideBar(){
	var bar = document.getElementById("bar_popup");
	bar.style.bottom = (pos * 0.9) + "px";
	pos *= 0.9;
	pos = Math.ceil(pos);
	if(pos > -2.5){
		bar.style.bottom = "0px";
		document.getElementsByTagName("html")[0].style.paddingBottom = "50px";
		clearTimeout(slidetimeout);
	}
}

function slideFinish(){
	document.body.parentNode.style.paddingBottom ='0px';
}
	
function pngfix(){
	if(navigator.userAgent.indexOf("MSIE") == -1)
		return;
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   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='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	}
}


window.onload = function(){
	showBar();
	pngfix();
}