path_files = '';

jQuery.preloadImages = function(){
	for(var i = 0; i<arguments.length; i++){
		document.createElement('img').src = arguments[i];
	}
}

function newwindow(w,h,webaddress) {
	var viewimageWin = window.open(webaddress,'New_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=Yes,resizable=no,copyhistory=no,width='+w+',height='+h);
	viewimageWin.moveTo(screen.availWidth/2-(w/2),screen.availHeight/2-(h/2));
}

function Mostrar(id){
	$.fancybox({'width':550,'type':'iframe','height':200,'href':path_files+'/includes/stats.php?vote_id='+id});
	return false;
}

function Mostrar3(id){
	$.fancybox({'width':535,'type':'iframe','height':190,'href':path_files+'/includes/stats3.php?vote_id='+id});
	return false;
}

// for summer fashion competition
function Mostrar5(id){
	$.fancybox({'width':600,'type':'iframe','height':230,'href':path_files+'/includes/stats5.php?vote_id='+id});
	return false;
}

function LoadTabS(dst){
	div = '#'+dst+'-page';
	$('.page').hide();
	on = '-on.gif';
	off = '-off.gif';
	$(".tabs img").each(function(){
		s1 = $(this).attr('src');
		$(this).attr('src', s1.replace(on,off) );
	});
	s1 = $('#link_'+dst+' img').attr('src');
	$('#link_'+dst+' img').attr('src', s1.replace(off,on));
	$(div).show();
	return false;
}

function LoadTabS2(dst){
	div = '#'+dst+'-page';
	$('.page').hide();
	on = '-on.jpg';
	off = '-off.jpg';
	$(".tabs img").each(function(){
		s1 = $(this).attr('src');
		$(this).attr('src', s1.replace(on,off) );
	});
	s1 = $('#link_'+dst+' img').attr('src');
	$('#link_'+dst+' img').attr('src', s1.replace(off,on) );
	$(div).show();
	return false;
}

function LoadTab(dst, p, filter){
	$('.fashion_tab').hide();
	$('.menu a').each(function(i){
		s1 = $(this).attr('class');
		if (s1.indexOf('-black') > 0){
			s1 =  s1.replace('-black','');
		}
		$(this).attr('class',s1);
	});
	s2 = 'sp-'+dst+'-btn';
	s2 = s2.replace('_','-');
	$('.'+s2).attr('class','sprite '+s2  + '-black');
	if (filter == -1){on = '_on2';}else{on = '_on';}
	if (dst == 'most_viewed') dst = 'most_popular';
	div = '#tab_'+dst;
	$(div).show().html('<img src="'+path_files+'/images/loadingAnimation.gif" style="margin:95px 250px">');
	$.getScript( path_files + "/includes/nav_tab.php?dst="+dst+ "&p="+p+ "&filter="+filter);	
	return false;
}


function FashionNav(dst,p,type){
	$('#'+dst).html('<img src="'+path_files+'/images/loadingAnimation.gif" style="margin:0 auto">');
	$.getScript( path_files + "/includes/nav_fashion.php?p="+p+ "&dst="+dst+ "&type="+type);
	return false;
}

function ChangeComments(){
	img_c = $('#change_img');
	src = img_c.attr('src');
	if(src.indexOf('down') > 0){
		img_c.attr('src',path_files + '/images/comments_up.gif');
	}else{
		img_c.attr('src',path_files + '/images/comments_down.gif');
	}
	$('.comments_form').toggle('slow');
	return false;
}

function SendPM(user_id){
	message = $('#pm_message').val();
	subject = $('#pm_subject').val();
	user_id = parseInt(user_id);
	if (message===''){alert("A message is required."); return false;}
	data='message='+message+'&user_id='+user_id+'&subject='+subject;
	if(user_id > 0){
		$.ajax({type: "POST",url: path_files + "/users/send_pm.php",data: data ,dataType: "script"});
	}else{
		alert(user_id);
	}
	$('#pm .spinner').show();
	return false;
}

function DeleteMessage (message_id){
	message_id = parseInt(message_id);
	div = $('.message_div');
	data =  "message_id=" + message_id;
	$.ajax({type: "POST",url: path_files + "/includes/delete_message.php",data: data ,dataType: "script"});
}

