 var newMusicArray;
 var newsArray;
 var offset=0;
 var customerInfo;
 var customerLocation;
 
 function initLibraryIndexPage(){
 
 
     checkLoginCookie(); 
     setCustomerLocation( customerLocation );
    
      jQuery.noConflict();                       
      jQuery(document).ready( function(){
     
      
       jQuery( "#header" ).addClass("ui-corner-top");
      
       jQuery( "#pages li.current_page_item").addClass("ui-state-active");
      
       
       jQuery("#myMap").css({"height":"150px"} ); 
       jQuery("#header").addClass("ui-widget-content");
       jQuery("#header").animate({"height":"350px"},2000 );
       
         this.customerInfo     = getCustomerInfo();
         this.customerLocation = getCustomerLocation();
        
          
          jQuery("#customerInfo").css(  {"border":"1px solid #ffffff","margin-top":"60px","font-size":"10pt","font-weight":"600"} );
          jQuery("#customerInfo").addClass("ui-widget-header");
          jQuery("#customerName").css(  {"height":"30px"}  );
          jQuery("#customerName").children().remove();
	  jQuery("#customerName").append("<div>Welcome "+ customerInfo.title + " "+ 
	                                                  customerInfo.firstName + " " +
	                                                  customerInfo.lastName+ "</div> " );
	 
          jQuery("#myMap").addClass("ui-widget-content");
          jQuery("#customerIP").append("<p>Your IP: "+  customerLocation.ip +"</p>");
	 
	  
         if( customerInfo.lastName   == 'User'){
         
             
            
          jQuery("#loginButton").append("<button name=\"login\">Login</button>&nbsp;<button name=\"register\"><a href=\"#\">Register</a></button>"  ); 
          jQuery("#loginButton button").addClass("ui-state-default");
          jQuery("#loginButton button").hover( function(){  jQuery(this).addClass("ui-state-hover");      },
	  		        	       function(){  jQuery(this).removeClass("ui-state-hover");     }   );//end hover
		 	                                                 
             jQuery("#loginButton button[name='login']").click( function(){  checkIfIsLogged(); } ); //end click
             jQuery("#loginButton button[name='register']").click( function(){  registerNewCustomer(); } ); //end click
           
          }//end if
          
         else{
         
           jQuery("#loginButton").append("<button name=\"login\">Logout</button>"  ); 
	   jQuery("#loginButton button").addClass("ui-state-defaut");
	   jQuery("#loginButton button").hover( function(){  jQuery(this).addClass("ui-state-hover");      },
	  	  		        	function(){  jQuery(this).removeClass("ui-state-hover");     }   );//end hover
		 	                              
         
	  jQuery("#loginButton button").click( function(){  logout(); } );//end click
         
          
		 	
         
          }//end else
           
          
        
      printDancesMenu(); 
      createContentMenu();
      loadIPGeo();
	 
	  
        
 
 	} );//end document ready
 
 
           
 }//end initPage 
 
 

 function setMyIP(ip){
 
        
 	  this.customerLocation =  { ip:ip,
	                             country :"USA",
	                             city:"South Orange, NJ", 
	                             latitude:"40.749",
                                     longitude:"-74.2616" } ;
         
  
  }
  
  
  
  function loadIPGeo(){
  
  
  
   
    
   var pageUrl="http://www.ballroomlibrary.com/php/proxyIP.php?ip="+this.customerLocation.ip + "&position=true";
   
  	 
      		
  			jQuery.ajax({
  			
  			  
  			  url: pageUrl,
  			  cache: false,
  			  async: true,
  			
  			  success: function( htmlText, success ){
  			    
  			   
  			     
  			     if( htmlText.indexOf("500 Internal Server Error")!=-1 ){
  			     
  			     
  			       
  			          jQuery("#customerIP").append("<div id=\"customerIP\">Unknown City</div>");
			       	                               
			       	      
  			         customerLocation =  { ip:getCustomerLocation().ip,
			       			       country :"USA",
			       			       city:"South Orange, NJ", 
			       			       latitude:"40.749",
			       			       longitude:"-74.2616" } ;
         
			       		       	                      
                                  setCustomerLocation( customerLocation );                     
                                                                	     
  			      			     
  			     }
  			     else if( htmlText.indexOf("Unknown Country") ){
  			     
  			           
  			             jQuery("#customerIP").append("<div id=\"customerIP\">Unknown City</div>");
				      customerLocation =  { ip:getCustomerLocation().ip,
				                            country :"USA",
				  			    city:"South Orange, NJ", 
				  			    latitude:"40.749",
				  			    longitude:"-74.2616" } ;
				           
				  			       		       	                      
                                  setCustomerLocation( customerLocation );              
  			     } 
  			     else{
  			     
  			        var country = htmlText.split("Country:" )[1].split("\n")[0];
  			       	var city    = htmlText.split("City:" )[1].split("\n")[0];
  			       	var latitude = htmlText.split("Latitude:")[1].split("\n")[0];
  			       	var longitude = htmlText.split("Longitude:")[1].split("\n")[0];
  			       
  			       
  			        jQuery("#customerIP").append("<div id=\"customerIP\">"+
  			                                     country+", "+
  			                                     city +"</div>");
  			                                                            
  			       
  			    
  			       	customerLocation = { ip:getCustomerLocation().ip,
  			       	                     country :country,
                                                     city:city, 
                                                     latitude:latitude,
                                                     longitude:longitude };
                                                     
                                setCustomerLocation( customerLocation );                     
                                                                                     
			                                   
			     }//end else
  			    
           
  			    
  			  },//end success.
  			  error: function (XMLHttpRequest, textStatus, errorThrown) {
  			  
  			              jQuery("#customerIP").append("<div id=\"customerIP\">Unknown City</div>");
				     			                                                         
  			         
  			      	   customerLocation =  { ip:getCustomerLocation().ip,
				  			       			       country :"USA",
				  			       			       city:"South Orange, NJ", 
				  			       			       latitude:"40.749",
				  			       			       longitude:"-74.2616" } ;
				           
				  			       				 					                             country :"USA",
				  			       	                      
                                  setCustomerLocation( customerLocation );    
				
  			    
                            }//end error
  			  
  			  
  			  
  		});//rnd ajax

  
   
     
 }//end looadIPGEO
 
 
 
 
  function getMyIP(){
  
    return this.ip;
  
  }
 
 
 function getUserName(){
 
 
  this.userName;
 
 }
 
 
 function getSubscription(){
 
 
  this.subscription;
 
 
 }
 
 
 function showMoreIP(){
 
 
   jQuery("#customerIP").append("<iframe src=\"http://www.ip2location.com/ib1/\" "+
                                       "        width=\"402\" height=\"84\" scrolling=\"no\" "+
                                    "frameborder=\"0\" ></iframe>");
 
 
 
 
 }
 
 
