
$(document).ready(function(){OnPageInitialize();});function PageLoaded(){}
function OnPageInitialize(){$(window).load(function(){PageLoaded();});$('#basic-modal .basic').click(function(e){$('#basic-modal-content').modal();});$('#txtNewsFeedText').marquee('pointer').mouseover(function(){$(this).trigger('stop');}).mouseout(function(){$(this).trigger('start');});UpdateFavoritesCount();}
function ShowClientLogin(){if(!$('#uxSearchPanel').is(":visible")){$('#basic-modal-content').modal();}}
function Logout(){document.location='client_auth.php?cmd=logout';}
function ClientArea(){document.location='clients.php';}
function DoAuth(){if(typeof($('input#cuid'))=='undefined'){return false;}
var uid=$('input#cuid').val();var pwd=$('input#cpwd').val();var server_key=$('input#skey').val();if(!uid||!pwd||!server_key){alert('Error: Please provide a username and password!');return false;}
var md5_hash=hex_md5(pwd);$('input#cpwd').val('');$('input#md5hash').val(md5_hash);$('#frmLogin').attr('action','client_auth.php');return true;}
function ToggleSearchPanel(){$("#uxSearchPanel").slideToggle('slow',function(){if($(this).is(":visible")){$('#btnSearch').html('CLOSE SEARCH');}else{$('#btnSearch').html('SEARCH');}});}
$(function(){$("#slider-range-height").slider({range:true,min:48,max:80,values:[48,80],slide:function(event,ui){var minh=ui.values[0];var min_ft=Math.floor(minh/12);var min_in=minh%12;var maxh=ui.values[1];var max_ft=Math.floor(maxh/12);var max_in=maxh%12;var minheight=min_ft+'\' '+min_in+'"';var maxheight=max_ft+'\' '+max_in+'"';$("#height").val(minheight+'  -  '+maxheight);}});var minh=$("#slider-range-height").slider("values",0);var min_ft=Math.floor(minh/12);var min_in=minh%12;var maxh=$("#slider-range-height").slider("values",1);var max_ft=Math.floor(maxh/12);var max_in=maxh%12;var minheight=min_ft+'\' '+min_in+'"';var maxheight=max_ft+'\' '+max_in+'"';$("#height").val(minheight+'  -  '+maxheight);});$(function(){$("#slider-range-weight").slider({range:true,min:45,max:300,values:[45,300],slide:function(event,ui){var minweight=ui.values[0];var maxweight=ui.values[1];$("#weight").val(minweight+'  -  '+maxweight+' lbs');}});$("#weight").val($("#slider-range-weight").slider("values",0)+'  -  '+$("#slider-range-weight").slider("values",1)+' lbs');});$(function(){$("#slider-range-age").slider({range:true,min:4,max:90,values:[4,90],slide:function(event,ui){var minweight=ui.values[0];var maxweight=ui.values[1];$("#age").val(minweight+'  -  '+maxweight+' yrs');}});$("#age").val($("#slider-range-age").slider("values",0)+'  -  '+$("#slider-range-age").slider("values",1)+' yrs');});function UpdateFavoritesCount(){var favorites_list=$.cookie('favorites');var count=0;if(favorites_list&&favorites_list.length>0){var count=(favorites_list.split(':').length);}
$('span#txtFavoritesCount').html('('+count.toString()+')');return count;}
function IsModelInFavorites(pid){if(!pid||pid<=0){return-1;}
var favorites_list=$.cookie('favorites');if(!favorites_list||favorites_list.length<=0){return-1;}
var MyFavorites=new Array();MyFavorites=favorites_list.split(':');for(var k=0;k<MyFavorites.length;k++){if(pid==MyFavorites[k]){return k;}}
return-1;}
function CloseFavorites(){ToggleFavoritesPanel();}
function ShowFavorites(state){var MyFavorites=new Array();MyFavorites=GetUserFavorites();var favorites_string=$.cookie('favorites');if(state!=0&&(favorites_string==undefined||favorites_string==null||!favorites_string||favorites_string.length<=0)){alert('You have not added any favorites yet!');return false;}
if(favorites_string.length>0){var json_obj='';var server_resp=$.ajax({type:"POST",cache:false,timeout:3000,url:'get_favorites.php',data:{'favorites':favorites_string},async:false,beforeSend:function(){},success:function(msg){},error:function(XMLHttpRequest,textStatus,errorThrown){alert("An error occurred while making the request: "+errorThrown);return false;}}).responseText;if(server_resp.length>0){json_obj=$.parseJSON(server_resp);}}
$('ul#FavoritesList li').each(function(){$(this).remove();});if((!MyFavorites)||MyFavorites.length<=0){$('#FavoritesHeading').html('You have not added any favorites yet!');ToggleFavoritesPanel();return false;}else{$('#FavoritesHeading').html('');}
$(MyFavorites).each(function(index,value){if(value!=''){var fav_name=json_obj[value];if(fav_name==''){fav_name='';}
$('ul#FavoritesList').append('<li><div class="clip_thumb"><a href="talent.php?xcmd=find&pid='+value+'"><img src="model_photos/model_thumbnail.php?pid='+value+'" /></a></div><div class="thumb_data"><label>'+fav_name+'</label><br/><br/><a href="#" onclick="RemoveFromFavorites('+value+');">Remove from favorites</a></div></li>');}});ToggleFavoritesPanel(state);return true;}
function AddFavoritesToUl(dObj){var MyFavorites=new Array();MyFavorites=GetUserFavorites();if((!MyFavorites)||MyFavorites.length<=0){return false;}
$(MyFavorites).each(function(index,value){if(value!=''){$(dObj).append('<li><div class="clip_thumb_contactpage"><img src="model_photos/model_thumbnail.php?pid='+value+'" /></div></li>');}});return true;}
function ToggleFavoritesPanel(state){UpdateFavoritesCount();if(state==1){$('#uxFavoritesPopout').slideDown('slow');return true;}
if(state==0){$('#uxFavoritesPopout').slideUp('slow');return true;}
$('#uxFavoritesPopout').slideToggle('slow',function(){if($(this).is(":visible")){}else{}});}
function ClearFavorites(){RemoveAllFavorites();$('#FavoritesList li').each(function(){$(this).remove();});ToggleFavoritesPanel();}
function BookFavorites(){window.location='contact.php?book=1';}
function GetUserFavorites(){var favorites_list=$.cookie('favorites');if(!favorites_list||favorites_list.length<=0){return null;}else{return favorites_list.split(':');}}
function AddToFavorites(pid){if(!pid||pid<=0){return false;}
var MyFavorites=new Array();var favorites_list=$.cookie('favorites');if(!favorites_list||favorites_list.length<=0){MyFavorites.push(pid);}else{if(IsModelInFavorites(pid)>-1){alert('This model is already in your favorites.');$('.example6DOMWindowClose').click();return false;}
MyFavorites=favorites_list.split(':');MyFavorites.push(pid);var server_resp=$.ajax({type:"POST",cache:false,timeout:1000,url:'add_favorites.php',data:{'pid':pid},async:false,beforeSend:function(){},success:function(msg){},error:function(XMLHttpRequest,textStatus,errorThrown){}}).responseText;}
var favorites_stringified=MyFavorites.join(':');$.cookie('favorites',favorites_stringified,{expires:365});$('.example6DOMWindowClose').click();UpdateFavoritesCount();ShowFavorites(1);return true;}
function RemoveAllFavorites(){$.cookie('favorites','');UpdateFavoritesCount();}
function RemoveFromFavorites(pid){if(!pid||pid<=0){return false;}
var MyFavorites=new Array();var favorites_list=$.cookie('favorites');if(!favorites_list||favorites_list.length<=0){return false;}else{var pos=IsModelInFavorites(pid);if(pos>-1){MyFavorites=favorites_list.split(':');MyFavorites.splice(pos,1);}else{return false;}}
var favorites_stringified=MyFavorites.join(':');$.cookie('favorites',favorites_stringified,{expires:365});$('.example6DOMWindowClose').click();UpdateFavoritesCount();ShowFavorites(0);return true;}