function ShowMessage(msg_id){
	msg_id = parseInt(msg_id);
	div = $('.message_div');
	div.show().html('<img src="'+path_files+'/images/loadingAnimation.gif" style="margin:0 auto">');	
	if(msg_id  > 0){
		$.ajax({type:"POST",url:path_files+"/includes/message.php",dataType:"html",data:"msg_id="+msg_id,success:function(msg){
			div.hide();
			$('.inbox_list').slideUp('slow', function () {$('.message_div').slideDown('slow') });
			div.html(msg);
			
			$('.message_div a.thickbox').fancybox({'titleShow': false});
			$('.message_div a.thickbox2').fancybox({'titleShow': false, 'type' : 'iframe'});

			//tb_init('.message_div a.thickbox');
			$('#subject_' + msg_id).html('<a href="#"  class="grey" onclick="return ShowMessage('+ msg_id +')">'+ $('#message_title').html() +'</a>');
		}});
	}
	return false;
}

function CloseMessage(){
	$('.compose_email').slideUp('slow');
	$('.message_div').slideUp('slow',function(){$('.inbox_list').slideDown('slow')});
	return false;
}

function SendToClipBoard(s){
	$('#'+ s).select();
	s = $('#'+ s).val();
	if(window.clipboardData && clipboardData.setData){clipboardData.setData("text", s);}else{alert("Internet Explorer required");}
	return false;
} 

function ValidateTuner(){
	genre_id = '';c = 0;
	station = $('input[@name=station]:checked').val();
	$("#genres input[@type='checkbox']").each(function(){
		if(this.checked){
			c++;
			genre_id=genre_id+','+this.value;
		}
	});
	username = $('#user_name').val();
	if(station==null && username==''  && c==0){
		alert("You must select a Genre, a Station or a User");
		return false;
	}
	if (c > 0){
		$('#ids').val(genre_id);
	}
	return true;
}

function Check(div){
	if(div == 'music_filters'){
		state = $('#music_checkbox').attr('checked');
	}
	if(div == 'fashion_filters'){
		state = $('#fashion_checkbox').attr('checked');
	}
	if(div == 'art_filters'){
		state = $('#art_checkbox').attr('checked');
	}
	if(div == 'model_filters'){
		state = $('#model_checkbox').attr('checked');
	}
	if(div == 'clothes_filters'){
		state = $('#fashion-designer_checkbox').attr('checked');
	}
	if(state==true){
		$('#'+div).slideDown('slow');
	}else{
		$('#'+div).slideUp('slow');
	}
}

function AddToCalendar(calendar_id){
	$('.event_'+calendar_id).html('<img src="'+path_files+'/images/loadingAnimation.gif">');
	calendar_id = parseInt(calendar_id);
	data = "calendar_id=" + calendar_id;
	if(calendar_id > 0){
		$.ajax({type:"POST",url:path_files+"/includes/add2calendar.php",data:data,dataType:"script"});
	}
	return false;
}

function ToggelValue(value){
	value = parseInt(value);
	data = "value="+value;
	if(value > 0){
		$.ajax({type:"POST",url:path_files+"/includes/toggle.php",data: data,dataType:"script"});
	}
}

function ToggelValue2(value){
	value = parseInt(value);
	data = "value=" + value;
	if (value > 0  ){
		$.ajax({type:"POST",url:path_files+"/includes/toggle2.php",data:data,dataType:"script"});
	}
}

function ToggelValue3(value){
	value = parseInt(value);
	data =  "value=" + value;
	if(value > 0){
		$.ajax({type:"POST",url:path_files+"/includes/toggle3.php",data:data,dataType:"script"});
	}
}

function ToggelValue4(value){
	value = parseInt(value);
	data =  "value=" + value;
	if(value > 0){
		$.ajax({type:"POST",url:path_files+"/includes/toggle4.php",data:data,dataType:"script"});
	}
}

/**
 * This function is used to set the "Summer Fashion Contest" winner
 *
 */
function SetSummerContestWinner(value){
	value = parseInt(value);
	data =  "value=" + value;
	if(value > 0){
		$.ajax({type:"POST",url:path_files+"/includes/summer-contest-set-winner.php",data:data,dataType:"script"});
	}
}