function showGoogleMap( ){

  jQuery("#myMap").show(); 
     
}
    
 

 
 function loadGoogleMap() {

      
  
         var map = new google.maps.Map2(document.getElementById("myMap"));
         var zoom = 13;
         map.setCenter(new google.maps.LatLng( this.customerLocation.latitude , this.customerLocation.longitude ),   zoom );
	 var mapControl = new google.maps.SmallMapControl();
         map.addControl(mapControl);


}//end map


function checkLoginCookie(){

 
  var sessionInfoString  = getCookie('sessionInfo');
 
  
   var result = false;
   
  
    if ( sessionInfoString !=null && sessionInfoString != ""){
    
    
        
        var customerInfoArray = unescape( sessionInfoString ).split("_");
        
        setCustomerInfo( {   id:customerInfoArray[0],
                            title:customerInfoArray[1],
	                    lastName:customerInfoArray[2],
	                    firstName:customerInfoArray[3],
	                    email:customerInfoArray[4],
	                    password:customerInfoArray[5],
	                    loginId:customerInfoArray[6]   } );
	        
	
	return true;
	         
	                    

        
    }
 
    else{
 
          
        setCustomerInfo( {   id:"peter.ingris@ballroomradio.com",
                             title:"",
                             firstName:"Anonymous",
	                     lastName:"User",
	                     
	                     email:"",
	                     password:"",
	                     loginId:""   } );  
  	return false; 
  
  
  }//end else
  
  return false;
  
}//end function





