// JavaScript Document

var http_check 	= (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");

var CONTENTDIV	= "content";

var SCREENHEIGHT= screen.availHeight;

var SCREENWIDTH = screen.width;

var x = 0;

var y = 0;



var imgURL='';

var imgWid='';

var imgHei='';

var imgId ='';





var nVer = navigator.appVersion;

var nAgt = navigator.userAgent;

var browserName  = '';

var fullVersion  = 0;

var majorVersion = 0;



// In Internet Explorer, the true version is after "MSIE" in userAgent

if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {

	browserName  = "IE";

	fullVersion  = parseFloat(nAgt.substring(verOffset+5));

	majorVersion = parseInt(''+fullVersion);

}



// In Opera, the true version is after "Opera"

else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {

	browserName  = "Opera";

	fullVersion  = parseFloat(nAgt.substring(verOffset+6));

	majorVersion = parseInt(''+fullVersion);

}



// In Firefox, the true version is after "Firefox" 

else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {

	browserName  = "Firefox";

	fullVersion  = parseFloat(nAgt.substring(verOffset+8));

	majorVersion = parseInt(''+fullVersion);

}

// In most other browsers, "name/version" is at the end of userAgent 

else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) {

	browserName  = nAgt.substring(nameOffset,verOffset);

	fullVersion  = parseFloat(nAgt.substring(verOffset+1));

	if (!isNaN(fullVersion)) majorVersion = parseInt(''+fullVersion);

	else {fullVersion  = 0; majorVersion = 0;}

}



// Finally, if no name and/or no version detected from userAgent...

if (browserName.toLowerCase() == browserName.toUpperCase() || fullVersion==0 || majorVersion == 0 ){

	browserName  = navigator.appName;

	fullVersion  = parseFloat(nVer);

	majorVersion = parseInt(nVer);

}

	

function coordinates(event){

	x = event.screenX;

	y = event.screenY;

	//alert('X: '+x+' || Y: '+y);

}



///////////////////////////////////////////////////////////////

// calculate the current window width //

function pageWidth() {

	return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;

}



// calculate the current window height //

function pageHeight() {

	return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;

}



// calculate the current window vertical offset //

function topPosition() {

	return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;

}



// calculate the position starting at the left of the window //

function leftPosition() {

	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;

}

////////////////////////////////////////////////////////////////





/*===============================================================*/

//=== 		This code for float the div		======================



var ns = (navigator.appName.indexOf("Netscape") != -1);

var d = document;

function JSFX_FloatDiv(id, sx, sy)

{

	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];

	var px = document.layers ? "" : "px";

	window[id + "_obj"] = el;

	if(d.layers)el.style=el;

	el.cx = el.sx = sx;el.cy = el.sy = sy;

	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};



	el.floatIt=function()

	{

		var pX, pY;

		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 

		document.documentElement && document.documentElement.clientWidth ? 

		document.documentElement.clientWidth : document.body.clientWidth;

		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 

		document.documentElement.scrollTop : document.body.scrollTop;

		if(this.sy<0) 

		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 

		document.documentElement.clientHeight : document.body.clientHeight;

		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;

		this.sP(this.cx, this.cy);

		setTimeout(this.id + "_obj.floatIt()", 40);

	}

	return el;

}

/*===============================================================*/





function isSpecialChars(str){

	specialchars=".,|!@#$%^&*()~`'?;:";

	for (var i = 0; i < str.length; i++) {

		if (specialchars.indexOf(str.charAt(i)) != -1) {

			return 0;

		}

	}

}





//+++++++++	This function return the left and top position of div

function GetLeftTopPosition(obj)

{	

    var topValue= 0,leftValue= 0;

    while(obj){

		leftValue+= obj.offsetLeft;

		topValue+= obj.offsetTop;

		obj= obj.offsetParent;

    }

	finalvalue = leftValue+"::"+topValue;

    return finalvalue;

}

//+++++++++++++++++++++++++++++++++++++++++++







//+++++++++  This function return the page height and width start here ++++++++++++++++++++//

function getPageSize(){

	

	var xScroll, yScroll;

	

	if (window.innerHeight && window.scrollMaxY) {	

		xScroll = document.body.scrollWidth;

		yScroll = window.innerHeight + window.scrollMaxY;

	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac

		xScroll = document.body.scrollWidth;

		yScroll = document.body.scrollHeight;

	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari

		xScroll = document.body.offsetWidth;

		yScroll = document.body.offsetHeight;

	}

	

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer

		windowWidth = self.innerWidth;

		windowHeight = self.innerHeight;

	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode

		windowWidth = document.documentElement.clientWidth;

		windowHeight = document.documentElement.clientHeight;

	} else if (document.body) { // other Explorers

		windowWidth = document.body.clientWidth;

		windowHeight = document.body.clientHeight;

	}	

	

	// for small pages with total height less then height of the viewport

	if(yScroll < windowHeight){

		pageHeight = windowHeight;

	} else { 

		pageHeight = yScroll;

	}

	

	// for small pages with total width less then width of the viewport

	if(xScroll < windowWidth){	

		pageWidth = windowWidth;

	} else {

		pageWidth = xScroll;

	}

	

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	return arrayPageSize;

}

//+++++++++  This function return the page height and width end here ++++++++++++++++++++//







//+++ This function is for show the actual image