function ValidateExt(field_name,allowed_extensions){
	val = $('#'+ field_name).val().toLowerCase();
	array = allowed_extensions.split(',');
	cont = 0;
	for(i=0; i<array.length; i++){
		if(val.indexOf('.'+array[i]) > 0) cont++;
	}
	if (cont == 0){
		alert('The File must be '+array.join(' or '));
		$('#'+ field_name).val('');
	}
}

function ValidateSearch(){
	err = $("#search_errors");
	q = $('#q').val();
	type = $('#search_type').val();
	if(q!='' && (type=='' || type==null)){
		err.show().html('<label>Please select where to search</label>');
		return false;
	}
	err.hide();
	return true;
}

function checkbox_control(div,status){
	var inputs = document.getElementById(div).getElementsByTagName('input');
	for(var i=0; i<inputs.length; i++){
		inputs[i].checked = status;
	}
	Check('model_filters');
	Check('clothes_filters');
	return false;
}

function LoadNavPage(url,page,container){
	url = url.replace('/search/','/search.php');
	url = url.replace('/top_rated/','/top_rated.php');
	url = url.replace('/new_releases/','/new_releases.php');
	page = parseInt(page);
	$('#'+container+' .pages').hide();
	$('#'+container+' .spinner').show();
	new_html = $('#'+container+'_page_'+ page).html();
	if (new_html != null){
		$('#'+container+'_page_'+ page).fadeIn("slow");
		$('#'+container+' .spinner').hide();
	}else{
		$.post(url,{ajax:"true"},function(data){
			$('#'+ container).hide().prepend(data).fadeIn("slow");;
			$('#'+container+' .spinner').hide();
		});
	}
	$('#'+container+'  .pages_nav  li').removeClass("bold");
	$('#'+container+'_li_'+ page ).addClass("bold");
	actual_txt = $('#'+container+'_nav_page').html();
	ind = actual_txt.indexOf('of');
	txt = actual_txt.substr(ind);
	$('#'+container+'_nav_page').html('Showing page '+(page+1)+' '+txt);
	window.location.hash = container + ':'+ page;
	return false;
}

function LoadSeccion(file,user_id){
	$(".user_nav img").each(function(i){
		$(this).attr('src', path_files + '/images/users_'+ $(this).attr('alt').toLowerCase() + '_link.png');
	});
	current_page = file;
	$('#user_contents').html('<img src="' + tb_pathToImage+ '">');
	if (user_id  > 0 ){
		$.ajax({type:"GET",url:path_files+"/users/"+file+".php",data:"user_id="+user_id,success:function(msg){
			ini = 0;
			fin = 0;
			$('#user_contents').html(msg);
			ini = msg.indexOf('/* JAVASCRIPT CODE */');
			fin = msg.indexOf('</script>');
			eval(msg.substr(ini, fin - ini) )
			tb_init('a.thickbox, area.thickbox, input.thickbox');
		}});
	}
	return false;
}

function LoadParams(params,user_id){
	params = params.replace('http://','');
	params = params.split('/');
	cont = 0;
	var3 = '';
	for ( i = 0 ; i < params.length; i++){
		if (i == 2) { file = params[i]}
		if (i == 3 ) { var3 = params[i]}
	}
	$('#user_contents').html('<img src="'+path_files+tb_pathToImage+'">');
	if(user_id>0){
		$.ajax({type: "GET",url: path_files +"/users/" + file + ".php",data: "user_id=" + user_id+"&var3="+var3,success:function(msg){
			ini = 0;
			fin = 0;
			$('#user_contents').html(msg);
			ini = msg.indexOf('/* JAVASCRIPT CODE */');
			fin = msg.indexOf('</script>');
			eval(msg.substr(ini, fin - ini) )
			tb_init('a.thickbox, area.thickbox, input.thickbox');
		}});
	}
	return false;
}

function LoadPosts(params,user_id){
	params = params.replace('http://','');
	params = params.split('/');
	cont = 0;var3 = '';	var4 = '';
	for(i=0; i<params.length; i++){
		if(i==2){file=params[i]}
		if(i==3){var3=params[i]}
		if(i==4){var4=params[i]}
	}
	$('#blog_content').html('<img src="' + tb_pathToImage+ '">');
	if(user_id>0){
		$.ajax({type: "GET",url: path_files + "/users/posts.php",data: "user_id=" + user_id+"&var3="+var3+"&var4=" + var4,success: function(msg){$('#blog_content').html(msg)}});
	}
	return false;
}