function setCookie( loginId ){
	 
	    var date = new Date();
	    var minutes = date.getMinutes();
	    var newMinutes = minutes+5
	     
	       
	     this.customerInfo.loginId = loginId;
	      var customerInfoStr = customerInfo.id+"_"+
	                            customerInfo.title+"_"+
	                            customerInfo.lastName+"_"+
	                            customerInfo.firstName+"_"+
	                            customerInfo.email+"_"+
	                            customerInfo.password+"_"+
                                    loginId;
                                  
	     document.cookie="sessionInfo="+escape( customerInfoStr )+";domain=ballroomlibrary.com;path=/;expires=";
	  
	   
	   
	   
 }//end setLoginCookie



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));
	     			}
	     			else{
	     			
	     			   return "";
	     			}
	   	
	   	
	   	}//end if
	   	
	   	else{
	   	
	   	
	      	   return "";
	      	   
	      	 }
}//end get
	 




function setCustomerLocation( cl ){


   this.customerLocation = cl;


}
 
 
 function getCustomerLocation(){
 
 
   return this.customerLocation;
 
 
}
 
 
 
 function setCustomerInfo( ci ){
 
 
 
   this.customerInfo = ci;
 
 
 }
 
 
 
 
function getCustomerInfo(){


  return this.customerInfo;


}



function getRandomIndex( maxNumber ){



  index = Math.round( Math.random()*maxNumber ) ;
  return index;
       


}




function addAlbumToMusicArray( albumObject ){

   
   this.newMusicArray.push( albumObject );


}









function goLocation( location, googleKeyword){

	
	var newWindow = window.open();
	    newWindow.document.write("<html><head><title>"+googleKeyword+"+</title></head>"+
	                                "<frameset rows=\"200,*\" style=\"border:1px solid orange\" frameborder=\"no\">"+
	                                "<frame name=\""+googleKeyword+"\" src=\"http://www.ballroomLibrary.com/googleAdds.html\">"+
	                                "<frame name=\"main\" src=\""+location +"\">"+
	                                "</frameset>"+
	                              "</html>");
	  
  
	  	jQuery("#newsDialog").dialog('close');


}


function goBlog(){

 var newWindow = window.open();
     newWindow.location = "http://ballroomRadio.com/blog/online_help";
}

function goHome(){
     location="index.html"
}


function goRegister(){

     location="http://www.ballroomlibrary.com/registerFreeUSListenerBeta.html"
}



function searchWord( keyword ){

        var locUrl = "http://www.google.com/custom?domains=designers.ballroomdress.us&q="+keyword+"&sa=Search&sitesearch=&client=pub-3837358447107106&forid=1&ie=ISO-8859-1&oe=ISO-8859-1&safe=active&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A1%3B&hl=en";

   		newWindow=window.open();
   		newWindow.location=locUrl ;
 }
 
 
/******************************************************************************************************************/
//LOGIN

function checkIfIsLogged(){



  
 var lastName = getCustomerInfo().lastName;
      if( getCustomerInfo().lastName != 'User'){
      
            
          jQuery("#customerIP").children().remove(); 
          jQuery("#customerIP").append("<p>Your IP: "+  customerLocation.ip +"</p>"+
	  	                       "<p><h2><a href=\"javascript:logout()\">Logout</a></h2></p>" +
	                               "<div><h2><a href=\"javascript:showGoogleMap()\">map</a></h2></div>" ); 
	                                      
	                                      
	                      
          
      
       }//end if
      
       else {
       
             
               
          showLibraryLogin();
       
       
       }//end else
     







}//en dfunction




function showLibraryLogin(){
      
       jQuery('#loginForm').children().remove();
       jQuery('#loginForm').append( printLoginFormDialog() );
       jQuery("#loginForm").css( {      "width":"550px",
                                        "height":"350px"   } );
                                        
	jQuery("#loginFormDialog").css({"margin":"10px",
	                                "width":"300px",
	                                "height":"260px",
	                                 "border":"2px solid #292929",
                                         "font-size":"12pt"         } );
                                        
	jQuery("#loginFormDialog input").css({"margin-left":"20px",
	                                      "height":"30px",
	                                      "color":"#000000",
	                                      "border":"1px solid #666666",
	                                      "font-size":"14pt",
	                                      "font-weight":"700"   } );
	
        jQuery("#loginFormDialog label").css({ "margin":"10px", "font-size":"8pt" }  );//end click  
        
   	jQuery("#loginFormDialog button").css({"margin-left":"10px",
   	                                       "height":"30px",
   	                                       "width":"100px",
   	                                       "border":"1px solid #666666",
   	                                        "font-size":"10pt"     } );
   	 
   	 
   	 
   	
     
     //initializing	                                        
   	jQuery("#loginFormDialog button[name='submit']").click( function(){ login();  }  );//end click 
   	jQuery("#loginFormDialog button[name='submit']").hover( function(){  jQuery(this).addClass("ui-state-hover")   },
	                                                        function(){  jQuery(this).removeClass("ui-state-hover") })  ;


        jQuery("#loginFormDialog button[name='reset']").click(  function(){  resetLoginForm();  }  );//end click   
        jQuery("#loginFormDialog button[name='reset']").hover( function(){  jQuery(this).addClass("ui-state-hover")   },
	                                                        function(){  jQuery(this).removeClass("ui-state-hover") }) ;

	jQuery("#loginForm").dialog({'modal':true,
	                              close: function(){ document.location.href="/" },
	                             'width':'360px',
	                             'title':'BallroomLibrary.com Login'}); 
	  
	 
   }//end show loginForm Dialog










