// 公用的js函数
// fancybox实现alert功能的方法
function fancyAlert(msg,state) {//state弹出框样式0失败1成功2普通
	var cssStr;
	if(state==0){
		cssStr = "<div class='popup_header_13' style=\"margin:1px;\">";
	}else if(state==1){
		cssStr = "<div class='popup_header_14' style=\"margin:1px;\">";
		setTimeout(function() {
			jQuery.fancybox.close();
		}, 1000);
	}else if(state==2){
		cssStr = "<div class='popup_header_15' style=\"margin:1px;\">";	
	}
	jQuery.fancybox({
		"modal" : true,
		"content" : cssStr
				+ "<span class='span_margin_left'>"+msg+"</span>"
				+ "<div style=\"text-align:right;margin-top:8px;margin-right:20px;\">"
				+ "<input type=\"button\" class=\"input_btn\" onclick=\"jQuery.fancybox.close();\" value=\"确定\" />"
				+ "</div></div>"
	});
}
function fancyAlertErro(msg) {
	jQuery.fancybox({
		"modal" : true,
		"showCloseButton" : false,
		"content" : "<div style=\"margin:1px;width:240px;\">"
				+ msg
				+ "<div style=\"text-align:right;margin-top:10px;\">"
				+ "</div></div>"
	});
	setTimeout(function(){jQuery.fancybox.close();},1500);
}
/**
 * 操作异常警告提示框
 * @param {提示框标题} msg_title
 * @param {提示框内容} msg_content
 * @param {提示框宽度} msn_width
 */
function fancyAlertWarn(msg_title,msg_content,msn_width) {
	jQuery.fancybox({
		"modal" : true,
		"content" : '<div  class="fancy_popup_p" style="width:'+msn_width+'px;">'
                    	+'<div class="fancy_popup_header fancy_popup_header_2">'
                        	+'<h4 style="border-bottom: 1px solid #CCCCCC;margin:0 20px 0 40px;width: 75%;*width: 71%;text-align: left;">'+msg_title+'</h4>'
                        +'</div>'
                        +'<div class="fancy_popup_item">'
                        	+'<p class="fancy_pop_up_alert">'+msg_content+'</p>'
                       +' </div>'
                       +' <div class="fancy_addgroup_cmd fancy_editgroup_cmd">'
                               +'<input type="button" class="fancy_input_btn" onclick=\"jQuery.fancybox.close();\" value="确定" id="">'
                        +'</div>'           
                    +'</div>'
	});
}

// fancybox实现confirm功能的方法
function fancyConfirm(msg, callback, title, state) {
	var ret;
	var cssStr;
	if(state == 1){
		cssStr = "<div class='popup_header popup_header_17'><h4>";
	}else{
		cssStr = "<div class='popup_header popup_header_2'><h4>";
	}
	jQuery.fancybox({
		modal : true,
		content : "<div  class='album_popup_p'>"
				+ cssStr
				+ title
				+ "</h4></div>"
				+ "<div class='album_popup_item'><p class='pop_up_alert'>"
				+ msg
				+ "</p></div>"
				+ "<div class='friends_addgroup_cmd friends_editgroup_cmd'>"
				+ "<input type='button' class='input_btn' value='确定' id='fancyConfirm_ok'>"
				+ "</div>"
				//+ "<div class='friends_addgroup_cmd friends_editgroup_cmd album_popup_input_btn'>"
				//+ "<input type='button' class='input_btn' value='返回' id='fancyConfirm_cancel'>"
				//+ "</div>"
				+ "</div>",
		onComplete : function() {
			jQuery("#fancyConfirm_cancel").click(function() {
						ret = false;
						jQuery.fancybox.close();
					});
			jQuery("#fancyConfirm_ok").click(function() {
						ret = true;
						jQuery.fancybox.close();
					});
		},
		onClosed : function() {
			callback.call(this, ret);
		}
	});
}