function LoadPosts2(params,user_id){
	params = params.replace('http://','');
	params = params.split('/');
	cont = 0;var3 = '';	var4 = '';
	for(i=0; i<params.length; i++){
		if(i==2){file=params[i]}
		if(i==3){var3=params[i]}
		if(i==4){var4=params[i]}
	}
	$('#blog_content').html('<img src="' + tb_pathToImage+ '">');
	if(user_id > 0){
		$.ajax({type: "GET",url: path_files + "/users/posts2.php",data: "user_id=" + user_id+"&var3="+var3+"&var4=" + var4,success: function(msg){$('#blog_content').html(msg)}});
	}
	return false;
}

function checkemail(str){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if(filter.test(str)){return true;}else{return false;}
}

function SendComment(i){
	message = $('#message_' + i).val();
	post_id = parseInt($('#post_id_' + i).val());
	if(message==='' || message===undefined){
		alert('Please enter a message.');
		return false;
	}
	$('#post_' + i + ' .comments_form .spinner').show();
	data = "post_id=" + post_id+"&message="+message + "&i=" + i;
	if(post_id > 0){
		$.ajax({type: "POST",url: path_files +"/users/add_comment.php",data: data ,dataType: "script"});
	}
	return false;
}

function SendComment2(id,type){
	message = $('#message').val();
	id = parseInt(id);
	if (message === '' ||  message === undefined ){
		alert('Please enter a message.') ; return false;
	}
	$('.comments_form .spinner').show();
	data =  "reg_id=" + id+"&message="+message + "&type=" + type;
	if (id > 0){
		$.ajax({type: "POST",url: path_files +"/users/add_comment2.php",data: data ,dataType: "script"});
	}
	return false;
}

function SharePost(i){
	friend_email = $('#friend_email_' + i).val();
	friend_name = $('#friend_name_' + i).val();
	message = $('#share_message_' + i).val();
	post_id = parseInt($('#post_id_' + i).val());
	
	if (friend_name === '' ||  friend_name === undefined ){
		alert('Please enter your Friend Name.') ; return false;
	}
	
	if (friend_email === '' || friend_email === undefined || checkemail(friend_email) == false ) {
		alert('Please enter a valid Friend Email.') ; return false;;
	}
	if (message === '' ||  message === undefined ){
		alert('Please enter a message.') ; return false;
	}
	$('#post_' + i + ' .share_form .spinner').show();
	data =  "post_id=" + post_id+"&message="+message +"&email="+friend_email + "&friend_name=" +  friend_name + "&i=" + i;
	alert(data);
	//return false;
		if (post_id > 0  ){
			$.ajax({type: "POST",url: path_files + "/users/share_post.php",data: data ,dataType: "script"});
		}
	return false;
}

function AddToFav(user_id,name){
	if (in_fav == true){
		alert('This user is already in your favorites ');
		return false;
		}
	user_id = parseInt(user_id);
	data =  "user_id=" + user_id+"&name="+name;
		if (user_id > 0  ){
			$.ajax({type: "POST",url: path_files + "/users/add_to_fav.php",data: data ,dataType: "script"});
		}
		return false;

}

function Rate(value, type , user_id ){
	value = parseInt(value);
	type = parseInt(type);
	user_id = parseInt(user_id);
	data =  "user_id=" + user_id+"&value="+value+"&type="+type;
	if(value > 0 && type > 0 && user_id > 0){
		$.ajax({type: "POST",url: path_files + "/users/rate.php",data: data ,dataType: "script"});
	}
	return false;
}

function Rate2(value, type , user_id ){
	value = parseInt(value);
	type = parseInt(type);
	user_id = parseInt(user_id);
	data =  "user_id=" + user_id+"&value="+value+"&type="+type;
	if (value>0 && type>0 && user_id>0){
		$.ajax({type: "POST",url: path_files + "/users/rate2.php",data: data ,dataType: "script"});
	}
	return false;
}

