function truecare(myvar){
window.location.href = "http://www.truedentaldiscounts.com/" + myvar;
}
//#####################################################################
var speed = 1;

function init() {
    var a = document.getElementById("marquee_replacement");
    if(a){
    a.style.overflow = 'hidden';
    scrollFromBottom()
    }
}
var go = 0;
var timeout = '';

function scrollFromBottom() {
    clearTimeout(timeout);
    var a = document.getElementById("marquee_replacement");
    if (a.scrollTop >= a.scrollHeight - 320) {
        a.scrollTop = 0
    };
    a.scrollTop = a.scrollTop + speed;
    if (go == 0) {
        timeout = setTimeout("scrollFromBottom()", 50)
    }
}
function stop() {
    go = 1
}
function startit() {
    go = 0;
    scrollFromBottom()
}
//########################################################################
function lightbox(a, b) {
    document.getElementById(a).style.display = (b)
}
//########################################################################
function checkForm(form){
	var email = document.getElementById('email').value;
	var phone = document.getElementById('phone').value;
	var name = document.getElementById('name').value;
	if(name != ''){
		if(email.match(/^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i)){
			if(phone.match(/^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/)){
			return true;
			}else{
			alert("Please enter a valid phone number.");
			return false;
			}
		} else{
		alert("Please enter a Valid Email address.");
		return false;
		}
	} else{
	alert("Please enter your name.")
	return false;
	}
}
//#########################################################################
function iniSlideShow(slides){
p = setTimeout(function(){slideShow(1,slides)}, 5000);
}
function slideShow(id, slides){
	if (id >= slides){
	next = 1;
	}
	else {
	next = id + 1;
	}

	for (var i=10; i>=-1; i--){
	counter = 11 - i;
	t = setTimeout('fadeOut('+i+',' + id + ')',55*counter);
	}
	for (var i=0;i<11;i++){
	c = setTimeout('fadeIn('+i+',' + next + ')',55*i);
	}
clearTimeout(t);
clearTimeout(c);
p = setTimeout("slideShow(" + next +"," + slides +")", 5000);
}
function fadeIn(value, id){	
document.getElementById("s"+id).style.opacity = value/10;
document.getElementById("s"+id).style.filter = 'alpha(opacity=' + value * 10 + ')';
}
function fadeOut(value, id){
document.getElementById("s"+id).style.opacity = value/10;
document.getElementById("s"+id).style.filter = 'alpha(opacity=' + value * 10 + ')';
}
//#########################################################################
function Set_Cookie( name, value, expires, path, domain, secure ){
//Set_Cookie( 'test', 'none', '', '/', '', '' );
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
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() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	var i = 0;
	for ( i = 0; i < a_all_cookies.length; i++ ){
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name ){
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 ){
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ){
		return null;
	}
}
//---------------------------------------------------------------------------------------------------
function realLightbox(popup,style){
    if(style == 'display'){
var lbbg = document.createElement('div');
var mydivheight = document.documentElement.scrollHeight;
var lbbgStyle = 'background: black; height:'+mydivheight+'px ; width: 100%; position: absolute; top: 0; left: 0; opacity: .5; z-index: 1; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"';
lbbg.setAttribute('style', lbbgStyle);
lbbg.setAttribute('id','lbbg');
var closeLb = 'realLightbox(\''+popup+'\',\'hide\');';
lbbg.setAttribute('onclick', closeLb);
document.body.appendChild(lbbg);
var popup = document.getElementById(popup)
popup.style.display = 'block';
    if (navigator.appName == "Microsoft Internet Explorer"){
    lightbtop = document.documentElement.scrollTop + 50;
    lightbtop = lightbtop + 'px';
    }
    else{
    lightbtop = window.pageYOffset + 50;
    lightbtop = lightbtop + 'px';
    }
popup.style.top = lightbtop;

    } else if (style == 'hide'){
lbbg = document.getElementById('lbbg');
document.body.removeChild(lbbg);
document.getElementById(popup).style.display = 'none';
    }

}
//--------------------------------------------------------------------------------------------
function changeParent(url){
    document.location = url;
}

