//mysphoto
function ckmy(){
	var f = document.myslide;
	var ic = 0;
	var aid;
	aid = "";
	if(!f.id.length){
		if(f.id.checked){
			ic = 1;
			id = f.id.value;
		}
	}else{
		for(var i=0;i<f.id.length;i++){
			if (f.id[i].checked==true){
				ic = 1;
				id = f.id[i].value;
				break;
			}
		}
	}
	if(ic==0){
		alert("请选择相册！");
		//return false;
	}else{
		et.getajax_img_ck_my('action.asp?action=myalbum_photo&moliheid='+id);
	}
}

function getp2(){
	var f = document.p;
	var ic = 0;
	jack=0;
	cur_photo_z =0;
	for(var i=0;i<f.url.length;i++){
		if (f.url[i].checked){
			var t = f.url[i].value.split("|");
			sl.addphoto(t[0],t[1],t[2]);
			ic = 1;
			//jack++;
		}
	}
	if(ic==1){
		sl.setcookie("slide_tmp_images",sl.getimginfo());
		sl.Flash_Reload();
		et.closewin();
		//location.href = "upload_success.html";
	}else{
		alert("请选择您要添加的照片！");
	}
}

function getp4(){
	var f = document.p;
	var ic = 0;
	sl.setDragId();
	for(var i=1;i<f.url.length;i++){
			var t = f.url[i].value.split("|");
			sl.addphoto(t[0],t[1],t[2]);
			ic = 1;
	}
	if(ic==1){
		sl.setcookie("slide_tmp_images",sl.getimginfo());
		sl.Flash_Reload();
		et.closewin();
		//location.href = "upload_success.html";
	}else{
		alert("请选择您要添加的照片！");
	}
}//我的图片end
//qq
function ckqq(){
	var f = document.abl;
	var ic = 0;
	var aid;
	aid = "";
	jack=0;
	cur_photo_z=0;
	if(!f.aid.length){
		if(f.aid.checked){
			ic = 1;
			aid = f.aid.value;
		}
	}else{
		for(var i=0;i<f.aid.length;i++){
			if (f.aid[i].checked==true){
				ic = 1;
				aid = f.aid[i].value;
				break;
				jack++;
			}
		}
	}
	total_photo_z = jack;
	if(ic==0){
		alert("请选择相册！");
		//return false;
	}else{
		et.getajax_img_qq_ck('./nget/get_qq_photo.asp?qq='+qq_v+'&aid='+aid);
	}
}
//google 相册
function ckgg(){
	var f = document.abl;
	var ic = 0;
	var aid;
	aid = "";
	jack=0;
	cur_photo_z=0;
	if(!f.aid.length){
		if(f.aid.checked){
			aid = f.aid.value;
			ic = 1;
		}
	}else{
		for(var i=0;i<f.aid.length;i++){
			if (f.aid[i].checked==true){
				ic = 1;
				aid = f.aid[i].value;
				break;
				//jack++;
			}
		}
	}
	//total_photo_z = jack;
	if(ic==0){
		alert("请选择相册！");
		//return false;
	}else{
		et.getajax_img_ck('./nget/get_gg_photo.asp?userid='+f.userid.value+'&aid='+aid);
	}
}

function overlay() {
	et.CreateMask();
	var str = '<div id="help_note" class=""  style="padding:10px;"><b>相册正在抓取，请稍候……</b></div><div id="container_photo" class="" style="display:none;padding:10px"><b>相册图片抓取中，请稍候</b>：正在抓取第<b id="cur_photo"></b>张，共<b id ="total_count"></b>张</div>';
	et.CreateWin(str,"330px");
}

//163
function ck163(){
	var f = document.abl;
	var z = document.getElementById("userid");
	var ic = 0;
	var aid;
	aid = "";
	jack=0;
	cur_photo_z=0;
	if(!f.aid.length){
		if(f.aid.checked){
			aid = f.aid.value;
			ic = 1;
		}
	}else{
		for(var i=0;i<f.aid.length;i++){
			if (f.aid[i].checked==true){
				ic = 1;
				aid = f.aid[i].value;
				break;
				//jack++;
			}
		}
	}
	//total_photo_z = jack;
	if(ic==0){
		alert("请选择相册！");
	}else{
      et.getajax_img_ck('./nget/get_163_photo.asp?userid='+z.value+'&aid='+aid);
	}
}

function sal(obj){
	var f = document.p;
	for(var i=1;i<f.url.length;i++){
		f.url[i].checked = obj;
	}
}