function Rate3(value, type, user_id){
	value = parseInt(value);
	type = parseInt(type);
	user_id = parseInt(user_id);
	data =  "user_id=" + user_id+"&value="+value+"&type="+type;
	if(value>0 && type>0 && user_id>0){
		$.ajax({type: "POST",url: path_files + "/users/rate3.php",data: data ,dataType: "script"});
	}
	return false;
}

function Rate4(value, type , user_id ){
	value = parseInt(value);
	type = parseInt(type);
	user_id = parseInt(user_id);
	data = "user_id=" + user_id+"&value="+value+"&type="+type;
	if (value>0 && type>0 && user_id>0){
		$.ajax({type: "POST",url: path_files + "/users/rate4.php",data: data ,dataType: "script"});
	}
	return false;
}

/* function to rate product in summer fashion contest - 13/06/2011 */
function Rate5(value, type , user_id ){
	value = parseInt(value);
	type = parseInt(type);
	user_id = parseInt(user_id);
	data = "user_id=" + user_id+"&value="+value+"&type="+type;
	if (value>0 && type>0 && user_id>0){
		$.ajax({type: "POST",url: path_files + "/users/rate5.php",data: data ,dataType: "script"});
	}
	return false;
}

function RSVP(calendar_id, output){
	calendar_id = parseInt(calendar_id);
	output = parseInt(output);
	if (output == 1){
		$('#confirm_image').html('<img src="'+path_files+'/images/loadingAnimation.gif">');
	}
	data =  "calendar_id=" + calendar_id + "&output=" + output;
	if (calendar_id > 0 ){
		$.ajax({type: "POST",url: path_files + "/includes/confirm.php",data: data ,dataType: "script"});
	}
	return false;
}

function Display(value, type,layer){
	$('.' + layer).show();
	value = parseInt(value);
	type = parseInt(type);
	$('.' + layer).html('<img src="'+path_files +'/images/vote_'+ value  +'_' +type +'.png" >');
	return false;
}

function JS_Load_post_subcategories(pre){
	v = parseInt($('#post_category_id').val());
	d = $('#post_subcategory_id');
	p = parseInt(pre);
	if (isNaN (v)){
		alert('Please select an Option');
		return false;
	}
	d.attr("disabled",'true');
	data = 'v='+ v + '&d=post_subcategory_id&t=post_category_id&p='+p;
	$.ajax({type: "POST",url: path_files + "/includes/combos.php",data: data ,dataType: "html",success:function(msg){
		d.html(msg);
		d.removeAttr("disabled");
	}});
}

function SellSong(song_id){
	e = $('#price_'+song_id);
	if (e.attr("disabled") ){
		e.removeAttr("disabled");
		e.focus();
		e.select();
		data = 'song_id=' + song_id;
		sa = $('#sample_'+song_id)
		if (sa.html().length < 80){
			sa.html('<img src="../images/loading_sample.gif" />');	
			$.ajax({type: "POST",url: path_files + "/includes/sample.php",data: data ,dataType: "script"});
		}	
	}else{
		e.attr("disabled","true");
	}
}
function StopSell(album_id){
	sa = $('#stop_'+album_id);
	data = 'album_id=' + album_id;
	sa.html('<img src="../images/loading_sample.gif" />');
	$.ajax({type: "POST",url: path_files + "/includes/stop_sell.php",data: data ,dataType: "script"});
}

function getHash(){
	return window.location.hash.replace("#", "");
}

function InitializeSE(){
	var bookHash=getHash();
	if(bookHash.length>0&&bookHash.indexOf(':')>0){
		page=bookHash.substr(bookHash.indexOf(':')+1);
		container=bookHash.substr(0,bookHash.indexOf(':'));
		url=$('#'+container+'_li_0 a').attr('href').replace('p=0','p='+page);
		pp=parseInt($('#'+container+'_list_0 li').size())-1;
		$('#'+container+'  .pages_nav  ul').hide();
		$('#'+container+'_list_'+Math.floor(page/pp)).show();
		LoadNavPage(url,page,container);
	}
}

function LoadFB(id){
	tr = $('#feed_back_'+id);
	td = $('#feed_back_form_'+id);
	tr.show();
	if (td.html().length < 80){
		data = 'sid='+id;
		$.ajax({type: "POST",url: path_files + "/includes/feedback.php",data: data ,dataType: "html",success:function(msg){
			td.html(msg).hide().slideToggle("slow");
		}});
	}else{
		td.slideToggle("slow");
	}
	return false;
}