function openBigImg(divId){

	

	var fo_nm 	= document.getElementById('folNam').value;

	var imgNm 	= document.getElementById('imgNmId').value;

	

	var imgPath = 'tuna/'+fo_nm+'/'+imgNm;

	

	var imgCapt	= document.getElementById('imgCap').value;

	document.getElementById('cpId').innerHTML = imgCapt;

	

	var imgObj 	= document.getElementById('bigImgSrc'); 

	imgObj.src  = imgPath;

	

	var imgH	= document.getElementById('imgHei').value;

	var imgW	= document.getElementById('imgWid').value;

	var scrObj	= document.getElementById('scrollDiv');

		

	if(imgH > 600){

		scrObj.style.height = '604px';

		var imgW = parseInt(imgW) + 17;

	}else{

		imgH = parseInt(imgH)+5;

		scrObj.style.height = parseInt(imgH)+'px';

	}

	if(imgW > 900){

		scrObj.style.width  = '900px';	

	}else{		

		scrObj.style.width  = parseInt(imgW)+'px';

	}

		

	var obj 	= document.getElementById(divId);

	obj.style.display = 'block';

			

	var width 			= pageWidth();	

	var height 			= pageHeight();	

	var left 			= leftPosition(); 

	var top 			= topPosition();

	var dialogwidth 	= obj.offsetWidth;

	var dialogheight 	= obj.offsetHeight;

	var topposition 	= top + (height / 2) - (dialogheight / 2);

	var leftposition 	= left + (width / 2) - (dialogwidth / 2);

	obj.style.top 		= "170px";

	obj.style.left 		= "170px";

	

	var cntObj 	  		= document.getElementById(CONTENTDIV);

	var cntHeight 		= cntObj.offsetHeight;

	var cntWidth		= cntObj.offsetWidth;

	

	if(SCREENHEIGHT == '994'){

		

		if(cntHeight < 1000 && cntHeight > 950){

			cntHeight = SCREENHEIGHT - 10;	

		}else if(cntHeight > 1000){

			cntHeight = cntHeight;

		}else{

			cntHeight = SCREENHEIGHT - 140;

		}

	}else if(SCREENHEIGHT == '738'){

		

		if(cntHeight > 700  && cntHeight < 750){			

			cntHeight = SCREENHEIGHT;

		}else if(cntHeight > 750 ){			

			cntHeight = cntHeight;

		}else if(cntHeight < SCREENHEIGHT){

			cntHeight = SCREENHEIGHT - 140;

		}else{			

			cntHeight = SCREENHEIGHT;

		}

	}

	

	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";

	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";

	

	document.getElementById("div_loading").style.display = 'block';	

	return false;

}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





//+++ This function is for show delete album pop up
function del_album(showDiv, alId, relativeDivId){
	document.getElementById("tErrMsg").innerHTML = '';
	document.getElementById("delSKey").value 	 = '';
	document.getElementById('hAlId').value		 = alId;
	var obj 		  	= document.getElementById(showDiv);
	var relObj		= document.getElementById(relativeDivId);
	document.getElementById("alb_rel_div_id").value=relativeDivId;
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
	var openDivLeft = (divLeft+15);
	var openDivTop 	= (divTop-90);
	obj.style.top 	  = openDivTop+'px';
	obj.style.left 	  = openDivLeft+'px';
	//obj.style.display 	= 'block';
	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';	
   $("#div_loading").fadeIn(2000);
	return false;
}

function del_album_17dec09_old(divId, alId){
	document.getElementById("tErrMsg").innerHTML = '';

	document.getElementById("delSKey").value 	 = '';

	document.getElementById('hAlId').value		 = alId;	

			

	var obj 	= document.getElementById(divId);

	obj.style.display = 'block';

			

	var width 			= pageWidth();	

	var height 			= pageHeight();	

	var left 			= leftPosition(); 

	var top 			= topPosition();

	var dialogwidth 	= obj.offsetWidth;

	var dialogheight 	= obj.offsetHeight;

	var topposition 	= top + (height / 2) - (dialogheight / 2);

	var leftposition 	= left + (width / 2) - (dialogwidth / 2);

	obj.style.top 		= "170px";

	obj.style.left 		= "170px";

	

	var cntObj 	  		= document.getElementById(CONTENTDIV);

	var cntHeight 		= cntObj.offsetHeight;

	var cntWidth		= cntObj.offsetWidth;

	

	if(SCREENHEIGHT == '994'){

		

		if(cntHeight < 1000 && cntHeight > 950){

			cntHeight = SCREENHEIGHT - 10;	

		}else if(cntHeight > 1000){

			cntHeight = cntHeight;

		}else{

			cntHeight = SCREENHEIGHT - 140;

		}

	}else if(SCREENHEIGHT == '738'){

		

		if(cntHeight > 700  && cntHeight < 750){			

			cntHeight = SCREENHEIGHT;

		}else if(cntHeight > 750 ){			

			cntHeight = cntHeight;

		}else if(cntHeight < SCREENHEIGHT){

			cntHeight = SCREENHEIGHT - 140;

		}else{			

			cntHeight = SCREENHEIGHT;

		}

	}

	

	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";

	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";

	

	document.getElementById("div_loading").style.display = 'block';

	

	var float_left = (SCREENWIDTH / 2) - 120;

	var float_top  = (SCREENHEIGHT / 3) - 120;

	JSFX_FloatDiv(divId, float_left,float_top).floatIt();

	return false;

}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++



//+++ This function is for check album securitu key

function delTuPhAl(divId, type){
 	if(type == 'Y'){
 		var delId	= document.getElementById("hAlId").value;
 		var s_key	= document.getElementById("delSKey").value;
 		var check      = document.getElementById("check").value;
  		s_key		= rm_trim(s_key);		
 		if(s_key == ''){
 			var msg = 'Enter album security key';
 			document.getElementById("tErrMsg").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
 			return false;
 		}else{
 			document.getElementById("tErrMsg").innerHTML = '';	
 		}
		var check      = document.getElementById("check").value;
		if(check == ''){
 			var msg = 'Enter code.';
 			document.getElementById("tErrMsg").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
 			return false;
 		}else{
 			document.getElementById("tErrMsg").innerHTML = '';	
 		}
 		/*if(check != '')
		{
			var casechanged  =	check.toUpperCase();
			var checkvalue = hex_md5(casechanged);
 			var captchavalue = document.captchaForm.captcha.value;
			if(checkvalue != captchavalue){
				var msg = "invalid code.try again.";
				document.getElementById("tErrMsg").innerHTML ="<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
				return false;
			}
		}*/
  		var url = "check-tuna-key.php?aid="+delId+"&sid="+s_key+"&code="+check;
 		//alert(url);return false;
 		http_check.open("GET", url, true);				
 		http_check.onreadystatechange = function test(){					
 			if(http_check.readyState == 4) {
 				var response = http_check.responseText;
 				//alert(response);
 				if (response == 101){
					var msg = "invalid code.try again.";
					document.getElementById("tErrMsg").innerHTML ="<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
					return false;
				} else if (response == 1){
 					//document.getElementById(divId).style.display = 'none';
 					//document.getElementById("div_loading").style.display = 'none';	
					$("#"+divId).fadeOut(2000);
					$("#div_loading").fadeOut(2000);
 					window.location = 'tuna.php?tai='+delId;
 				}else{										
 					messg = 'Album security key is wrong.';
 					document.getElementById("tErrMsg").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+messg+"</font>";									
 					return false;
 				}
 			}
 		}				
 		http_check.send(null);		
  	}else{
 		//document.getElementById(divId).style.display = 'none';
 		//document.getElementById("div_loading").style.display = 'none';
		$("#"+divId).fadeOut(2000);
		$("#div_loading").fadeOut(2000);
 	}	
 }

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