function check(o){
	var obj = o.parentNode;
	var t = obj.getElementsByTagName("input");
	t[0].checked = t[0].checked ? false : true;
}
count =0;
var arr_j =[];
function getp(){
	var f = document.p;
	var ic = 0;
	var aa = 0;
	ddd = f.url.length-1;
	jack=0;
	cur_photo_z =0;
	//相册的单张抓取是出现的问题10:01 2008-7-8
	arr_j = [];
	for(var i=1;i<f.url.length;i++){
		if (f.url[i].checked){
			arr_j.push(f.url[i].value);
		}
	}
	//end  10:01 2008-7-8
	ic = ajax_count(0,f);
	total_count(f);
	if(ic==1){
		sl.setcookie("slide_tmp_images",sl.getimginfo());
		sl.Flash_Reload();
		et.closewin();
		overlay();
	}else{
		alert("请选择您要添加的照片！");
	}
}

//在相册页，直接点提交按钮，提交图片。
function getp3() {
	var f = document.p;
	var ic = 0;
	jack=0;
	cur_photo_z=0;	
	ic = ajax_count2(1,f);
	total_count2(f);
	total_photo_z = jack;
	if(ic==1){
		sl.setcookie("slide_tmp_images",sl.getimginfo());
		sl.Flash_Reload();
		et.closewin();
		overlay();//添加蒙版
	}else{
		alert("请选择您要添加的照片！");
	}
}

function total_count(f) {
	for(var i=1;i<f.url.length;i++){
		if (f.url[i].checked){
			jack++;
		}
	}
	total_photo_z = jack;
}
function ajax_count(start,f) {
	var ic = 0;
	for(j=start;j<arr_j.length;j++) {
		var t = arr_j[j].split("|");
		if (count<1){
			sl.request_addphoto(t['0'],t['1'],t['2'],t['3']+"|"+t['4']);
			count++;
		}else {
			setTimeout(function(){
				ajax_count(j,f);
			},500);
			break;
		}
		ic = 1;
	}
	return ic;
}
function total_count2(f) {
	for(var i=1;i<f.url.length;i++){
		jack++;
	}
	total_photo_z = jack;
}
function ajax_count2(start,f) {
	var ic = 0;
	for(var i=start;i<f.url.length;i++){
		var t = f.url[i].value.split("|");
		if(count<1) {
			sl.request_addphoto(t['0'],t['1'],t['2'],t['3']);
			count++;
		} else{
			setTimeout(function() {
				ajax_count2(i,f);
			},500)
			break;
		}
		ic = 1;
		//jack++;
	}
	return ic;
}

//网络图片
function addpicurl(){
    var s = document.pic.elements;
	var isok=true;
	var photos = new Array();
	for(var i=0;i<s.length;i++){
		if(s[i].type=="text" && s[i].name!="counts" && s[i].value != "" && s[i].value != "http://"){
			if(isimg(s[i].value)){
				photos.push(formatImageUrl(s[i].value));
			}else{
				alert('图片地址不合法');
				isok = false;
				s[i].focus();
				s[i].select();
				break;
			}
		}
	}
	if(isok){
		//parent.sl.setDragId();
		for(var i=0;i<photos.length;i++){
			sl.addphoto("",photos[i],"2");
		}
		sl.setcookie("slide_tmp_images",sl.getimginfo());
		sl.Flash_Reload();
		et.closewin();
		//location.href = "upload_success.html";
	}
	cur_photo_z=0;
	total_photo_z=0;
}
function seturlinfo(v){
	if(v=='' || isNaN(v)){
		alert('请输入你要增加图片的数量，必须为数字！')
		document.pic.counts.value="";
		document.pic.counts.focus();
		return false;
	}
	var content = "";
	for(var i=0;i<v;i++){
		content +="<br /><input type=\"text\" name=\"url\" value=\"http://\" style=\"width:360px;margin-bottom:5px;\" onfocus=\"cinput(this);\" />";
	}
	document.getElementById("urlinfo").innerHTML += content;
	return false;
}

function cinput(obj){
	if (obj.value=="http://"){
		obj.select();
	}
}//网络图片end

//一级qq页面
function getHTTPObject() {
  var xhr = false;
  if (window.XMLHttpRequest) {
    xhr = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        xhr = false;
      }
    }
  }
  return xhr;
}