function SendFB(){
	sid = $('#sid').val();
	fb =  $('#feedback').val().replace("#", "");
	v = $('input[@name="fulfils"]:checked').val().toLowerCase();
	data = 'sid='+sid+'&v='+v+'&fb='+fb;
	$.ajax({type: "POST",url: path_files + "/includes/process_feedback.php",data: data ,dataType: "script"});
	return false;
}


function FinalVote(id){
	$(".showdown-item").each(function(){
		if ( $(this).attr('id') != 'showdown-item-' + id ){update = $(this).attr('id');
			$('#voted').val( $('#voted').val()  +  update.substr( update.lastIndexOf('-') +1 ) + ',' );
		}
	});
	ar = ($('#voted').val()).split(',');
	c = ar.length-1;
	if(c == 10){
		$('#showdown-winner-2').load(path_files+ "/includes/final-winner.php?id="+id+"&voted="+$('#voted').val(),{},function(){
			$('#round-counter').hide();
			$('#showdown-display').slideUp("slow");
			$('#showdown-winner-2').slideDown("slow");
			$('.opacity-09').fadeTo("slow", 0.5	);
		});
	}else{
		$('#showdown-1').html('<div class="showdown-item" id="showdown-item-'+id+'">'+$('#showdown-item-'+id).html()+'</div>');
		$('#showdown-2').html('<img src="'+path_files+'/images/loadingAnimation.gif">');
		$('#showdown-2').load(path_files+ "/includes/final_vnl.php?id="+id+"&voted="+$('#voted').val());
		if ( c >=10 ) $('#counter').html("<img src='"+path_files+"/images/p-"+c+".gif'/>");
		else $('#counter').html("<img src='"+path_files+"/images/p-0"+c+".gif'/>");
	}
	return false;
}


function ShowdownVote(id){
	$(".showdown-item").each(function(){
		if ( $(this).attr('id') != 'showdown-item-' + id ){update = $(this).attr('id');
			$('#voted').val( $('#voted').val()  +  update.substr( update.lastIndexOf('-') +1 ) + ',' );
		}
	});
	ar = ($('#voted').val()).split(',');
	c = ar.length-1;
	if(c == 13){
		$('#showdown-winner-2').load(path_files+ "/includes/showdown-winner.php?id="+id+"&showdown_id="+ $('#showdown_id').val() +"&voted="+$('#voted').val(),{},function(){
			$('#round-counter').hide();
			$('#showdown-display').slideUp("slow");
			$('#showdown-winner-2').slideDown("slow");
			$('.opacity-09').fadeTo("slow", 0.5	);
		});
	}else{
		$('#showdown-1').html('<div class="showdown-item" id="showdown-item-'+id+'">'+$('#showdown-item-'+id).html()+'</div>');
		$('#showdown-2').html('<img src="'+path_files+'/images/loadingAnimation.gif">');
		$('#showdown-2').load(path_files+ "/includes/vote_and_load.php?id="+id+"&showdown_id="+ $('#showdown_id').val() +"&voted="+$('#voted').val());
		if ( c >=10 ) $('#counter').html("<img src='"+path_files+"/images/p-"+c+".gif'/>");
		else $('#counter').html("<img src='"+path_files+"/images/p-0"+c+".gif'/>");
	}
	return false;
}



function ff(){
	title=document.title;
	url="http://www.ustrendy.com";
	if(window.sidebar){
		window.sidebar.addPanel(title,url,"");
	}else if(window.external){
		window.external.AddFavorite(url,title);
	}else if(window.opera&&window.print){
		alert("Sorry, your web browser does not support automatically adding Bookmarks/Favorites.  Press 'Ctrl-D' in Firefox or 'Ctrl-T' in Opera to manually bookmark UsTrendy.com.");
		return false;
	}
} 

function getCart(){
	q = $('#q').val();
	if ( q.indexOf('Article')< 0){
		$('#article').load('../includes/get_cart.php?id='+q).show();
	}
	return false;
}