function login(){



 var userName = jQuery(	"#loginFormDialog input[name='username']").val();
 var password = jQuery(	"#loginFormDialog input[name='password']").val();
 
 var libraryUrl = escape("http://www.ballroomlibrary.com:8080/DS4YouInfoServer/FindCustomerServlet?userName="+ userName+"&password=" + password);
 var proxy="/php/proxy.php?url=" + libraryUrl;
 	
        jQuery.ajax({
 					  			
 			 url: proxy,
 			 cache: false,
 			 async: false,
 			 success: function( text, success ){
 			  
 			       if(  isCustomerInfoVerified( text ) ){
 			        
 			          
 			           registerLogin();
 			          
 			        } 
 			        else{
 			         
 			            jQuery("#loginFormError").children().remove();
				        jQuery("#loginFormError").append("<p style=\"font-size:12pt;color:red\">Wrong Username/Password!</p>");
 			             
 			         
 			         }
 			         
 					  			    
 			 },//end success.
 			  error: function (XMLHttpRequest, textStatus, errorThrown) {
 					  			  
 			          alert("Login failed!");
 			          
 					  			    
 			  }//error
 					  			  
 					  			  
 					  			  
 	});//rnd ajax
 	                
 	

}//end login



function logout(){

  
  if ( getCookie( "sessionInfo" ) ){
  
  
      setCustomerInfo( {   id:"",
                           title:"",
                           firstName:"Anonymous",
            	           lastName:"User",
            	           email:"",
            	           password:"",
	                       loginId:""   } );
	                   
      jQuery("#customerName").children().remove();
      jQuery("#customerName").append("<div>Welcome "+ customerInfo.title + " "+ 
	                                              customerInfo.firstName + " " +
	                                              customerInfo.lastName+ "</div> " );   
	                                              
     
      document.cookie = "sessionInfo=;path=/;domain=ballroomLibrary.com;expires=Thu, 01-Jan-1970 00:00:01 GMT";
      alert("you have been logged out!");
      document.location.href="/";
        
      
  }//end if



}//logout 






function printLoginFormDialog(){


 var formHTML=
               "  <div id=\"loginFormError\" style=\"height:30px\"></div>"+
               "  <div id=\"loginFormDialog\">"+
               "  <img src=\"/wordpress/wp-content/uploads/2010/02/favicon.ico\" alt=\"Dancesprot4you logo\" "+
               "       style=\"border:2px solid #292929;height:30px; margin:10px;\"/>customer Login:"+
               
               "  <table>"+
               "  <tr><td><label>Username:</label></td></tr>"+
               "  <tr><td><input type=\"text\" name=\"username\" maxlength=\"40\" size=\"20\"></td></tr>"+
               "  <tr><td><label>Password:</label></td></tr>"+
               "  <tr><td><input type=\"password\" name=\"password\" maxlength=\"20\" size=\"20\"></td></tr>"+
               "  </table>"+
               "  <table>"+
               "  <tr>"+
               "  <td><button name=\"submit\">Send</button> <button name=\"reset\">Reset</button></td>"+
               "  </tr>"+
               "  </table>"+
               "  </div>"; //dialog

 return formHTML;


}