//+++ This function is for resend album sequrity key pop up
function resendAlbumSequrityKey(divId,divid2){
	document.getElementById(divid2).style.display = 'none';
	var obj 	= document.getElementById(divId);
 	document.getElementById("delSKey").value = '';
	var relID		= document.getElementById("alb_rel_div_id").value;
    var relObj		= document.getElementById(relID);
 	var divPos 		= GetLeftTopPosition(relObj);
 	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
 	var openDivLeft = (divLeft);
	var openDivTop 	= (divTop-160);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+divId).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	parent.doIframe();
	return false;
}

//+++ This function is for show delete photo pop up
function del_albumPhoto(showDiv,id,relativeDivId){
 	document.getElementById("hAlId").value=	id;
	document.getElementById("hAlbId").value=	id;
	document.getElementById("delSKey").value = '';
	var obj 		  	= document.getElementById(showDiv);
	var relObj		= document.getElementById(relativeDivId);
 	document.getElementById("alb_rel_div_id").value= relativeDivId;
	var divPos 		= GetLeftTopPosition(relObj);
 	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
	var openDivLeft = (divLeft+15);
	var openDivTop 	= (divTop-170);
	obj.style.top 	  = openDivTop+'px';
	obj.style.left 	  = openDivLeft+'px';
	//obj.style.display 	= 'block';
	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';	
	$("#div_loading").fadeIn(2000);
	parent.doIframe();
	return false;
}

function del_albumPhoto_17dec09Old(divId,id){

	

	document.getElementById("hAlId").value=	id;

	document.getElementById("delSKey").value = '';

	var obj 	= document.getElementById(divId);

	obj.style.display = 'block';

	//document.getElementById("hAlId")=	id;

	

			

	var width 			= pageWidth();	

	var height 			= pageHeight();	

	var left 			= leftPosition(); 

	var top 			= topPosition();

	var dialogwidth 	= obj.offsetWidth;

	var dialogheight 	= obj.offsetHeight;

	var topposition 	= top + (height / 2) - (dialogheight / 2);

	var leftposition 	= left + (width / 2) - (dialogwidth / 2);

	obj.style.top 		= "170px";

	obj.style.left 		= "170px";

	

	var cntObj 	  		= document.getElementById(CONTENTDIV);

	var cntHeight 		= cntObj.offsetHeight;

	var cntWidth		= cntObj.offsetWidth;

	

	if(SCREENHEIGHT == '994'){

		

		if(cntHeight < 1000 && cntHeight > 950){

			cntHeight = SCREENHEIGHT - 10;	

		}else if(cntHeight > 1000){

			cntHeight = cntHeight;

		}else{

			cntHeight = SCREENHEIGHT - 140;

		}

	}else if(SCREENHEIGHT == '738'){

		

		if(cntHeight > 700  && cntHeight < 750){			

			cntHeight = SCREENHEIGHT;

		}else if(cntHeight > 750 ){			

			cntHeight = cntHeight;

		}else if(cntHeight < SCREENHEIGHT){

			cntHeight = SCREENHEIGHT - 140;

		}else{			

			cntHeight = SCREENHEIGHT;

		}

	}

	

	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";

	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";

	

	document.getElementById("div_loading").style.display = 'block';

	

	var float_left = (SCREENWIDTH / 2) - 120;

	var float_top  = (SCREENHEIGHT / 3) - 120;

	JSFX_FloatDiv(divId, float_left,float_top).floatIt();

	return false;

}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++



//+++ This function is for check the security key of photo album

function delTuPh(divId, type){
 	document.getElementById("tpErrMsg").innerHTML = '';
 	if(type == 'Y'){
 		var h_img_id	= document.getElementById("hAlId").value;	
 		var h_alb_id	= document.getElementById('alI').value;	
  		var s_key		= document.getElementById("delSKey").value;
 		var checkVal      = document.getElementById("check").value;
 		s_key		= rm_trim(s_key);		
 		if(s_key == ''){
 			var msg = 'All fields are required';
 			document.getElementById("tpErrMsg").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
 			return false;
 		}else{
 			document.getElementById("tpErrMsg").innerHTML = '';	
 		}
 		if(checkVal == ''){
 			var msg = 'All fields are required.';
 			document.getElementById("tpErrMsg").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
 			return false;
 		}
 		
 		var url = "check-tuna-key.php?aid="+h_alb_id+"&sid="+s_key+"&code="+checkVal;
 		//alert(url);//return false;
 		http_check.open("GET", url, true);				
 		http_check.onreadystatechange = function test(){					
 			if(http_check.readyState == 4) {
 				var response = http_check.responseText;
 			//alert(response);//return false;
 				if (response == 101){
					var msg = "invalid code, try again...";
					document.getElementById("tpErrMsg").innerHTML ="<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
					return false;
				}else if (response == 1){
 					//document.getElementById(divId).style.display = 'none';
 					//document.getElementById("div_loading").style.display = 'none';						
					$("#"+divId).fadeOut(2000);
					$("#div_loading").fadeOut(2000);
 					window.location = 'tuna-photos.php?daid='+h_alb_id+'&diid='+h_img_id;		
 				}else{										
 					messg = 'Album security key is wrong.';
 					document.getElementById("tpErrMsg").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+messg+"</font>";									
 					return false;
 				}
 			}
 		}				
 		http_check.send(null);		
  	}else{
 		//document.getElementById(divId).style.display = 'none';
 		//document.getElementById("div_loading").style.display = 'none';		
		$("#"+divId).fadeOut(2000);
		$("#div_loading").fadeOut(2000);
 	}
 }

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