function grabFile(file) {
  var request = getHTTPObject();
  if (request) {
    request.onreadystatechange = function() {
      parseResponse(request);
    };
    request.open("GET", file, true);
    request.send(null);
    return true;
  } else {
    return false;
  }
}
function parseResponse(request) {
  if (request.readyState == 4) {
    if (request.status == 200 || request.status == 304) {
       var data = request.responseXML;
	   var albums = data.getElementsByTagName("album");
	   var details = document.getElementById("qqxml");
	   while (details.hasChildNodes()) {
        details.removeChild(details.lastChild);
      }
	 //qq 号
	 var owner = data.getElementsByTagName('owner')[0].firstChild.nodeValue;
	  if(albums.length<2) {
		xiu_20 = '<p>非常抱歉，该相册不存在！</p>'
		details.innerHTML = xiu_20;
		return
	 }
	 var xiu_20 = '<input type="hidden" name="qq" value="'+owner+'"/>';
	 //数据id号
	 for (var i=0; i<albums.length-1; i++) {
	  //取数据
	  var pre = data.getElementsByTagName("pre")[i].firstChild.nodeValue;
	  var image_pre = "http://mo.molihe.com/upload/img/" + pre.replace("?","|");
	  var name = data.getElementsByTagName("name")[i].firstChild.nodeValue;
	 //alert(name);
      var total = data.getElementsByTagName("total")[i].firstChild.nodeValue;
	  var id =data.getElementsByTagName("id")[i].firstChild.nodeValue;
	  var a_link = "javascript:et.getajax_img_qq('./nget/get_qq_album.asp?qq="+owner+"&aid="+id+"')";
	  //添数据
	  var temp = '<div class="xiu_20"><a href="'+a_link+'">' +
				 '<img src="'+image_pre+'" width="80px" height="80px"/></a><br/>' +
				 '<input type="radio" name="aid" value="'+id+'"/>'+
				 name +'  '+ '共' + total +'张' + '</div>';
	  xiu_20 = xiu_20 + temp;
	}
	details.innerHTML = xiu_20;
    }
  }
}

//qq二级页面
function grabFile2(file) {
  var request = getHTTPObject();
  if (request) {
    request.onreadystatechange = function() {
	  parseResponse2(request);
    };
    request.open("GET", file, true);
    request.send(null);
  }
}

function parseResponse2(request) {
  if (request.readyState == 4) {
    if (request.status == 200 || request.status == 304) {
      var data = request.responseXML;
      var pics = data.getElementsByTagName("pic");
	  var details = document.getElementById("qqixml");
		while (details.hasChildNodes()) {
        details.removeChild(details.lastChild);
      }
	  var xiu_20 = '<input type="checkbox" name="url" value="" style="display:none;"/>';
	  for (var i=0; i<pics.length; i++) {
	  var pre = data.getElementsByTagName("pre")[i+1].firstChild.nodeValue;
	  var url = data.getElementsByTagName("url")[i+1].firstChild.nodeValue;
	  var name = data.getElementsByTagName("name")[i+1].firstChild.nodeValue;
	   var url2 = "http://mo.molihe.com/upload/img/" + pre.replace("?","|");
	   var input_value = name + '|' + url +'|2|' + url2;
	  var temp = '<div class="xiu_20">'+
				 '<img width="80px" height="80px; "onclick="check(this);" src="'+url2+'"/><br/>'+
				 '<input type="checkbox" name="url" value="'+input_value+'"/>'+
				 name +'</div>'
	  xiu_20 = xiu_20 + temp;
	}
	details.innerHTML = xiu_20;
    }
  }
}

function grabFile3(file) {
  var request = getHTTPObject();
  if (request) {
    request.onreadystatechange = function() {
	  parseResponse3(request);
    };
    request.open("GET", file, true);
    request.send(null);
  }
}
function parseResponse3(request) {
  if (request.readyState == 4) {
    if (request.status == 200 || request.status == 304) {
      var data = request.responseXML;
      var pics = data.getElementsByTagName("pic");
	  var details = document.getElementById("qqixml");
		while (details.hasChildNodes()) {
        details.removeChild(details.lastChild);
      }
	  var xiu_20 = '<input type="checkbox" name="url" value="" style="display:none;"/>';
	  for (var i=0; i<pics.length; i++) {
	  var pre = data.getElementsByTagName("pre")[i+1].firstChild.nodeValue;
	  var url = data.getElementsByTagName("url")[i+1].firstChild.nodeValue;
	  var name = data.getElementsByTagName("name")[i+1].firstChild.nodeValue;
	   var url2 = "http://mo.molihe.com/upload/img/" + pre.replace("?","|");
	   var input_value = name + '|' + url +'|2|' + url2;
	  var temp = '<div class="xiu_20">'+
				 '<img width="80px" height="80px; "onclick="check(this);" src="'+url2+'"/><br/>'+
				 '<input type="checkbox" name="url" value="'+input_value+'"/>'+
				 name +'</div>'
	  xiu_20 = xiu_20 + temp;
	}
	details.innerHTML = xiu_20;
	getp3();
    }
  }
}


