window.onload = function(){
	var whichPage = $('homepage');
	if(whichPage){
		checkForImage();
	}
	startPage();
	fixNav();
	assignArticle();
	

}

function checkForImage(){
	var firstImage = $$('.images img');
	var firstImageLeft = $$('#lightview img');
	var rightcolumn = $$('.rightColumn div');
	var theSrc = "";
	var theAlt = "";
	var thePost = $$('div.post');
	var thePostWrap = $$('li.postWrapper');
	var thePost2 = $$('div.post');
	var thePost3 = $$('.post .content');
	var imgsDiv = $$('.post .images');
	var imgSrc = $$('.images img');
	var postImg = new Array();
	var postImg2 = new Array();
	var postTxt = new Array();
	
	// count each post's images
	for(var k=0;k<thePost.length;k++){
		postImg = thePost[k].getElementsByTagName('img');
		postImg2 = thePost2[k].getElementsByTagName('img');
		postTxt = thePost3[k].getElementsByTagName('p')[0];
		
		//alert(postTxt.firstChild.nodeValue);
		// get each post's text
		//var p0 = postTxt[0].firstChild.nodeValue;
		for(var z=0;z<postImg2.length;z++){
			if(postImg2[z].className != "images"){
				postImg2[z].className = 'hideImg';
				postImg2[0].className = 'hideImg1';
			}
			//alert(postImg2[z].className);
		}
		if(postImg.length>0){
			// if the block has ANY images
			//thePost[k].innerHTML= '<div class="images"><img src="' + postImg[0].src + '" /><span class="caption">' + postImg[0].alt + '</span></div>' + '<p>' + postTxt[0].firstChild.nodeValue + '</p>';
			
			var imageElm = document.createElement('div');
			//postTxt.style.clear='both';
			var panelElm = document.createElement('p');
			imageElm.className='images';
			panelElm.className='panelImg';
			//panelElm.style.clear='both';
			var theIMG = imageElm.innerHTML='<img src="' + postImg[0].src + '" /><span class="caption">' + postImg[0].alt + '</span>';
			var thePANEL = panelElm.innerHTML='<img src="' + postImg[0].src + '" /><span class="caption">' + postImg[0].alt + '</span>';
			thePostWrap[k].appendChild(imageElm);
			thePost3[k].insertBefore(panelElm,postTxt);
			
		}else{
			// if the block has NO images
		}
	}
	
	/*for(var i=0;i<firstImageLeft.length;i++){
		//firstImageLeft[0].setAttribute('id','firstImg');
		//firstImage[0].setAttribute('id','firstImg');
		
	}
	for(var j=0;j<rightcolumn.length;j++){
		theSrc = postImg2[0].src;
		theAlt = postImg2[0].alt;
		alert(theSrc);
		rightcolumn[j].innerHTML = '<img src="' + theSrc + '" /><span class="caption">' + theAlt + '</span>';
	}*/
}

function assignArticle()
{
	var catTitle = $$('li.postWrapper h1 a');
	
	for(var i=0;i<catTitle.length;i++)
	{
		catTitle[i].href = null;
		return false;
	}
	
	
	
}

//add new window target attribute for sign up button
function fixNav()
{
  	var theNav = $$('#nav a');
	theNav[0].setAttribute('target','_blank');;
	
}

function startPage()
{
	
	settings = {
          tl: { radius: 10 },
          tr: { radius: 10 },
          bl: { radius: 10 },
          br: { radius: 10 },
          antiAlias: true,
          autoPad: false,
          validTags: ["li"]
      }

      var contentPanelObject = new curvyCorners(settings, "postWrapper");
      contentPanelObject.applyCornersToAll();
	  
	 bottomSettings = {
          tl: false,
          tr: false,
          bl: { radius: 10 },
          br: { radius: 10 },
          antiAlias: true,
          autoPad: false,
          validTags: ["div"]
      }
	  
	var panelCorners = new curvyCorners(bottomSettings, "panelbottom");
	panelCorners.applyCornersToAll();
}