function isCustomerInfoVerified( responseText ){

	
  
   if( jQuery(responseText).find("userName") != null ){
   
   
          
        var customerInfo = new Object();
            customerInfo.id = jQuery(responseText).find("userName").text();
            customerInfo.lastName = jQuery(responseText).find("lastName").text();
            customerInfo.firstName = jQuery(responseText).find("firstName").text();
            customerInfo.email = jQuery(responseText).find("email").text();
            customerInfo.password = jQuery(responseText).find("password").text();
            customerInfo.title = jQuery(responseText).find("title").text();
   
            setCustomerInfo( customerInfo );
           
    		if( jQuery(	"#loginFormDialog input[name='password']").val() == customerInfo.password  ){
    
    			   
    			    jQuery("#loginForm").animate({'opacity':'0'}, 1000 );//dialog('close');
                    
                    return true;
        
    		}//end else
    		else{
    		
    		
    		    return false;
    		
    		}
    		
    		
    }// end if
    else{
     
        return false;
    }
    
    

}//end verifycustomerInfo




function resetLoginForm(){  

			jQuery(	"#loginFormDialog input[name='password']").val(""); 
            jQuery( "#loginFormDialog input[name='username']" ).val("");  
                       
                       
}//end reset



function resetRegistrationForm(){  

	
    
	jQuery(	"#registrationFormDialog input[name='firstname']").val(""); 
    jQuery( "#registrationFormDialog input[name='lastname']" ).val("");  
    jQuery(	"#registrationFormDialog input[name='password']").val(""); 
    jQuery( "#registrationFormDialog input[name='username']" ).val("");  
    
    
               
               
}//end reset
                       
function registerNewCustomer(){

	showLibraryRegistration();
	
}



function printRegistrationFormDialog(){
	
	
		 var formHTML=
		               "  <div id=\"regitrationFormError\" style=\"height:30px\"></div>"+
		               "  <div id=\"registrationFormDialog\">"+
		               "  <img src=\"/wordpress/wp-content/uploads/2010/02/favicon.ico\" alt=\"Dancesport4you logo\" "+
		               "       style=\"border:2px solid #292929;height:30px; margin:10px;\"/>BallroomLibrary.com:"+
		               
		               "  <table>"+
		               "  <tr><td><label>Title:</label></td><tr>"+
		               "  <tr><td><select>"+
		               "          <option value=\"Mr.\" SELECTED>Mr.</option>"+
		               "          <option value=\"Mrs.\"        >Mrs.</option>"+
		               "          <option value=\"Miss\"        >Miss</option>"+
		               "          </select>"+
		               "  </td></tr>"+
		               "  <tr><td><label>First Name:</label></td><tr>"+
		               "  <tr><td><input type=\"text\" name=\"firstname\" maxlength=\"40\" size=\"20\"></td></tr>"+
		               "  <tr><td><label>Last Name:</label></td><tr>"+
		               " <tr><td><input type=\"text\" name=\"lastname\" maxlength=\"40\" size=\"20\"></td></tr>"+
		               " </tr>"+
                       "  <tr><td><label>Username/Email:</label></td></tr>"+
		               "  <tr><td><input type=\"text\" name=\"username\" maxlength=\"60\" size=\"20\"></td></tr>"+
		               "  <tr><td><label>Password:</label></td></tr>"+
		               "  <tr><td><input type=\"password\" name=\"password\" maxlength=\"20\" size=\"20\"></td></tr>"+
		               "  </table>"+
		               "  <table>"+
		               "  <tr>"+
		               "  <td><button name=\"submit\">Send</button> <button name=\"reset\">Reset</button></td>"+
		               "  </tr>"+
		               "  </table>"+
		               "  </div>"; //dialog

		 return formHTML;

}//printRegistrationForm