function closeResendKeypopup(divId){
 		//document.getElementById(divId).style.display = 'none';
		//document.getElementById("div_loading").style.display = 'none';
		$("#"+divId).fadeOut(2000);
		$("#div_loading").fadeOut(2000);
 }



//+++ This fuction is for show login pop up div

function showLoginPopUp(divId)
 {	
 	var pageDet = getPageSize();
 	var pagWid = pageDet[0];
 	var pagHei = pageDet[1];
 	var winWid = pageDet[2];
 	var winHei = pageDet[3];		
 	var popUpWidth 		= $(divId).getWidth();
 	var popUpHeight		= $(divId).getHeight();	
 	var topposition 	= (winHei / 2) - (popUpHeight / 2);
 	var leftposition 	= (winWid / 2) - (popUpWidth / 2);
 	$(divId).show();	
 	document.getElementById("tunaMaskDivId").style.height = pagHei+"px";
 	document.getElementById("tunaMaskDivId").style.width  = pagWid+"px";
 	$("div_loading").show();
 	JSFX_FloatDiv(divId, leftposition,topposition).floatIt();
 	return false;
 }

//+++ This fuction is for show post comments popup

function showCommentPopUp(showDiv,relativeDivId)
{	
 	document.getElementById("comErrId").innerHTML = '';
	var obj 		  	= document.getElementById(showDiv);
 	var relObj		= document.getElementById(relativeDivId);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
	var openDivLeft = (divLeft+320);
	var openDivTop 	= (divTop-230);
	obj.style.top 	  = openDivTop+'px';
	obj.style.left 	  = openDivLeft+'px';
	//obj.style.display 	= 'block';
 	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';	
 	$("#div_loading").fadeIn(2000);
	return false;

}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++



