// JavaScript Document\

function loadUploadFlash(DivId,SrcPath,returnUrl,uploadUrl,totalPhoto,acctype){
	StrContent = '<object id="FlashFilesUpload" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" viewastext="" width="461" height="371"><param name="FlashVars" value="uploadUrl='+uploadUrl+'&amp;fileTypes=Images|*.jpg\;*.jpeg\;*.gif\;*.jpe&amp;uploadButtonVisible=No&amp;redirectUploadUrl='+returnUrl+'&allowedCount=100&dataCount='+totalPhoto+'&userType='+acctype+'&olapicMsg=You cannot upload more than 100 picture. please upgrade your account">';
    StrContent = '<param name="BGColor" value="#f8f6e6"><param name="Movie" value="'+SrcPath+'"><param name="WMode" value="transparent"><param name="Play" value="-1"><param name="Loop" value="-1"><param name="Quality" value="High"><param name="SAlign" value=""><param name="Menu" value="-1"><param name="Base" value=""><param name="AllowScriptAccess" value="always"><param name="Scale" value="ShowAll"><param name="DeviceFont" value="0"><param name="EmbedMovie" value="0"><param name="SWRemote" value=""><param name="MovieData" value=""><param name="SeamlessTabbing" value="1"><param name="Profile" value="0"><param name="ProfileAddress" value=""><param name="ProfilePort" value="0">';
    StrContent = '<embed  wmode="Transparent" id="EmbedFlashFilesUpload" src="'+SrcPath+'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" flashvars="uploadUrl='+uploadUrl+'&amp;fileTypes=Images|*.jpg\;*.jpeg\;*.gif\;*.jpe&amp;uploadButtonVisible=No&amp;redirectUploadUrl='+returnUrl+'&allowedCount=100&dataCount='+totalPhoto+'&userType='+acctype+'&olapicMsg=You cannot upload more than 100 picture. please upgrade your account" width="461" height="371"></object>';
	
	$(DivId).innerHTML = StrContent;
}


var ThumbLst;
function CngClass(obj){
	 obj=document.getElementById(obj);
	 if (ThumbLst) ThumbLst.className='photo-all-thumb-normal';
	 obj.className='photo-all-thumb-over';
	 ThumbLst=obj;
}

function ratethispicture(Id,action){
	getPublicAllPhotos_PhotoById(Id,action);
}


function getPublicAllPhotos_PhotoById(Id,action){
	
	sortby = document.frmallphotoslist.SortBy.value;
	
	authors = document.frmallphotoslist.Authors.value;
	
	AlbumId = document.frmphotoleft.AlbumId.value;
	
	CurrentPreviewId = document.frmphotoleft.CurrentPreviewId.value;
	if(action == 'next'){
		CurrIdent = document.frmphotoleft.CurrentPreviewId.value;
		LastPhotoId =  $("PhotoRight_lastPhoto").value;
		
		if(CurrIdent == LastPhotoId){
		    Page =0;
			if(document.frmallphotoslist.PhotoRight_currentpage){
				Page = parseInt(document.frmallphotoslist.PhotoRight_currentpage.value)+1;
			}
			if(Page !=0)getAllPublicPhotosByPage(Page);
		}
	}
	if(action == 'pre'){
		CurrIdent = document.frmphotoleft.CurrentPreviewId.value;
		FirstPhotoId =  $("PhotoRight_firstPhoto").value;
		if(CurrIdent == FirstPhotoId){
		    Page =0;
			if(document.frmallphotoslist.PhotoRight_currentpage){
				Page = parseInt(document.frmallphotoslist.PhotoRight_currentpage.value)-1;
			}
			if(Page !=0)getAllPublicPhotosByPage(Page);
		}
	}
	var success = function(t){getPublicAllPhotos_PhotoByIdCompleted(t,Id);}
	var failure = function(t){loadFailed(t);}
	var url 	= "ajax/photos.php";
	var pars 	= "op=getallphotosleft&Id="+Id+"&sortby="+sortby+"&Authors="+authors+"&WeddingId="+WeddingId+"&CurrentPreviewId="+CurrentPreviewId+"&AlbumId="+AlbumId+"&action="+action;
	var myAjax 	= new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}
function getPublicAllPhotos_PhotoByIdCompleted(t,Id){ 
   CngClass("thumbid"+Id);
   $("photopreview").innerHTML  = t.responseText;
}

function selcted_albumid(opname,albumid,albumname,hiddenid){	
	var success = function(t){getAjaxUpdateAlbumByPageCompleted(t,albumid,albumname,hiddenid);}
	var failure = function(t){loadFailed(t);}
	var url 	= "ajax/photos.php";
	var pars 	= "op=updatealbum&albid="+albumid+"&hidnid="+hiddenid+"&opname="+opname;
	var myAjax 	= new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});	
}
function getAjaxUpdateAlbumByPageCompleted(t,albumid,albumname,hiddenid){ 
   document.getElementById('select_currentalbum_id').value=albumid;
   document.getElementById('select_listid').value=albumname;
   document.getElementById('sortalbumlist').style.display="none";
  
}


function getuploadmsgPopup(curobj){
     var divPos = new ElementPosition(curobj); 
	 xpos = divPos.x;
	 ypos = divPos.y;
	 
	 if(curobj == 'uploadmsgphoto'){
		xpos = xpos + 200;
	 }else{
		xpos = xpos + 280;
	 }
	 
	 if(curobj == 'uploadmsgphoto'){
		ypos = ypos - 280;
	 }else{
		ypos = ypos + 250; 
	 }
	 
	 document.getElementById(TransLayerId).style.left  = xpos+'px';
	 document.getElementById(TransLayerId).style.top  = ypos+'px';
	 strContent  = '<div class="transparent-layer-loading" style="width:410px"><img src="images/spinner_grey.gif" align="absmiddle" > please wait a moment to get it..</div>'; 
	 document.getElementById(TransLayerId).innerHTML= strContent ;	 
	 document.getElementById(TransLayerId).style.display="block";
	
     var success = function(t){getUplodphotoCompleted(t,curobj);}
	 var failure = function(t){loadFailed(t);}
	 var url 	= SITEGLOBALPATH+"public/ajax/form.php";
	 var pars 	= "op=showuploadphotomsgpopup&";
	 var myAjax 	= new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});}
	 
function getUplodphotoCompleted(t,curobj){
	strContent = t.responseText;
	//alert(t.responseText);
	document.getElementById(TransLayerId).style.display="block";
	document.getElementById(TransLayerId).innerHTML= strContent;
	DivId  = TransLayerId;
	new Effect.BlindDown(DivId, {duration: 1});
	
}


