jQuery(document).ready(function(){
	reaset_width();
	fn_slide();
});

function reaset_width(){//alert(1)
							$('#fullBodyIndex').css('width', $('#wrapMain').width());
							$('#fullBodyAuthor').css('width', $('#wrapMain').width());
							$('#fullBodySpeaker').css('width', $('#wrapMain').width());
							
							/*if($('#mainBodyIndex').height()){
								$('#fullBodyIndex').css('height', ($('#mainBodyIndex').height())+($('#footer').height()));
							}
							else if($('#mainBodyAuthor').height()){
								$('#fullBodyAuthor').css('height', ($('#mainBodyAuthor').height())+($('#footer').height()));
							}
							else if($('#mainBodySpeaker').height()){
								$('#fullBodySpeaker').css('height', ($('#mainBodySpeaker').height())+($('#footer').height()));
							}*/
							
							window.setTimeout('reaset_width()',0);
}
function fn_slide(){
	$('#wrapMain').cycle({ 
    fx:     'turnUp,turnDown', 
		randomizeEffects: false, 
    timeout: 0, 
    //delay:  -1000,
		speedIn: 1100,
		speedOut: 1000,
		//autostop: 1,
		pager: '.pager',
		after: function(){
							//alert('mainBodyIndex: ' + $('#mainBodyIndex').height()+"\n"+'mainBodyAuthor: ' + $('#mainBodyAuthor').height()+"\n"+'mainBodySpeaker: ' + $('#mainBodySpeaker').height()+"\n"+'footer: ' + $('#footer').height());
							if($('#mainBodyIndex').height()){
								$('#fullBodyIndex').css('height', ($('#mainBodyIndex').height())+($('#footer').height()));
							}
							else if($('#mainBodyAuthor').height()){
								$('#fullBodyAuthor').css('height', ($('#mainBodyAuthor').height())+($('#footer').height()));
							}
							else if($('#mainBodySpeaker').height()){
								$('#fullBodySpeaker').css('height', ($('#mainBodySpeaker').height())+($('#footer').height()));
							}
						},
		pagerClick: function(idx, slide) { 
								},
		pagerAnchorBuilder: function(idx, slide) { 
				if(idx == 0){
					return '<img src="'+$('#web_root').val()+'images/back-to-main.png" alt="Back To Main"  id="index_extra" />'
				}
				if(idx == 1){
					return '<li id="slide_link_1"><img src="'+$('#web_root').val()+'images/btn-1-author-writer.png" alt="Author & Writer" title="Author & Writer" /></li>';
				}
				else if(idx == 2){
					return '<li id="slide_link_2"><img src="'+$('#web_root').val()+'images/btn-3-professional-speaker.png" alt="Professional Speaker" title="Professional Speaker" /></li>';
				}
    }
 });
	 $('#nav #index_extra').css('display', 'none');
	 $('#slide_link_1').after('<li><a href="'+$('#ext_link_1').val()+'" target="_blank"><img src="'+$('#web_root').val()+'images/btn-2.png" alt="ADR Services" title="ADR Services" /></a></li>');
	 $('#slide_link_2').after('<li><a href="'+$('#ext_link_2').val()+'" target="_blank"><img src="'+$('#web_root').val()+'images/btn-4.png" alt="She Negotiates" title="She Negotiates" /></a></li>');
	 $('span.pager #slide_link_1').css('display', 'none');
	 $('span.pager #slide_link_2').css('display', 'none');
}