function ShowPost(n){
	var s1=$('#post_'+n+' .blog-body');
	var s2=$('#post_'+n+' .blog-wrapper');
	if(s1.is(':hidden')){
		s2.animate({height:s1.height()});
		s2.fadeOut(200,function(){
			s1.fadeIn(200);
			s2.css({'display':'block','margin':0,'height':0});
		});
	} else {
		var h=$('#post_'+n+' .blog-body-hidden').height();
		s1.css('height',s1.height());
		s2.css({'display':'none','margin-top':s1.css('margin-top'),'margin-bottom':s1.css('margin-bottom'),'height':s1.height()});
		s1.fadeOut(200,function(){
			s2.fadeIn(200);
			s2.animate({height:h},200);
		});
	}
	return false;
}

function fancyTitle(title, currentArray, currentIndex, currentOpts){
	// begin - summer contest arrows patch
	if (typeof(parent.$) !== 'undefined') {
		if ($("#right-arrow").length > 0) {
			$("#right-arrow").css('zIndex', 1);
		}
		if ($("#left-arrow").length > 0) {
			$("#left-arrow").css('zIndex', 1);
		}
	}
	// end - summer contest arrows patch
	var id=0,html='';
	if(this.orig){
		var id=$(this.orig.context).attr('id').replace('pic','');
		if(title=='' && this.orig[0].title) title=this.orig[0].title;
	}
	if(typeof title!='undefined' && title!='') html='<p><strong>'+title+'</strong>';
	if(id && typeof data_pic!='undefined' && typeof data_pic[id]!='undefined'){
		d = data_pic[id];
		if(d.s && d.x && d.y) html+=' ('+d.s+' / '+d.x+'x'+d.y+')';
		html+='</p>';
		if(typeof d.r!='undefined'){
			if(typeof d.t!='undefined') t=d.t; else t=6;
			html+='<div class="fbox">'
			html+='<div><span style="margin-left: 3px;" class="sprite sp-rate-it-sm">Rate It</span>';
			html+='<span class="rating"><ul>';
			html+='<li class="current-rating" style="width:'+d.r*20+'%">Currently '+d.r+'/5 Stars.</li>';
			html+='<li><a class="star-1" href="#" onclick="return Rate3(1,'+t+','+id+')"></a></li>';
			html+='<li><a class="star-2" href="#" onclick="return Rate3(2,'+t+','+id+')"></a></li>';
			html+='<li><a class="star-3" href="#" onclick="return Rate3(3,'+t+','+id+')"></a></li>';
			html+='<li><a class="star-4" href="#" onclick="return Rate3(4,'+t+','+id+')"></a></li>';
			html+='<li><a class="star-5" href="#" onclick="return Rate3(5,'+t+','+id+')"></a></li>';
			html+='</ul></span></div>';
			url='http://www.ustrendy.com'+path_files+'/';
			if(t==6 || t==5) url+='?i='+id; else {if(typeof d.u!='undefined') url+=d.u+'/?id='+id; else url=false;}
			if(url){
				html+='<div class="vr"></div><div><span class="sprite sp-promote-it-sm">Promote It</span><ul>';
				html+='<li><a class="sprite sp-facebook3" target="_blank" href="http://www.facebook.com/sharer.php?u='+url+'">Facebook</a></li>';
				html+='<li><a class="sprite sp-twitter3" target="_blank" href="http://twitter.com/home?status=Currently%20in%20'+url+'">Twitter</a></li>';
				html+='<li><a class="sprite sp-stylehive3" target="_blank" href="http://www.stylehive.com/savebookmark/index.htm?url='+url+'">Stylehive</a></li>';
				html+='</ul></div>';
			}
			if(t==6 || t==5)html+='<div class="vr"></div><div><span class="sprite sp-shop-it">Shop It</span><a href="'+url+'" style="margin-top: 10px;" class="sprite sp-buy-this-now">Buy This Now!</a></div>';
			html+='</div>';
		}
	} else {
		if(title!='') html+='</p>';
	}
	return html;
}
if(typeof $.fn.fancybox!='undefined') $.fn.fancybox.defaults.titleFormat=fancyTitle;

$(function(){
	$('#search').val($('#search').addClass('placeholder').attr('defaultValue'))
	$('#search').focus(function(){if($(this).val()==$(this).attr('defaultValue'))$(this).val('').removeClass('placeholder');})
	.blur(function(){if($(this).val()=='')$(this).val($(this).addClass('placeholder').attr('defaultValue'));});
});