function showLibraryRegistration(){
    
    jQuery('#registrationForm').children().remove();
    jQuery('#registrationForm').append( printRegistrationFormDialog() );
    jQuery("#registrationForm").css( {      "width":"550px",
                                            "height":"400px"   } );
                                     
	jQuery("#registrationFormDialog").css({"margin":"10px",
	                                "width":"300px",
	                                "height":"300px",
	                                 "border":"2px solid #292929",
                                      "font-size":"12pt"         } );
                                     
	jQuery("#registrattionFormDialog input").css({"margin-left":"20px",
	                                      "height":"30px",
	                                      "color":"#000000",
	                                      "border":"1px solid #666666",
	                                      "font-size":"14pt",
	                                      "font-weight":"700"   } );
	
     jQuery("#registrationFormDialog label").css({ "margin":"10px", "font-size":"8pt" }  );//end click  
     
	jQuery("#registrationFormDialog button").css({"margin-left":"10px",
	                                       "height":"30px",
	                                       "width":"100px",
	                                       "border":"1px solid #666666",
	                                        "font-size":"10pt"     } );
	 
	 
	 
	
  
  //initializing	                                        
	jQuery("#registrationFormDialog button[name='submit']").click( function(){ submitRegistration();  }  );//end click 
	jQuery("#registrationFormDialog button[name='submit']").hover( function(){  jQuery(this).addClass("ui-state-hover")   },
	                                                        function(){  jQuery(this).removeClass("ui-state-hover") })  ;


     jQuery("#registrationFormDialog button[name='reset']").click(  function(){  resetRegistrationForm();  }  );//end click   
     jQuery("#registrationFormDialog button[name='reset']").hover( function(){  jQuery(this).addClass("ui-state-hover")   },
	                                                        function(){  jQuery(this).removeClass("ui-state-hover") }) ;

	jQuery("#registrationForm").dialog({'modal':true,
	                              close: function(){ document.location.href="/" },
	                             'width':'360px',
	                             'title':'BallroomLibrary.com Registration'}); 
	  
	 
}//end show loginForm Dialog






function submitRegistration(){
	
	var title = jQuery(	"#registrationFormDialog select").val();
	var firstName = jQuery(	"#registrationFormDialog input[name='firstname']").val();
	 var lastName = jQuery(	"#registrationFormDialog input[name='lastname']").val();
	 var userName = jQuery(	"#registrationFormDialog input[name='username']").val();
	 var password = jQuery(	"#registrationFormDialog input[name='password']").val();
	 
	/* String subscriberUserName=req.getParameter("userName");
		String subscriberTitle=req.getParameter("title");
		//String listenerPassword=req.getParameter("password");
		String subscriberFirstName = req.getParameter("firstName");
		String subscriberLastName = req.getParameter("lastName");
		String subscriberSubscribtion = req.getParameter("subscribtion");*/
	 var libraryUrl = escape("http://www.ballroomlibrary.com:8080/DS4YouInfoServer/RegisterDS4YouUserEmailServlet?title="+title+
			                                                                                                      "&firstName="+firstName+
			                                                                                                      "&lastName="+lastName+
			                                                                                                      "&userName="+ userName+
			                                                                                                      "&subscribtion=library"+
			                                                                                                      "&password=" + password);
	 var proxy="/php/proxy.php?url=" + libraryUrl;
	 	
	        jQuery.ajax({
	 					  			
	 			 url: proxy,
	 			 cache: false,
	 			 async: false,
	 			 success: function( text, success ){
	 			  
	 			     
	        		var title = jQuery(text).find("title").text();
	        		var lastName = jQuery(text).find("lastName").text();
	        		var email = jQuery(text).find("email").text();
	 			     alert( "Thank you for registration "+ title + " "+lastName+"\n"+
	 			    		 "Activation link was sent to your mailbox: "+ email );
	 			    jQuery("#registrationForm").dialog('close');
	 			  
	 			         
	 					  			    
	 			 },//end success.
	 			  error: function (XMLHttpRequest, textStatus, errorThrown) {
	 					  			  
	 			          alert("Login failed!");
	 			          
	 					  			    
	 			  }
	 					  			  
	 					  			  
	 					  			  
	 	});//rnd ajax
	 	                
	 	

}//end submitRegistration
                     

function registerLogin(){


  
      var libraryUrl =escape( "http://www.ballroomlibrary.com:8080/DS4YouInfoServer/LoginVerifiedUserServlet?userName="+ this.customerInfo.id+ "&status=login&id=0" );
      var proxyUrl    = "php/proxy.php?url="+ libraryUrl; 
      	
     
      	
             jQuery.ajax({
      					  			
      			 url: proxyUrl,
      			 cache: false,
      			 async: false,
      			 success: function( text ){
      			  
      			    
      			     var result = jQuery(text).find("status").text();
      			     
      			     
      			     if(  result=="ok" ){
      			     
      			    
      			              
      			               isLoginOK(text, result );
      			          
      			              
 			      }//end if
      			      else{
      			        
      			            alert("Authentication failed!");
      			        
      			      }
      			       
      			         
      					  			    
      			 },//end success.
      			 error: function (XMLHttpRequest, textStatus, errorThrown) {
      					  			  
      			          alert("Authentication failed!");
      					  			    
      			  }//error
      					  			  
      					  			  
      					  			  
      	});//rnd ajax
      	                
     

} //end function





