function CreateBookmarkLink() {

 title = "Redsexmobile.com"; 
  // Blogger - Replace with <$BlogItemTitle$> 
  // MovableType - Replace with <$MTEntryTitle$>

 url = "http://www.redsexmobile.com";
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}

function createIdentifier(s) {
	s = escape(s);
	s = s.replace(/\%u..../ig, "");
	s = s.replace(/\%../ig, "");
	s = s.toLowerCase();
	return s;
}

$(document).ready(function(){
    /* search stuff */
    $("#search_expression").click(function(){
        $("#search_form_id").hide();
        $("#search_form").show();
    });
    $("#search_stockid").click(function(){
        $("#search_form").hide();
        $("#search_form_id").show();
    });

    /* remove toplsit separatores */
    $(".toplist_header_text").prev(".toplist_separator").remove();
    //$("#toplist_box .toplist_separator:last").remove();

    /* toplist fake things */
    $(".toplistsavebutton").click(function(){
        var id = $(this).attr("id").substring(5);
        $.ajax({
            type: "POST",
            url: '/ajax/addfakedownloadcount',
            dataType: 'json',
            data: {
                stock_id: id,
                value: $("#dc-"+id).val(),
                type: $("#type-"+id).val()
            },
            success: function(response){
                alert("Saved: "+response.data.value);
            }
        });
    });
    $(".toplistrestorebutton").click(function(){
        var id = $(this).attr("id").substring(8);
        $.ajax({
            type: "POST",
            url: '/ajax/restorefakedownloadcount',
            dataType: 'json',
            data: {
                stock_id: id,
                type: $("#type-"+id).val()
            },
            success: function(response){
                alert("Restored!");
            }
        });
    });

    /* add category */
        $("#addcategorybutton").click(function(){
			$.ajax({
                type: "POST",
                url: '/ajax/addcategory',
                dataType: 'json',
                data: {
                    name: $("#newcategoryname").val(),
                    type: $("#newcategorytype").val()
                },
                success: function(response){
                    $("#"+response.data.type+"_category_container .category_links").append('<a href="/'+response.data.type+'/'+response.data.name+'" class="other_page">'+response.data.name+'</a>');
                    $("#newcategoryname").val("");
                }
            });
		});


/*select and browse positioned*/

	for(i=0;i<$("select").size();i++){
		// Next line was modified by Peter Hazi at 2008.12.21.
		if($("select:eq("+i+")").attr("class")!="multi_select" && $("select:eq("+i+")").parent().children("input:first").attr("type")=="text")
		$("select:eq("+i+")").parent().children("input:first").attr("value",$("select:eq("+i+") option:eq(0)").html());
	}

	$("select").change(function(){
		$(this).parent().children("input:first").attr("value",$(this).val());
	});
	
	$(".browse_input").keyup(function(){
		$(this).parent().children("input:eq(1)").attr("value",$(this).val());
	});
	
	$(".browse_input").click(function(){
		$(this).parent().children("input:eq(1)").attr("value",$(this).val());
	});

/*equal confirm buttons*/
	var browserUnique=40;
	if ($.browser.msie){
		browserUnique=41;
	}
	jQuery.each(jQuery.browser, function(i, val) {
  		if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.9")
    		browserUnique=70;
	});

	var maxButtonWidth=10;
	var wasInput=false;
	for(j=0; j<$(".confirm_buttons").size(); j++){
		maxButtonWidth=10;
		for(i=0; i<$(".confirm_buttons:eq("+j+") .blue_button").size(); i++){
			if($(".confirm_buttons:eq("+j+") .blue_button:eq("+i+")").width()>maxButtonWidth){
				if($(".confirm_buttons:eq("+j+") .blue_button:eq("+i+")").attr("type")=="button" || $(".confirm_buttons:eq("+j+") .blue_button:eq("+i+")").attr("type")=="submit")
					wasInput=true;
				maxButtonWidth=Number($(".confirm_buttons:eq("+j+") .blue_button:eq("+i+")").width());
			}
		}
		if(wasInput){
			maxButtonWidth=maxButtonWidth+10;
			if($.browser.msie){
				maxButtonWidth=maxButtonWidth+15;
				$(".confirm_buttons:eq("+j+") .button_left_side").css({"margin-left":"20px"});
				browserUnique=browserUnique+20;
				}
		}
		var buttonNumber=$(".confirm_buttons:eq("+j+") td .blue_button").size() + $(".confirm_buttons:eq("+j+") td .gray_button").size();
		var tdSize=buttonNumber*(maxButtonWidth+browserUnique);
		if ($(".confirm_buttons:eq("+j+") .gray_button").size() != 1)
			$(".confirm_buttons:eq("+j+") td").width(tdSize);
		for(i=0; i<$(".confirm_buttons:eq("+j+") .blue_button").size(); i++){
			$(".confirm_buttons:eq("+j+") .blue_button:eq("+i+")").width(maxButtonWidth);
		}
	}
	

/*category handler*/	
	
	$(".category_changer").click(function(){
		var cat_numb=$(this).attr("id").split("_")[1];
		
		/*show valid content*/
		/*$("#video_category_container").css({"display":"none"});
		$("#picture_category_container").css({"display":"none"});
		$("#story_category_container").css({"display":"none"});*/
		switch(cat_numb) {
			case '1':
				//$("#video_category_container").css({"display":"block"}); $("#newcategorytype").val("video");
				$.ajax({type: "POST", url: '/ajax/setselectedcategory', dataType: 'json', data:{category:'video'},
					success: function (data){
							$("#category_container").html(data['data']);
							$(".category_changer").css({"color":"#BBBBBB"});
							$(this).css({"color":"white"});
							$("#category_box .box_border").css({"background":"transparent url('/assets/images/category_cat_"+cat_numb+".png') no-repeat top left"});
							
						}});
			break;
			case '2':			
				//$("#picture_category_container").css({"display":"block"}); $("#newcategorytype").val("picture");
				$.ajax({
					type: "POST",
					url: '/ajax/setselectedcategory',
					dataType: 'json',
					data:{category:'picture'},
					success: function (data){
							$("#category_container").html(data['data']);							
							$(".category_changer").css({"color":"#BBBBBB"});
							$(this).css({"color":"white"});
							$("#category_box .box_border").css({"background":"transparent url('/assets/images/category_cat_"+cat_numb+".png') no-repeat top left"});
							
						}
					});
			break;
			case '3':
				//$("#story_category_container").css({"display":"block"}); $("#newcategorytype").val("story");
				$.ajax({type: "POST", url: '/ajax/setselectedcategory', dataType: 'json', data:{category:'story'},
					success: function (data){
							$("#category_container").html(data['data']);
							$(".category_changer").css({"color":"#BBBBBB"});
							$(this).css({"color":"white"});
							$("#category_box .box_border").css({"background":"transparent url('/assets/images/category_cat_"+cat_numb+".png') no-repeat top left"});
							
						}});
			break;
		}
	});


	/*css to safari*/
	
	if($.browser.safari){
		$(".select_container input").css({
			"margin-top":"-1px",
			"margin-left":"-1px"	
		});
	}
	
	setTimeout("imgValign()",3000);
	
	
	/*fluid text in the webmaster and video_help box (ie7 not work)*/
	
	if(!$.browser.msie){
	
		$("#webmasters_box .box_content p").css({
			"padding-bottom":"10px"
		});
		
		$("#video_help_box .box_content p").css({
			"padding-bottom":"10px"
		});
		
		/**Webmasters Box**/
		$("#webmasters_box .box_content").prepend("<div class='side_height'></div>");
		$("#webmasters_box .box_content .side_height").after("<div class='pattern_01'></div>");
		$("#webmasters_box .box_content .pattern_01").after("<div class='pattern_02'></div>");
		$("#webmasters_box .box_content .pattern_02").after("<div class='pattern_03'></div>");
		$("#webmasters_box .box_content .pattern_03").after("<div class='pattern_04'></div>");
		
		var wmBoxSideHeight=$("#webmasters_box .box_content").height()-80;
		
		$("#webmasters_box .side_height").css({
			"float":"left",
			"clear":"left",
			"height":wmBoxSideHeight+"px",
			"width":"0px"
		});
		
		$("#webmasters_box .pattern_01, #webmasters_box .pattern_02, #webmasters_box .pattern_03, #webmasters_box .pattern_04").css({
			"float":"left",
			"clear":"left",
			"height":"22px",
			"width":"30px"
		});
		
		$("#webmasters_box .pattern_01").css({
			"width": "78px"
		});
		
		$("#webmasters_box .pattern_02").css({
			"width": "85px"
		});
		
		$("#webmasters_box .pattern_03").css({
			"width": "90px"
		});
		
		$("#webmasters_box .pattern_04").css({
			"width": "100px"
		});
		
		
		if(wmBoxSideHeight<$("#webmasters_box .box_content p").height()-80){
			wmBoxSideHeight=$("#webmasters_box .box_content p").height()-75;
			$("#webmasters_box .side_height").css({
				"height":wmBoxSideHeight+"px"
			});
		}
		
		/**Video Help Box**/
		
		var vdBoxSideHeight=$("#video_help_box .box_content").height()-55;
		$("#video_help_box .box_content").prepend("<div class='side_height'></div>");
		$("#video_help_box .box_content .side_height").after("<div class='pattern_01'></div>");
		$("#video_help_box .box_content .pattern_01").after("<div class='pattern_02'></div>");
		$("#video_help_box .box_content .pattern_02").after("<div class='pattern_03'></div>");
		$("#video_help_box .box_content .pattern_03").after("<div class='pattern_04'></div>");
		$("#video_help_box .side_height").css({
			"float":"left",
			"clear":"left",
			"height":vdBoxSideHeight+"px",
			"width":"0px"
		});
		
		$("#video_help_box .pattern_01, #video_help_box .pattern_02, #video_help_box .pattern_03, #video_help_box .pattern_04").css({
			"float":"left",
			"clear":"left",
			"height":"12px",
			"width":"30px"
		});
		
		$("#video_help_box .pattern_01").css({
			"width": "50px"
		});
		
		$("#video_help_box .pattern_02").css({
			"width": "58px"
		});
		
		$("#video_help_box .pattern_03").css({
			"width": "58px"
		});
		
		$("#video_help_box .pattern_04").css({
			"width": "65px"
		});
		
		if(vdBoxSideHeight<$("#video_help_box .box_content p").height()-55){
			vdBoxSideHeight=$("#video_help_box .box_content p").height()-55;
			$("#video_help_box .side_height").css({
				"height":vdBoxSideHeight+"px"
			});
		}
	}
	
	/*choice mobile format*/
	
	$("div.download_mobile img").click(function(){
		downloadConfirm(this);
	});
	
	/*load categories*/
	/*$.ajax({
		type: "POST",
		url: '/ajax/getcategories',
		dataType: 'json',
		data: {},
		success: function(response){
			var html = '';
			if (response.errorcode == 0) {
				
				html = html + '<div id="video_category_container"><div class="category_links">';			
				jQuery.each(response.data.Videoproduct_Models_Product, function() {
			  		html = html + '<a href="/video/' + this.name + '" class="other_page">' + this.translated + '</a>';
				});
				html = html + '</div></div>';
				
				html = html + '<div id="picture_category_container" style="display:none"><div class="category_links">';			
				jQuery.each(response.data.Pictureproduct_Models_Product, function() {
			  		html = html + '<a href="/picture/' + this.name + '" class="other_page">' + this.translated + '</a>';
				});
				html = html + '</div></div>';
				
				html = html + '<div id="story_category_container" style="display:none"><div class="category_links">';			
				jQuery.each(response.data.Storyproduct_Models_Product, function() {
			  		html = html + '<a href="/story/' + this.name + '" class="other_page">' + this.translated + '</a>';
				});
				html = html + '</div></div>';
							
				$("#category_container").append(html);			
			}
		}
	});*/

	/*validate forms*/
	if ($("#upload_form_without_file")) $("#upload_form_without_file").validate({
		rules: {
			tags: { required: true },
			tags2nd: { required: true },
           	nick: { required: true },
           	email: {
			   	required: true,
				email: true
			},
			captcha: {
				required: true,
				rangelength: [5, 5]
			},
			accept: {
				required: true
			}
		},		
		messages: {			
			tags: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" },
			tags2nd: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" },
			nick: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" },
			email : {
				required: "<p class='form-field-error'>"+dictionary.required+"</p>",
				email: "<p class='form-field-error'>"+dictionary.email+"</p>"
			},
			captcha: {
				required: "<p class='form-field-error'>"+dictionary.required+"</p>",
				rangelength: "<p class='form-field-error'>"+dictionary.wronglength+"</p>"
			},
			accept: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" }
     	},     	
     	onkeyup: true,
     	errorPlacement: function(error, element) {
     		if ($(element).attr("name") == "accept") {
				error.appendTo(element.next());
			} else {
				element.after(error);
			}     		
   		}
    });
	if ($("#upload_form_with_file")) $("#upload_form_with_file").validate({
		rules: {
			tags: { required: true },
			tags2nd: { required: true },
           	nick: { required: true },
           	email: {
			   	required: true,
				email: true
			},
			captcha: {
				required: true,
				rangelength: [5, 5]
			},
			uploadcount: { max: 0 },
			uploaded: { min: 1 },
			accept: {
				required: true
			}
		},		
		messages: {			
			tags: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" },
			tags2nd: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" },
			nick: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" },
			email : {
				required: "<p class='form-field-error'>"+dictionary.required+"</p>",
				email: "<p class='form-field-error'>"+dictionary.email+"</p>"
			},
			captcha: {
				required: "<p class='form-field-error'>"+dictionary.required+"</p>",
				rangelength: "<p class='form-field-error'>"+dictionary.wronglength+"</p>"
			},
			uploadcount: { max: "<p class='form-field-error'>"+dictionary.uploadinprogress+"</p>" },
			uploaded: { min: "<p class='form-field-error'>"+dictionary.nofilesuploaded+"</p>" },
			accept: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" }
     	},
     	errorPlacement: function(error, element) {
     		if ($(element).attr("name") == "accept") {
				error.appendTo(element.next());
			} else {
				element.after(error);
			}     		
   		}
	});
	if ($("#contactform")) $("#contactform").validate({
		rules: {
			message: { required: true },
			email: { required: true, email: true },
			captcha: {
				required: true,
				rangelength: [5, 5]
			}
		},		
		messages: {			
			message: { required: "<p class='form-field-error'>"+dictionary.required+"</p>" },
			captcha: {
				required: "<p class='form-field-error'>"+dictionary.required+"</p>",
				rangelength: "<p class='form-field-error'>"+dictionary.wronglength+"</p>"
			},
			email: { required: "<p class='form-field-error'>"+dictionary.required+"</p>", email: "<p class='form-field-error'>"+dictionary.email+"</p>" }
     	},
     	errorPlacement: function(error, element) {
     		element.after(error);
   		}
	});
});