function tunaLogin(){

	

	var errCnt 	= 0;

	var u_name	= document.getElementById("tu_name").value;

	u_name		= rm_trim(u_name);

	

	if(u_name == ''){

		errCnt++;

	}

	

	var u_pass	= document.getElementById("tu_pass").value;

	u_pass		= rm_trim(u_pass);

	

	if(u_pass == ''){

		errCnt++;

	}

	

	if(errCnt > 0){

		var msg = 'All fields are required.';

		document.getElementById("loErrDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";

		return false;

	}else{

		document.getElementById("loErrDiv").innerHTML = '';

		

		var url = 'check-tuna-login.php?un='+u_name+'&up='+u_pass;

		//alert(url);return false;

		http_check.open("GET", url, true);

		http_check.onreadystatechange = function test(){

			if(http_check.readyState == 4){

				var response = http_check.responseText;

				

				//alert(response);return false;

				if(response == 'yes'){

					var comTxt	= document.getElementById("comText").value;

					var phId	= document.getElementById("himId").value;

					window.location = 'tuna-comm.php?tpid='+phId+'&tcmt='+comTxt;

				}else{

					var msg = 'Incorrect Username or Password';

					document.getElementById("loErrDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";

					return false;

				}

			}	

		}

		http_check.send(null);

	}	

}





function show_comment(pn){
	var aid		= document.getElementById("himId").value;
	var url = "tuna-comments.php?spid="+aid+"&pno="+pn;
	//alert(url);//return false;
	http_check.open("GET", url, true);
	http_check.onreadystatechange = function test(){
		if(http_check.readyState == 4) {
			var response = http_check.responseText;			
			//alert(response);return false;
			document.getElementById("comErrId").innerHTML = '';
			document.getElementById("comText").value	  = '';
			document.getElementById("coDeDiv").innerHTML  = response;
			parent.doIframe()
			return false;
		}
	}
	http_check.send(null);
}







function save_comment(){
	//alert("test");
	//document.getElementById("loErrDiv").innerHTML = '';
	//document.getElementById("tu_name").value = '';
	//document.getElementById("tu_pass").value = '';
	var aid		= document.getElementById("himId").value;
	var cText 	= document.getElementById("comText").value;
	cText		= rm_trim(cText);
	if(cText == ''){
		document.getElementById("comErrId").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>Add your comment!</font>";
		return false;
	}else{
		document.getElementById("comErrId").innerHTML = '';
		var url = "tuna-comments.php?tpid="+aid+"&comm="+cText;
		//alert(url);//return false;
		http_check.open("GET", url, true);
		http_check.onreadystatechange = function test(){
			if(http_check.readyState == 4) {
				var response = http_check.responseText;
				//alert(response);return false;
				if(response == 'noLo'){
					showLoginPopUp('usrLogDivId');
				}else{
					//alert(response);return false;
					document.getElementById("comErrId").innerHTML = "<font color='#0000FF' face='Verdana' size='1'>Comment posted.</font>";
					document.getElementById("comText").value	  = '';
					document.getElementById("div_loading").style.display = 'none';
					document.getElementById("TPL_POST_COMMEMT_DIV").style.display = 'none';
					document.getElementById("coDeDiv").innerHTML  = response;
				}
				setTimeout(100,parent.doIframe());
			}
		}
		http_check.send(null);	
	}

}


function flagTunaPopUp(showDiv,relativeDivId)
{
	var tunaPhId		= document.getElementById("himId").value;
	document.getElementById("mTypeId").value= tunaPhId;
	document.getElementById("flagId").value= '';
	document.getElementById("flagErrId").innerHTML= '';
	var obj 		  	= document.getElementById(showDiv);
	var relObj		= document.getElementById(relativeDivId);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
	var openDivLeft = (divLeft+100);
	var openDivTop 	= (divTop-250);
	obj.style.top 	  = openDivTop+'px';
	obj.style.left 	  = openDivLeft+'px';
	$("#"+showDiv).fadeIn(2000);
	//obj.style.display 	= 'block';
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;
}




//+++ This function is for show the tuna delete popup

function delTunaCommPopUp(cuId, showDiv, relativeDivId){
	document.getElementById('hCoId').value = cuId;
	var obj 		  	= document.getElementById(showDiv);
	var relObj		= document.getElementById(relativeDivId);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
	var openDivLeft = (divLeft+170);
	var openDivTop 	= (divTop-80);
	obj.style.top 	  = openDivTop+'px';
	obj.style.left 	  = openDivLeft+'px';
	//obj.style.display 	= 'block';
	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';	
	$("#div_loading").fadeIn(2000);
	return false;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++ This function is for check tuna album security key

function secTunaAlbKeyPopUp(showDiv, relativeDivId){
	document.getElementById("secErrMsg").innerHTML = '';
	document.getElementById("albSKey").value =	'';
	var obj 		  	= document.getElementById(showDiv);
	var relObj		= document.getElementById(relativeDivId);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
	var openDivLeft = (divLeft-170);
	var openDivTop 	= (divTop-120);
	obj.style.top 	  = openDivTop+'px';
	obj.style.left 	  = openDivLeft+'px';
	//obj.style.display 	= 'block';
	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';	
	$("#div_loading").fadeIn(2000);
	return false;
}
function shareTunaPhotoPopUp(divId,relativeDivId){
	document.getElementById("S_subject").value='';
	document.getElementById("S_description").value='';
   	var obj 		  	= document.getElementById(divId);
  	var relObj		= document.getElementById(relativeDivId);
 	var divPos 		= GetLeftTopPosition(relObj);
   	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
	var openDivLeft = (divLeft+175);
	var openDivTop 	= (divTop-270);
	obj.style.top 	  = openDivTop+'px';
	obj.style.left 	  = openDivLeft+'px';
	//obj.style.display 	= 'block';
	//alert('hiiiiiiii');
  	$("#"+divId).fadeIn(2000);
 	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';	
	$("#div_loading").fadeIn(2000);
	return false;
}
function ShareTunaPhoto(value){
	
	
		var subject = document.getElementById("S_subject").value;
		var desc = document.getElementById("S_description").value;
		var uLink = encodeMyHtml(document.getElementById("S_ulink").value);

		if(subject=="" || desc==""){
			document.getElementById("shareE").innerHTML='All fields are required';
			return false;
		}
		if (uLink=="") {
			document.getElementById("shareE").innerHTML='Enter valid URL';
			return false;
		}
		else
		{		
			var url ="share-tuna-photo.php?subject="+subject+"&desc="+encodeURI(desc)+"&lin="+uLink;
			http_check.open("GET", url, true);				
			http_check.onreadystatechange = function test(){	
				if(http_check.readyState == 4) {
					var response = http_check.responseText;
						if (response == 1){
							var msg = "Shared successfully.";
							document.getElementById("shareE").innerHTML ="<font color='#0000FF' face='Verdana' size='1'>"+msg+"</font>";
							closeMsgBox('shareDiv');
							return false;
						}else{										
							msg = 'Something went wrong.';
							document.getElementById("shareE").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";									
							return false;
						}					
				}
			}	
			http_check.send(null);
		}
}	
function encodeMyHtml(Txtval) {
	var	encodedHtml='';
     encodedHtml = Txtval;
	 encodedHtml = encodedHtml.replace(/\//g,"%2F");
     encodedHtml = encodedHtml.replace(/\?/g,"%3F");
     encodedHtml = encodedHtml.replace(/=/g,"%3D");
     encodedHtml = encodedHtml.replace(/&/g,"%26");
     encodedHtml = encodedHtml.replace(/@/g,"%40");
	 return encodedHtml; 
    // encodeHtml.htmlEncoded.value = encodedHtml;
   } 


function checkTuPhAlKey(key,albId){
 		var s_key	= document.getElementById(key).value;
  		s_key		= rm_trim(s_key);		
 		if(s_key == ''){
 			var msg = 'Enter album security key';
 			document.getElementById("secErrMsg").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
 			return false;
 		}else{
 			document.getElementById("secErrMsg").innerHTML = '';	
 		}
  		var url = "check-tuna-key.php?aid="+albId+"&sid="+s_key+"&tuna_se=yes";
 		//alert(url);return false;
 		http_check.open("GET", url, true);				
 		http_check.onreadystatechange = function test(){					
 			if(http_check.readyState == 4) {
 				var response = http_check.responseText;
 				//alert(response);
 				if (response == 0){
					var msg = "Album security key is wrong.";
					document.getElementById("secErrMsg").innerHTML ="<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
					return false;
				} else if (response == 1){
 					GoToPhotoTag();
 				}else{										
 					messg = 'Album security key is wrong.';
 					document.getElementById("secErrMsg").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>"+messg+"</font>";									
 					return false;
 				}
 			}
 		}				
 		http_check.send(null);		
  	
 }


//+++ This function is for delete the comment

function delTuComment(divId){
	var cid		= document.getElementById('hCoId').value
	var iid		= document.getElementById("himId").value;
	var url = "tuna-comments.php?imd="+iid+"&coi="+cid;
	//alert(url);//return false;
	http_check.open("GET", url, true);
	http_check.onreadystatechange = function test(){
		if(http_check.readyState == 4) {
			var response = http_check.responseText;			
			document.getElementById("coDeDiv").innerHTML  = response;
			document.getElementById(divId).style.display 		 = 'none';
			document.getElementById("div_loading").style.display = 'none';
			parent.doIframe();
			return false;		
		}
	}
	http_check.send(null);
}

//+++++++++++++++++++++++++++++++++++++++++++

//+++ This function is for check the album security key at photo upload time

function checkKey(){

		

	document.getElementById('TUNA_PROG_MSG').style.display = 'block';				

	document.getElementById('TUNA_PROG_ERROR_MSG').style.display = 'none';	

	document.getElementById("div_loading").style.display = 'block';

				

	var obj = document.getElementById("TPL_TUNA_PROG_DIV");

	

	obj.style.display 	= 'block';

	

	var width 			= pageWidth();	

	var height 			= pageHeight();	

	var left 			= leftPosition(); 

	var top 			= topPosition();

	var dialogwidth 	= obj.offsetWidth;

	var dialogheight 	= obj.offsetHeight;

	var topposition 	= top + (height / 2) - (dialogheight / 2);

	var leftposition 	= left + (width / 2) - (dialogwidth / 2);	

	topposition			= topposition -50;

	obj.style.top 		= topposition+"px";

	obj.style.left 		= leftposition+"px";

	

	var cntObj 	  		= document.getElementById(CONTENTDIV);

	var cntHeight 		= cntObj.offsetHeight;

	var cntWidth		= cntObj.offsetWidth;

	

	if(SCREENHEIGHT == '994'){

		

		if(cntHeight < 1000 && cntHeight > 950){

			cntHeight = SCREENHEIGHT - 10;	

		}else if(cntHeight > 1000){

			cntHeight = cntHeight;

		}else{

			cntHeight = SCREENHEIGHT - 140;

		}

	}else if(SCREENHEIGHT == '738'){

		

		if(cntHeight > 700  && cntHeight < 750){			

			cntHeight = SCREENHEIGHT;

		}else if(cntHeight > 750 ){			

			cntHeight = cntHeight;

		}else if(cntHeight < SCREENHEIGHT){

			cntHeight = SCREENHEIGHT - 140;

		}else{			

			cntHeight = SCREENHEIGHT;

		}

	}	

	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";

	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";

	

	var al_id	= document.getElementById("album_id").value;	

	var as_key	= document.getElementById('skey').value;

	

	var url = "check-tuna-key.php?aid="+al_id+"&sid="+as_key;

	//alert(url);

	

	http_check.open("GET", url, true);				

	http_check.onreadystatechange = function test(){					

		if(http_check.readyState == 4) {

			var response = http_check.responseText;

			

			//alert(response);//return false;

			

			if (response == 'ok'){

				document.getElementById("TPL_TUNA_PROG_DIV").style.display  = 'none';

				document.getElementById("div_loading").style.display 	= 'none';	

				

				document.upTuPhForm.submit();

			}else{

				

				document.getElementById('TUNA_PROG_MSG').style.display = 'none';				

				document.getElementById('TUNA_PROG_ERROR_MSG').style.display = 'block';				

				return false;

			}

		}

	}				

	http_check.send(null);	

	

}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





//+++ This function is for show edit tuna album div
function shEdAlbumDiv(showDiv, albDivId, albId, albImNm, vali, tFol,albLocDiv,relativeDivId){
	document.getElementById('tualb_image').disabled = false;
	document.getElementById('edTuAlDiv').style.display = 'block';
	document.getElementById("errMsgId").innerHTML = '';
	document.getElementById('alb_key').value = '';
	document.getElementById('loopVal').value = vali;
	document.getElementById('folNm').value = tFol;
	var alb_nm	= document.getElementById(albDivId).innerHTML;
	var alb_Lo	= document.getElementById(albLocDiv).innerHTML;
	document.getElementById('album_name').value = alb_nm;
	document.getElementById('album_loc').value = alb_Lo;
	document.getElementById('hAlbDivId').value 	= albDivId;
	document.getElementById('hAlbId').value 	= albId;
	document.getElementById('hOldImgName').value= albImNm;
	document.getElementById('hOldAlbNm').value	= alb_nm;
	document.getElementById('hOAlbLoc').value	= alb_Lo;
	document.getElementById('hOAlbLocDivId').value	= albLocDiv;
	document.getElementById("alb_rel_div_id").value= relativeDivId;
	var obj 		  	= document.getElementById(showDiv);
	var relObj		= document.getElementById(relativeDivId);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
	var openDivLeft = (divLeft);
	var openDivTop 	= (divTop-150);
	obj.style.top 	  = openDivTop+'px';
	obj.style.left 	  = openDivLeft+'px';
	//obj.style.display 	= 'block';
	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";
	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;
}

function shEdAlbumDiv_17dec09old(divId, albDivId, albId, albImNm, vali, tFol,albLocDiv){

		
		//alert(albLocDiv);

	document.getElementById('tualb_image').disabled = false;

	

	document.getElementById('reEmDiv').style.display = 'none';

	document.getElementById('edTuAlDiv').style.display = 'block';

	document.getElementById("errMsgId").innerHTML = '';

	document.getElementById('alb_key').value = '';

	document.getElementById('loopVal').value = vali;

	document.getElementById('folNm').value = tFol;

	

	

	var alb_nm	= document.getElementById(albDivId).innerHTML;

	var alb_Lo	= document.getElementById(albLocDiv).innerHTML;

	document.getElementById('album_name').value = alb_nm;

	document.getElementById('album_loc').value = alb_Lo;

	

	document.getElementById('hAlbDivId').value 	= albDivId;

	document.getElementById('hAlbId').value 	= albId;

	document.getElementById('hOldImgName').value= albImNm;

	document.getElementById('hOldAlbNm').value	= alb_nm;

	document.getElementById('hOAlbLoc').value	= alb_Lo;

	document.getElementById('hOAlbLocDivId').value	= albLocDiv;

	

	var obj 	= document.getElementById(divId);

	obj.style.display = 'block';

			

	var width 			= pageWidth();	

	var height 			= pageHeight();	

	var left 			= leftPosition(); 

	var top 			= topPosition();

	var dialogwidth 	= obj.offsetWidth;

	var dialogheight 	= obj.offsetHeight;

	var topposition 	= top + (height / 2) - (dialogheight / 2);

	var leftposition 	= left + (width / 2) - (dialogwidth / 2);

	obj.style.top 		= "170px";

	obj.style.left 		= "170px";

	

	var cntObj 	  		= document.getElementById(CONTENTDIV);

	var cntHeight 		= cntObj.offsetHeight;

	var cntWidth		= cntObj.offsetWidth;

	

	if(SCREENHEIGHT == '994'){

		

		if(cntHeight < 1000 && cntHeight > 950){

			cntHeight = SCREENHEIGHT - 10;	

		}else if(cntHeight > 1000){

			cntHeight = cntHeight;

		}else{

			cntHeight = SCREENHEIGHT - 140;

		}

	}else if(SCREENHEIGHT == '738'){

		

		if(cntHeight > 700  && cntHeight < 750){			

			cntHeight = SCREENHEIGHT;

		}else if(cntHeight > 750 ){			

			cntHeight = cntHeight;

		}else if(cntHeight < SCREENHEIGHT){

			cntHeight = SCREENHEIGHT - 140;

		}else{			

			cntHeight = SCREENHEIGHT;

		}

	}

	

	document.getElementById("tunaMaskDivId").style.height = cntHeight+"px";

	document.getElementById("tunaMaskDivId").style.width  = cntWidth+"px";

	

	document.getElementById("div_loading").style.display = 'block';

	

	var float_left = (SCREENWIDTH / 2) - 120;

	var float_top  = (SCREENHEIGHT / 3) - 120;

	JSFX_FloatDiv(divId, float_left,float_top).floatIt();

	return false;

	

}

//+++++++++++++++++++++++++++++++++++++++++++++++++





//+++ This function is for edit tuna album

function upTunaAlbum(divId){

	

	document.getElementById('tualb_image').disabled = false;

	

	var errCnt	= 0;

	var modify	= 0;

	var url		= '';

	var albNm	= document.getElementById('album_name').value;

	alb_nm	 	= rm_trim(albNm);



	var albLo	= document.getElementById('album_loc').value;

	alb_Lo	 	= rm_trim(albLo);
	

	var check	= document.getElementById('check1').value;

	checkCaptcha = rm_trim(check);
	
	


	if(alb_nm == ''){

		document.getElementById("errMsgId").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>*All fields are required</font>";

		errCnt++;

	}

	

	var albSke	= document.getElementById('alb_key').value;

	albSkey	 	= rm_trim(albSke);

	

	if(albSkey == ''){

		document.getElementById("errMsgId").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>*All fields are required</font>";

		errCnt++;

	}
	
	var check	= document.getElementById('check1').value;

	checkCaptcha = rm_trim(check);
	
	
	if(checkCaptcha == ''){

		document.getElementById("errMsgId").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>*All fields are required.</font>";

		errCnt++;

	}
	
	
	/*if(checkCaptcha != '')
	{
	
		var casechanged  =	checkCaptcha.toUpperCase();
		var checkvalue = hex_md5(casechanged);
		var captchavalue = document.captchaForm1.captcha1.value;
		
		if(checkvalue != captchavalue){
			document.getElementById("errMsgId").innerHTML ="<font color='#FF0000' face='Verdana' size='1'>Type Character Is Not Valid!Please Try Again.</font>";
			errCnt++;
		}
	}*/
	
	
	//var val = isSpecialChars(alb_nm);

	

	

	if(errCnt == 0){

		

		url 		= "check-tuna-key.php?code="+checkCaptcha+'&';

		

		var albId	= document.getElementById('hAlbId').value;

		var olAlNm	= document.getElementById('hOldAlbNm').value;

		var prAlNm	= document.getElementById('album_name').value;

		var alImNm	= document.getElementById('hNewImgName').value;

		var olImNm	= document.getElementById('hOldImgName').value;

		var olAlbLo	= document.getElementById('hOAlbLoc').value;

		var prAlbLo	= document.getElementById('album_loc').value;

				

		if(alImNm != '' && olAlNm == prAlNm && olAlbLo == prAlbLo ){			

			//alert("1");

			url = url+'ntualim='+alImNm+'&otualim='+olImNm+'&aid='+albId+'&sk='+albSkey;
			//alert(url);

			modify++;

		}

		

		if(alImNm != '' && olAlNm != prAlNm && olAlbLo == prAlbLo){

			//alert("2");

			url = url+'utan='+alb_nm+'&aid='+albId+'&ntualim='+alImNm+'&otualim='+olImNm+'&sk='+albSkey;

			modify++;

		}

		if(alImNm != '' && olAlNm == prAlNm && olAlbLo != prAlbLo){

			//alert("3");

			url = url+'utloc='+alb_Lo+'&aid='+albId+'&ntualim='+alImNm+'&otualim='+olImNm+'&sk='+albSkey;

			modify++;

		}

		if(alImNm != '' && olAlNm != prAlNm && olAlbLo != prAlbLo){

			//alert("4");

			url = url+'utan='+alb_nm+'&utloc='+alb_Lo+'&aid='+albId+'&ntualim='+alImNm+'&otualim='+olImNm+'&sk='+albSkey;

			modify++;

		}

		

		if(alImNm == '' && olAlNm != prAlNm && olAlbLo == prAlbLo){

			//alert("5");

			url = url+'utan='+alb_nm+'&aid='+albId+'&sk='+albSkey;

			modify++;

		}

		if(alImNm == '' && olAlNm == prAlNm && olAlbLo != prAlbLo){

			//alert("6");

			url = url+'utloc='+alb_Lo+'&aid='+albId+'&sk='+albSkey;

			modify++;

		}

		if(alImNm == '' && olAlNm != prAlNm && olAlbLo != prAlbLo){

			//alert("7");

			url = url+'utan='+alb_nm+'&utloc='+alb_Lo+'&aid='+albId+'&sk='+albSkey;

			modify++;

		}



		if(alImNm == '' && olAlNm == prAlNm && olAlbLo == prAlbLo){

			//alert("8");

			document.getElementById("errMsgId").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>Please edit a field</font>";

			return false;

		}
		//alert(url);//return false;
		if(modify > 0){
			http_check.open("GET", url, true);

			http_check.onreadystatechange = function test(){

				if(http_check.readyState == 4) {

					var response = http_check.responseText;

					//document.write(response);

					//alert(response);//return false;
				if(response==101){
					document.getElementById("errMsgId").innerHTML ="<font color='#FF0000' face='Verdana' size='1'>invalid code , try again...</font>";
					return false;
				}
					var responseTxt = response.split('~~');

					//alert(responseTxt);
					//alert(responseTxt[0]);

					if(responseTxt[0].indexOf("wrkey")!=-1){

						document.getElementById("errMsgId").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>Album security key is wrong</font>";

						return false;

						

					}else if (responseTxt[0].indexOf("exist")!= -1){

						document.getElementById("errMsgId").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>Album name already exist</font>";

						return false;

						

					}else if(responseTxt[0].indexOf("update") != -1){

						var loop = document.getElementById('loopVal').value;

						var imgSrc = 'imgId'+loop;
						
					
						//var tFol = document.getElementById('folNm').value;

						//var imgPa	= 'tuna/'+tFol+'/'+alImNm;

						//alert(responseTxt[1]);

						document.getElementById(imgSrc).src = responseTxt[1];

						document.getElementById(divId).style.display = 'none';

						document.getElementById("div_loading").style.display = 'none';

												

					}else if(responseTxt[0].indexOf("TAL") !=-1){

						var albDivId = document.getElementById('hOAlbLocDivId').value;

						document.getElementById(albDivId).innerHTML = prAlbLo;

						document.getElementById(divId).style.display = 'none';

						document.getElementById("div_loading").style.display = 'none';
						

					}else if(responseTxt[0].indexOf("TANL") !=-1){

						var albDivId1 = document.getElementById('hAlbDivId').value;

						document.getElementById(albDivId1).innerHTML = prAlNm;

						var albDivId2 = document.getElementById('hOAlbLocDivId').value;

						document.getElementById(albDivId2).innerHTML = prAlbLo;

						

						document.getElementById(divId).style.display = 'none';

						document.getElementById("div_loading").style.display = 'none';

					}else{

						var albDivId = document.getElementById('hAlbDivId').value;

						document.getElementById(albDivId).innerHTML = prAlNm;

						document.getElementById(divId).style.display = 'none';

						document.getElementById("div_loading").style.display = 'none';

						return false;

					}

				}

			}

			http_check.send(null);

			

		}else{

			document.getElementById("errMsgId").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>Change you party name</font>";

			return false;

		}

	}

}

//++++++++++++++++++++++++++++++++++++++++







//+++ This function is for resenm tuna album security key

function reAlSeKey(divId){
 	var errCnt = 0;
 	document.getElementById("rEmErrMsgDiv").innerHTML = '';
 	var que = document.getElementById('seQue').value;
 	if(que == ''){				
 		document.getElementById("rEmErrMsgDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>All fields are required </font>";
		return false;
 	}
 	var ans = document.getElementById('sec_ans').value;	
 	ans		= rm_trim(ans);
 	if(ans == ''){
 		document.getElementById("rEmErrMsgDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>All fields are required </font>";
		return false;
 	}
 	var temail = document.getElementById('tu_email').value;
 	temail		= rm_trim(temail);
 	if(temail == ''){
 		document.getElementById("rEmErrMsgDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>All fields are required </font>";
		return false;
 	}else{
 		if(!isEmail(temail)){
 			document.getElementById("rEmErrMsgDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>Email is not correct</font>";
			return false
 		}
 	}
 	var check	= document.getElementById('check2').value;
 	checkCaptcha = rm_trim(check);
 	if(checkCaptcha == ''){
 		document.getElementById("rEmErrMsgDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>*All fields are required.</font>";
 		return false;
 	}
	
 	
	
 		var albId	= document.getElementById('hAlbId').value;
 		var url = 'check-tuna-key.php?aid='+albId+'&qu='+que+'&an='+ans+'&em='+temail+'&code='+checkCaptcha;		
 		//alert(url);//return false;
 		http_check.open("GET", url, true);
 		http_check.onreadystatechange = function test(){
 			if(http_check.readyState == 4) {
 				var response = http_check.responseText;
 				//document.write(response);
 				//alert(response);//return false;
 				 if(response==101){
					 document.getElementById("rEmErrMsgDiv").innerHTML ="<font color='#FF0000' face='Verdana' size='1'>invalid cod , try again...</font>";
					return false;
				 }else if (response == 1){
					 document.getElementById("rEmErrMsgDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>Check your mail box</font>";
 					document.getElementById('tu_email').value = '';
 					document.getElementById('sec_ans').value  = '';
 					//document.getElementById(divId).style.display = 'none';
 					//document.getElementById("div_loading").style.display = 'none';
 					return true;
 				}else{
 					document.getElementById("rEmErrMsgDiv").innerHTML = "<font color='#FF0000' face='Verdana' size='1'>Information is wrong</font>";
 					return false;
 				}
 			}
 		}
 		http_check.send(null);
 }

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++





//+++ This function is for show the resend email popup

function tuna_show(shDiv, hiDiv){
	document.getElementById(hiDiv).style.display = 'none';
	document.getElementById(shDiv).style.display = 'block';
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++







//+++ This function is for close the tuna popup

function closeTunaPopUp(divId){
 	//document.getElementById(divId).style.display = 'none';
 	//document.getElementById("div_loading").style.display = 'none';
	$("#"+divId).fadeOut(2000);
	$("#div_loading").fadeOut(2000);
 }

//+++++++++++++++++++++++++++++++++++++++++++++++



function check_key(){



	var val = document.getElementById('seKey').value;

	val		= rm_trim(val);	

	

	if(val == 'enter location or party name'){

		var errMsg = 'Please provide a location or party name';			

		document.getElementById('sErrDiv').innerHTML = "<font color='#FF0000' face='Verdana' size='2'>"+errMsg+"</font>";

		return false;

	}else{

		document.getElementById('sErrDiv').innerHTML = '';

	}	

}





////////////////////////////////////////////////////////////////////////



function showNext(iid){

	

	//alert(iid);

	document.getElementById('himId').value = iid;

	var url = 'show-tuna-comm.php?iid='+iid;		

	//alert(url);return false;

	http_check.open("GET", url, true);

	http_check.onreadystatechange = function test(){

		if(http_check.readyState == 4) {

			var response = http_check.responseText;

			

			//document.write(response);

			//alert(response);return false;	

			

			document.getElementById("tuCoTblDiv").innerHTML = response;

			return false;		

		}

	}

	http_check.send(null);

}
function checkCaptchaCode(val,capValField,errDivId,capErrorId,capErrorDiv){
	//alert(val);
	var url = "check_captcha.php?code="+val;
 		//alert(url);//return false;
 		http_check.open("GET", url, true);				
 		http_check.onreadystatechange = function test(){					
 			if(http_check.readyState == 4) {
 				var response = http_check.responseText;
 			//alert(response);//return false;
 				if (response =='yes'){
					document.getElementById(capErrorDiv).style.display='none';
					return true;	
 				}else{										
 					var msg = "invalid code, try again...";
					document.getElementById(capErrorDiv).style.display='block';
					document.getElementById(errDivId).innerHTML ="<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
					document.getElementById(capErrorId).innerHTML ="<font color='#FF0000' face='Verdana' size='1'>"+msg+"</font>";
					document.getElementById(capValField).value='';
					return false;
 				}
 			}
 		}				
 		http_check.send(null);	
}
function checkCaptchaCode1(val){
	//alert(val);
	var url = "check_captcha.php?code="+val;
 		//alert(url);//return false;
 		http_check.open("GET", url, true);				
 		http_check.onreadystatechange = function test(){					
 			if(http_check.readyState == 4) {
 				var response = http_check.responseText;
 				if (response =='yes'){
					return true;	
 				}else{										
					return false;
 				}
 			}
 		}				
 		http_check.send(null);	
}	