function fancyAlertPic(pic_url, contents, vote_item_num, ischecked, isOver,pic_link ) {
	var _link = "" ;
	if(pic_link != "http://" && pic_link != ""  && pic_link != null && pic_link != "null"){
		_link = '<a href='+pic_link+' target="_blank">详情</a>' ;
	}
	if(vote_item_num == "1"){
		if(isOver == 0){
			jQuery.fancybox({
				"modal" : true,
				"content" : '<div class=\"vote_popup_p\">'
							+ '<div class=\"vote_popup_aline vote_popup_previous\"><a id=\"prev\">&gt;&gt;上一张</a></div>'
							+ '<div class=\"vote_popup_aline vote_popup_next\"><a id=\"next\">下一张&gt;&gt;</a></div>'
		                    + '<div style=\"text-align:center;\"><img src=\"'+ pic_url +'\" class=\"vote_big_pic\" onerror=\"this.src=\''+getAlbumImgOnError()+'\'\"></div>' 
		                    + '<div class=\"vote_popup_box overflow_hidden\">'
		                    + '<input type=\"radio\" id=\"pic_input\">'
		                    + '<span>' + contents + '</span>'
		                    + _link
		                    + '</div>'
		                    + '</div>'
			});
		}else{
			jQuery.fancybox({
				"modal" : true,
				"content" : '<div class=\"vote_popup_p\">'
							+ '<div class=\"vote_popup_aline vote_popup_previous\"><a id=\"prev\">&gt;&gt;上一张</a></div>'
							+ '<div class=\"vote_popup_aline vote_popup_next\"><a id=\"next\">下一张&gt;&gt;</a></div>'
		                    + '<div style=\"text-align:center;\"><img src=\"'+ pic_url +'\" class=\"vote_big_pic\" onerror=\"this.src=\''+getAlbumImgOnError()+'\'\"></div>' 
		                    + '<div class=\"vote_popup_box overflow_hidden\">'
		                    + '<input type=\"radio\" id=\"pic_input\" disabled=\"\">'
		                    + '<span>' + contents + '</span>'
		                    + _link
		                    + '</div>'
		                    + '</div>'
			});
		}
		if(ischecked == true){
			$("input#pic_input").attr("checked", true);
		}
	}else {
		if(isOver == 0){
			jQuery.fancybox({
				"modal" : true,
				"content" : '<div class=\"vote_popup_p\">'
							+ '<div class=\"vote_popup_aline vote_popup_previous\"><a id=\"prev\">&gt;&gt;上一张</a></div>'
							+ '<div class=\"vote_popup_aline vote_popup_next\"><a id=\"next\">下一张&gt;&gt;</a></div>'
		                    + '<div style=\"text-align:center;\"><img src=\"'+ pic_url +'\" class=\"vote_big_pic\" onerror=\"this.src=\''+getAlbumImgOnError()+'\'\"></div>' 
		                    + '<div class=\"vote_popup_box overflow_hidden\">'
		                    + '<input type=\"checkbox\" id=\"pic_input\">'
		                    + '<span>' + contents + '</span>'
		                    + _link
		                    + '</div>'
		                    + '</div>'
			});
		}else {
			jQuery.fancybox({
				"modal" : true,
				"content" : '<div class=\"vote_popup_p\">'
							+ '<div class=\"vote_popup_aline vote_popup_previous\"><a id=\"prev\">&gt;&gt;上一张</a></div>'
							+ '<div class=\"vote_popup_aline vote_popup_next\"><a id=\"next\">下一张&gt;&gt;</a></div>'
		                    + '<div style=\"text-align:center;\"><img src=\"'+ pic_url +'\" class=\"vote_big_pic\" onerror=\"this.src=\''+getAlbumImgOnError()+'\'\"></div>' 
		                    + '<div class=\"vote_popup_box overflow_hidden\">'
		                    + '<input type=\"checkbox\" id=\"pic_input\" disabled=\"\">'
		                    + '<span>' + contents + '</span>'
		                    + _link
		                    + '</div>'
		                    + '</div>'
			});
		}
		if(ischecked == true){
			$("input#pic_input").attr("checked", true);
		}
	}
}
function fancyAlertPhoto(pic_url) {
			jQuery.fancybox({
				"modal" : true,
				"content" : '<div class=\"vote_popup_p\">'
							+ '<div class=\"vote_popup_aline vote_popup_previous\"><a id=\"prev\">&gt;&gt;上一张</a></div>'
							+ '<div class=\"vote_popup_aline vote_popup_next\"><a id=\"next\">下一张&gt;&gt;</a></div>'
		                    + '<div style=\"text-align:center;\"><img src=\"'+ pic_url +'\" class=\"vote_big_pic\" onerror=\"this.src=\''+getAlbumImgOnError()+'\'\"></div>' 
		                    + '</div>'
		                    + '</div>'
			});
	
}

$(function(){
	  
	// 弹出页面
	$("#fancyiframe").fancybox({
	'width':'75%',
	'height':'75%',
	'autoScale':false
});

});