function isLoginOK( text, loginStatus){



	 
	 jQuery("#loginButton").children().remove();
	 jQuery("#loginButton").append("<button>Logout</button>"  ); 
	 jQuery("#loginButton button").addClass("ui-state-defaut");
	jQuery("#loginButton button").hover( function(){  jQuery(this).addClass("ui-state-hover");      },
		       	  		     function(){  jQuery(this).removeClass("ui-state-hover");     }   );//end hover
		       	  		     
	jQuery("#loginButton button").click( function(){  logout(); } ); //end click
					                     
	         
	      			               
	      			               if( loginStatus == "ok" ){
	      			               
	      			                  
	      			                 var loginId = jQuery(text).find("id").text();
	      			                 
	      			                     setCookie( loginId );
	      			                     checkLoginCookie();
	      			                     jQuery("#customerName").children().remove();
						     jQuery("#customerName").append("<div>Welcome "+ customerInfo.title + " "+ 
						     	                                              customerInfo.firstName + " " +
						     	                                              customerInfo.lastName+ "</div> " );   
		                                              
	      			                     
	      			                     
	      			                     
	      			                     jQuery("#loginForm").dialog('close');
	      			                 
	      			                }//end if
	      			                else if(loginStatus == "extendLogin" ){
	      			                
	      			                  var loginId = jQuery(text).find("id").text();
						  setCookie( loginId );
						  checkLoginCookie();
						  jQuery("#customerName").children().remove();
						  jQuery("#customerName").append("<div>Welcome "+ customerInfo.title + " "+ 
						  	                                          customerInfo.firstName + " " +
						  	                                          customerInfo.lastName+ "</div> " );   
		                                              
	      			                   jQuery("#loginForm").dialog('close');
	      			                
	      			                }//else if
				   

   }//end loginOK




function initSignUpForm(){

         
         
        
	jQuery("#ballroomRadio").hide();
	jQuery("#content").append("<div id=personalInfoDialog></div>");
		
	var formHTML = printSignUp();
	
	
        
	jQuery("#personalInfoDialog").html( formHTML) ;
	jQuery("#personalInfoForm input").css({"margin":"10px","background":"white", "opacity":"0.5"});
	jQuery("#personalInfoForm input").focus( function() { jQuery(this).css({"margin":"10px","background":"white", "opacity":"1"} );//end css
	                                                                                                           } );//end focus
	jQuery("#personalInfoForm div").css( { "background":"#000000","margin":"10px", "opacity":"1"} );
	jQuery("#personalInfoForm div").children("input").css({"opacity":"1"});
	
       
	jQuery("#personalInfoDialog").css( { "margin":"10px","height":"600px"} );
	jQuery("#personalInfoDialog" ).dialog({    title:"Sign Up Form:",
	                                    close:function(){   cancelInfo(); },	
				            bgiframe: false,
				            height: 600,
				            width:450,
				            modal: true }); //end dialog
									                                       
	                                                             
        
        jQuery("#personalInfoForm button[name='submit']").click( function(){  verifyInfo() }  );
	jQuery("#personalInfoForm button[name='submit']").hover( function(){  jQuery(this).addClass("ui-state-hover");   },
	               		                                 function(){  jQuery(this).removeClass("ui-state-hover");     } );
	               	           
	               	        
	jQuery("#personalInfoForm button[name='cancel']").click( function(){ cancelInfo() }  );
	jQuery("#personalInfoForm button[name='cancel']").hover( function(){  jQuery(this).addClass("ui-state-hover");      },
	               		                                 function(){  jQuery(this).removeClass("ui-state-hover");     } );
	               	           
	            
	jQuery("#personalInfoForm button[name='edit']").click( function(){   var formHTML = printSignUp();
	                                                                     jQuery("#personalInfoDialog").html( formHTML) ;

                                                                          } );//end click
		 	       	           
	 	       	        
	jQuery("#personalInfoForm button[name='edit']").hover( function(){  jQuery(this).addClass(   "ui-state-hover");      },
	 	       		                               function(){  jQuery(this).removeClass("ui-state-hover");     } );
	 	       	           
	 	       	        
	        
	 	                                           



}




