
function getCookie(c_name){
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

imgs = 0;
vids = 0;
val = getCookie("images");
if(val!=""){
	tmp = val.split(',');
	for(k=0; k<tmp.length; k++){

		if(tmp[k].indexOf("-1")>0){ imgs++; }
		if(tmp[k].indexOf("-2")>0){ vids++; }

	}
}

document.getElementById("ms_imgs").innerHTML = imgs;
document.getElementById("ms_vids").innerHTML = vids;
if((imgs + vids) > 0 ){ document.getElementById("ms_links").style.display = "block"; }




if(location.href.indexOf("aspx")>0){
	document.getElementById("bread_crumb_blog").innerHTML = "<a href='/pressroom/blog/'>Travels in Virginia Blog</a>";
	document.getElementById("bread_crumb_blog_page").innerHTML = "  > " + rawTitle;
}


function validemail(emailform){
		if(emailform.length>5){
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailform)) {
				return true;
			} else {
				return false;			
			}
		} else {
			return false;		
		}
	return false;
}


function WebForm_DoPostBackWithOptions(obj){

	var msg="";

	if( document.getElementById("_ctl1_name").value.length == 0 ){
		msg = msg + "Name is required.\n";
	}
	
	if( document.getElementById("_ctl1_email").value.length == 0 ){
		msg = msg + "Email is required.\n";
	} else {
		if(!validemail(document.getElementById("_ctl1_email").value)){
			msg = msg + "Email address is not valid.\n";
		}
	}
	
	if( document.getElementById("_ctl1_comment").value.length == 0 ){
		msg = msg + "Comments are required.\n";
	}
	
	if(msg.length>0){
		alert(msg);
		submit = false;
		return false;
	} else {
		submit = true;
		return true;
	}

	return false;
}

/* FIXES THE WEBKIT ISSUES */
jQuery(function($) { 
	if(document.getElementById("commentViewEntry")!=null){
		$("form").each(function(){ $(this).removeAttr("onsubmit").submit(function(){ return WebForm_OnSubmit(); }); });  
	}
});

var m_names = new Array("January", "February", "March", 
"April", "May", "June", "July", "August", "September", 
"October", "November", "December");


$(".commentDateStyle").each(function(i){
		
		var myDate = new Date($(this).text());
		
		// alert(myDate);
		$(this).text(m_names[myDate.getMonth()] + " " + myDate.getDay() + ", " + myDate.getFullYear());
		
		//images_arr.push($(this).attr("src"));
		//$(this).attr("id", "_img_" + i);
});

function WebForm_OnSubmit(){ return submit; }

if(location.href.indexOf("CommentView") > 0){ $("#omg b").text($("#omg b").text() + " *"); }
if( $("#blog_login a").text() == "Sign In" ){ $("#blog_login a").attr("href", "/pressroom/blog/Login.aspx"); }



$(".itemBodyStyle img").each(function(){
	$(this).css("width", 220);
	$(this).css("margin", 10);
});

$(".itemBodyStyle object").each(function(){
	
	w = $(this).attr("width");
	h = $(this).attr("height");
	new_h = parseInt( (h*380) / w );

	$(this).attr("width", 380);
	$(this).attr("height", new_h);
	$(this).css("margin-top", 10);
	$(this).css("margin-bottom", 10);

});

$(".itemBodyStyle embed").each(function(){
	
	w = $(this).attr("width");
	h = $(this).attr("height");
	new_h = parseInt( (h*380) / w );

	$(this).attr("width", 380);
	$(this).attr("height", new_h);
	// $(this).css("margin", 10);

});

/* hides login box */
if( $("#blog_login").html().indexOf("Sign")!=-1 ){ $("#blog_login").css("display", "none"); $("#blog_login").html(" "); }

