/* * EquineNetwork.js Javascript Framework v0.8 * by ieWebDesigns (www.inlandempirewebdesigns.com) * Requires jQuery 1.3.2 or later. */ function EquineNetwork() { this.readCookie = function(name){ var nameEQ = name + '='; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; }; this.saveCookie = function(name, value, days){ var expires = ''; if(days){ var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); expires = '; expires=' + date.toGMTString(); } document.cookie = name + '=' + escape(value) + expires + '; path=/'; }; this.setupModal = function(){ if(!this.isModalHTML){ this.isModalHTML = true; jQuery('body').append('
'); jQuery('#equineNetwork_modal').dialog({ title: 'Send a MyEquine Message to the Seller', width: 500, height: 'auto', modal: true, autoOpen: false, draggable: true, resizable: false }); } }; this.showForm = function(msg) { if(msg == null) msg = ''; jQuery('#equineInternet-loginForm').html( '
'+ ''+ ''+ ''+ '
Create New AccountForgot My Password
'+ '
' ); }; this.showProfile = function() { jQuery('#equineInternet-loginForm').html( '
'+ '
'+ '

Hello, '+ this.Username() +'!

'+ '

You have '+ this.UserNumMessages() +' new messages.

'+ '
'+ ''+ '

Click to Log out

'+ '
' ); }; this.userData = null; } /** * Print the login form. */ EquineNetwork.prototype.PrintLogin = function() { document.write('
'); if( this.UserLoggedIn() ) this.showProfile(); else this.showForm(); } EquineNetwork.prototype.doLogin = function() { var email = jQuery('#equineInternet-email').val(); var password = jQuery('#equineInternet-password').val(); var getData = (email && password) ? {email:email, password:password} : null; var i = this; jQuery('#equineInternet-loginForm').html('
'); jQuery.post( '/_api/ajax/userLoginJSON.php', getData, function(data, textStatus) { if(textStatus == 'success' && data != null && data.status == 'Active') { i.userData = data; i.showProfile(); } else if(textStatus == 'success' && data != null) { i.userData = null; i.showForm(email); alert('Your account is marked "'+ data.status +'".\nPlease contact support.'); } else { i.userData = null; i.showForm(email); if( email ) alert('Your login attemp failed. Try again.'); } }, 'json' ); return false; } EquineNetwork.prototype.ShowContactSellerModal = function(adId) { this.setupModal(); if( !this.UserLoggedIn() ){ jQuery('#equineNetwork_modal').html( '

You must be logged in to reply to an ad.

'+ '

If you do not have an account, you can register at Equine Internet.

'+ '

Click Here to Register

' ); jQuery('#equineNetwork_modal').dialog('option', 'buttons', { Cancel: function(){jQuery(this).dialog('close');}, 'Register Now': function(){ jQuery(this).dialog('close'); window.open('http://www.equineinternet.com/'); } }); $('#equineNetwork_modal').dialog('open'); return; } jQuery.ajaxSetup({cache: false}); jQuery('#equineNetwork_modal').html(''); jQuery('#equineNetwork_modal').load('/_api/ajax/contactSellerForm.php?adId='+adId); jQuery('#equineNetwork_modal').dialog('option', 'buttons', { Cancel: function(){jQuery(this).dialog('close');}, 'Send Message': function(){ jQuery(this).dialog('option', 'buttons', { "Close": function() {jQuery(this).dialog('close');} }); jQuery.ajaxSetup({cache: false}); jQuery(this).load('/_api/ajax/contactSellerSend.php?_'+(new Date().valueOf()), { adId: jQuery('#equineNetwork_adId').val(), messageBody: jQuery('#equineNetwork_messageBody').val(), security: jQuery('#equineNetwork_securityCode').val() }); } }); $('#equineNetwork_modal').dialog('open'); } EquineNetwork.prototype.UserLoggedIn = function(){return this.userData != null;} EquineNetwork.prototype.UserId = function(){return this.userData.id;} EquineNetwork.prototype.Username = function(){return this.userData.username;} EquineNetwork.prototype.UserStatus = function(){return this.userData.status;} EquineNetwork.prototype.UserNumMessages = function(){return this.userData.num_messages;} var equineNetwork = new EquineNetwork();