function printSignUp(){
         var formHTML = "<div id=personalInfoForm >"+
                                 
                       
                        "<div>Class Name: " + this.customerInfo.className+"</div>"+
                        "<div>Duration  : " + this.customerInfo.classDuration +"</div>"+
                        "<div>Start Date: " + this.customerInfo.startDate     +"</div>"+
                        
                        //name widget
                        "<div  class=\"ui-widget-content ui-corner-all\">"+
                        "<div>"+
                        "<span>&nbsp;&nbsp;&nbsp;Title:</span>"+
                        "<span><select name=title>"+
                        "       <option value=\"Mr.\" selected>Mr.</option>"+
                        "       <option value=\"Mrs.\"        >Mrs.</option>"+
                        "       <option value=\"Miss\"        >Miss</option>"+
                        "       </select>                                  "+
                        "</span>"+
                        "<span >&nbsp;&nbsp;&nbsp;First Name:</span>"+
                        "<span> &nbsp;&nbsp;<input type=\"text\" name=\"first\" value=\""+ this.customerInfo.firstName + "\"  size=\"10\"></span>"+
                        "</div>"+
                        "<div>"+
                        "<span >"+
                        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
                        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
                        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
                        "&nbsp;&nbsp;&nbsp;&nbsp;"+
                        "Last Name:"+
                        "</span>"+
                        "<span>&nbsp;&nbsp;<input type=\"text\" name=\"last\" value=\"" + this.customerInfo.lastName  + "\" size=\"15\"></span>"+
                        "</div>"+
                        "</div>"+ 
                        
                        
                        //contact widget
                        "Contact information:"+
                        "<div class=\"ui-widget-content ui-corner-all\">"+
                        "<div>"+
                        "<span>&nbsp;&nbsp;&nbsp;Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"+
                        "<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"text\" name=\"email\" value=\"" + this.customerInfo.email   +  "\"  size=\"20\" ></span>"+
                        "</div>"+
                        "<div>"+
                        "<span >&nbsp;&nbsp;&nbsp;Verify Email:</span>"+
                        "<span>&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"text\" name=\"verifyEmail\" value=\"\"  size=\"20\"></span>"+
                        "</div>"+
                        "<div>"+
                        "<span>"+
                        "&nbsp;&nbsp;&nbsp;Phone: "+
                        "</span>"+
                        "<span>"+
                       "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"text\" name=\"phone\" value=\""     + this.customerInfo.phone    +  "\"  size=\"10\">"+
                       "</span>"+
                       "</div>"+
                       "</div>"+ 
                       //end contact widget
                       "<div>"+
                        "<button class=\"ui-state-default\" name=\"submit\">Submit Info</button>     "+
                        "<button class=\"ui-state-default\" name=\"cancel\">Cancel</button>"+
                        "</div>"+
                        
                        "</div>";
          
          return formHTML;
          
          
          }
          
          
          



/*************************************************************************************************/









function printGoogleSearch(){


  
var resultHTML ="<style type=\"text/css\">"+
"  @import url(http://www.google.com/cse/api/branding.css);"+
"  </style>"+
"  <div class=\"cse-branding-bottom\" style=\"background-color:#000000;color:#FFFFFF\">"+
"    <div class=\"cse-branding-form\">"+
"      <form action=\"http://ballroomradio.com/index.php/google-search\" id=\"cse-search-box\">"+
"        <div>"+
"          <input type=\"hidden\" name=\"cx\" value=\"partner-pub-3837358447107106:g0acew-1jgx\" />"+
"          <input type=\"hidden\" name=\"cof\" value=\"FORID:11\" />"+
"          <input type=\"hidden\" name=\"ie\" value=\"ISO-8859-1\" />"+
"          <input type=\"text\" name=\"q\" size=\"31\" />"+
"          <input type=\"submit\" name=\"sa\" value=\"Search\" />"+
"        </div>"+
"      </form>"+
"    </div>"+
"    <div class=\"cse-branding-logo\">"+
"      <img src=\"http://www.google.com/images/poweredby_transparent/poweredby_000000.gif\" alt=\"Google\" />"+
"    </div>"+
"    <div class=\"cse-branding-text\">"+
"      Custom Search"+
"    </div>"+
"  </div>";
  

jQuery("#googleSearch").append( printGoogleSearch() );




}//end gogleSearch