/*Picture_preview to middle*/

 function imgValign(){
 var imgSize=$("li.picture_preview").size(); 
 for(i=0;i<imgSize;i++){
  if($("ul img:eq("+i+")").height()<155 && $("ul img:eq("+i+")").height()!=0)
   $("ul img:eq("+i+")").css({
    "margin-top" :(155-$("ul img:eq("+i+")").height())/2+"px"
   });

 }
 if($("li.picture_preview img:last").width()==0){
  setTimeout("imgValign()",500);
 }

}

/* shoe selector screen for mobile download */
function downloadConfirm(thisis){
	
		var link3GP = $(thisis).parent().children("div").children("a:eq(0)").attr("href");
		var linkMp4 = $(thisis).parent().children("div").children("a:eq(1)").attr("href");
		
		if (!link3gp || !linkMp4) {
			return;
		}
	
		bgWidth=$("html").width();
		bgHeight=$("html").height();
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var moveToCenter;
		if (navigator.appName == "Netscape") moveToCenter=window.pageYOffset+windowHeight/2-100+'px';
		else moveToCenter=document.documentElement.scrollTop+windowHeight/2-105+'px';

		$("body").append("<div id='popupContact'></div>");
		$("body").append("<div id='popupBg'></div>");

		if(bgWidth<windowWidth){
			bgWidth=windowWidth;
		}
		if(bgHeight<windowHeight){
			bgHeight=windowHeight;
		}



		$("#popupContact").css({
			"position": "absolute",
			"z-index": "1000",
			"background-color": "white",
			"width": "275px",
			"height": "192px",
			"top": moveToCenter,
			"left": windowWidth/2-140
 		});

		$("#popupBg").css({
			"width": bgWidth+"px",
			"height": bgHeight+"px",
			"position": "absolute",
			"top": "0px",
			"left": "0px",
			"z-index": "100",
			"background-color": "black",
			"opacity": "0.5",
			"Filter": "Alpha(Opacity=50)"
		});

		$("#popupContact").append("<div class='confirmContent'></div>");
		$("#popupContact").append("<div class='closeConfirm'><img src='/assets/images/close_win.png' /></div>");
		$(".confirmContent").append("<div><a id='3gp_choice' href="+link3GP+"></a><a id='mp4_choice' href="+linkMp4+"></a>");
 		$("#3gp_choice").append("<img src='/assets/images/mobile_v_information.png' /><br/>3GP<br/>("+$(thisis).parent().children("div").children(".file_size:eq(0)").html()+")");
 		$("#mp4_choice").append("<img src='/assets/images/mobile_v_information.png' /><br/>MP4<br/>("+$(thisis).parent().children("div").children(".file_size:eq(1)").html()+")");

 		$(".confirmContent").css({
			"margin": "20px",
			"height": "130px",
			"width": "210px",
			"padding": "10px",
			"border": "2px solid gray",
			"font-size": "14px",
			"overflow": "auto",
			"z-index": "1000",
			"text-align": "center"
		});

		$(".closeConfirm").css({
			"position":"absolute",
			"right":"3px",
			"top":"-10px",
			"width":"25px",
			"height":"25px",
			"font-size":"18px",
			"font-weight":"bold",
			"background-color":"transparent",
			"text-align":"center",
			"cursor":"pointer"
		});

		$(".confirmContent #3gp_choice, .confirmContent #mp4_choice").css({
			"color":"black",
			"text-decoration":"none",
			"font-size":"14px",
			"float":"left",
			"text-align":"center",
			"font-weight":"bold",
			"margin-top":"0px",
			"width":"100px"
		});


		$(".confirmContent img").css({
			"margin-bottom":"10px"
		});

		$(".closeConfirm, #popupContact a").click(function(){
			closeContent();
		});


}

function closeContent(){
	$("#popupContact *").remove();
	$("#popupContact").remove();
	$("#popupBg").remove();
}

function mover() {
	sh=document.getElementById('stathelp');
	if (navigator.appName == "Netscape") sh.style.top=window.pageYOffset+'px';
	else sh.style.top=document.documentElement.scrollTop;
	setTimeout('mover();',1000);
	}
