function show_nav_bevels() {
	nav = $('ss_main_nav');
	lasts = nav.select('li.lasty');
	for(var i = 0; i < lasts.length; i++) {
		lasts[i].show();
	}
}



function update_item_descript(event,target) {
		elm = (event.findElement());
		var value = elm.getValue();
		var target = $(target);
		//alert(target);
		target.value = value;
}



function validate_form(e) {


	/*debug
	var all = '';
	for(var i in e) {
		var things = i + '\n';
		all = all + things;
	}
	alert(all);
	*/
		
	form = e.findElement();
	var valid = true;
	//clear all error classnames 
	var divs = form.select('div.err') 
	for(var i = 0; i<divs.length; i++) {
		divs[i].removeClassName('err');
	}
	//get radio inputs
	rad_elms = form.getInputs('radio');	
	//get radio group names 
	var name_hash = new Hash();
	for(var i=0; i<rad_elms.length; i++)  {
		if(rad_elms[i].hasClassName('mandatory')) {
			//get the parent div for err handling this assumes the parent div is 2 steps away from the form field
			var parentdiv = rad_elms[i].ancestors()[1];
			name_hash.set(rad_elms[i].name,parentdiv)	
		}
	}
	name_hash.keys().each(function(name) {
		if(!form.getInputs('radio',name).find(function(radio) { return radio.checked; })) {
			valid = false;
			name_hash.get(name).addClassName('err')
		}
	});
	
	//get text inputs
	
	txt_elms = form.getInputs('text');
	for(var i=0; i<txt_elms.length; i++) {
		cur = txt_elms[i];
		if(cur.hasClassName('mandatory')) {
			if(cur.hasClassName('email')) {
				var email_exp = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				var value = cur.getValue();
				if(!value.match(email_exp)) {
					valid = false;
					var parentdiv = cur.ancestors()[0];
					parentdiv.addClassName('err');
				}
			} else {
					if(!cur.present()) {
						valid = false;
						curr.addClassName('err');
					} else {
						alert(cur.getValue());
					}
			}
		} else {
			continue;
		}
		
	}
	
	if(!valid) {
		e.stop();
		/*return false;*/
	}

}

/*
     Initialize and render the MenuBar when its elements are ready 
     to be scripted.
*/

YAHOO.util.Event.onContentReady("ss_main_nav", function () {


	/*show beveled corners if the browser is not ie */
	ua = YAHOO.env.ua;
	if(!ua.ie) {
	
		//show beveled edges
		show_nav_bevels();
	
	}




    /*
         Instantiate a MenuBar:  The first argument passed to the 
         constructor is the id of the element in the page 
         representing the MenuBar; the second is an object literal 
         of configuration properties.
    */

    var oMenuBar = new YAHOO.widget.MenuBar("ss_main_nav", { 
                                                autosubmenudisplay: true, 
                                                hidedelay: 750, 
                                                lazyload: true });

    /*
         Call the "render" method with no arguments since the 
         markup for this MenuBar instance is already exists in 
         the page.
    */

    oMenuBar.render();

});

//jankfest
function ss_clipload_init(clip_id,info,chrome,size) {
		return function (e) {
			//load video into homepage video
			var vidcont = $('ytwin');
			var request = '/pages/sstv_load_clip/id:' + clip_id + '/info:' + info + '/width:' + size + '/chrome:' + chrome;			
			new Ajax.Updater(vidcont,request,{evalScripts:true}); 
		}		
}


function  onYouTubePlayerReady(playerId) {
				 ytplayer = document.getElementById("myytplayer");
}
      	
function loadYouTubeClip(id,height,width) {
	if(typeof(ytplayer) != 'undefined') {
		//ytplayer.setSize(width, height);
      ytplayer.setVolume(25);
		//ytplayer.loadVideoById(id);
		ytplayer.cueVideoById(id);
		clearInterval(readyTest);
		ytplayer.pauseVideo();
		//add the listener to the play link
		//$('playlink').observe('click',function(){ytplayer.playVideo();},false);
	} 
}




