// JavaScript Document
var http_check = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
//+++++++++  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 ++++++++++++++++++++//



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

function isEmail(str){

	var at="@";

	var dot=".";

	var lat=str.indexOf(at);

	var ldot=str.indexOf(dot);

	var lstr=str.length;



	if(str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		return false;

	}

	if(str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		return false;

	}

	if(str.indexOf(" ")!=-1){

		return false;

	}

	if(str.indexOf(at,(lat+1))!=-1){

		return false;

	}

	if(str.indexOf(dot,(lat+2))==-1){

		return false;

	}

	if(str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		return false;

	}

	return true;

}
function checkIntVal(str){
var checkOK = "0123456789.";
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < str.length;  i++)
  {
   ch = str.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)

    {
      allValid = false;
      break;
    }

  }
   if (!allValid){
		return false;
	}
}
function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}
//////////////////////////////////////////
function setCurrencyType(currencyType,currencyTypeId,amtVal,convertedCurrencyId){
	if(currencyType == ""){
		var message= "Select payment mode";
		document.getElementById('errDivId').style.display = 'block';
		document.getElementById('errDivId').innerHTML = message;
		document.getElementById(amtVal).value = '';
		document.getElementById(currencyTypeId).value = '';
	}else{
		document.getElementById(currencyTypeId).value = currencyType;
		document.getElementById(amtVal).value = '';
		document.getElementById(convertedCurrencyId).innerHTML = '';
		document.getElementById('errDivId').style.display = 'none';
		document.getElementById('errDivId').innerHTML = '';
	}
}
function exchangeMoney(shareVal,currencyType,showId,convertedCurrencyVal){
	var currType	=	document.getElementById(currencyType).value;
	if(currType == ""){
		document.getElementById('errDivId').style.display = 'block';
		document.getElementById('errDivId').innerHTML = 'Select payment mode';
		document.getElementById(showId).innerHTML	=	'';
		return false;	
	}
	if(rm_trim(shareVal) != ''){
		if(checkIntVal(shareVal)== false){
			document.getElementById('errDivId').style.display = 'block';
			document.getElementById('errDivId').innerHTML = 'Amount must be a number';
			document.getElementById(showId).innerHTML	=	'';
			return false;
		}
		if(currType == '1'){
			var roundedNumber = roundNumber(shareVal,2);
			document.getElementById(showId).innerHTML = roundedNumber+' '+'USD';
			document.getElementById(convertedCurrencyVal).value = roundedNumber;
			document.getElementById('errDivId').innerHTML = '';
			document.getElementById('errDivId').style.display = 'none';
			return false;
			}else{			
			 var url = "convertCurrency.php?shareCurrVal="+shareVal+"&currType="+currType;
				http_check.open("GET", url, true);
				http_check.onreadystatechange = function test(){			
				//alert(http_check.readyState);
				if(http_check.readyState == 4) {							
					var response = http_check.responseText;
					 if (response != ''){
						 document.getElementById(showId).innerHTML = response+' '+'USD';
						 document.getElementById(convertedCurrencyVal).value = response;
						 document.getElementById('errDivId').style.display = 'none';
						 document.getElementById('errDivId').innerHTML = '';
							return false;
						}
					 else{
							document.getElementById('errDivId').style.display = 'block';
							document.getElementById('errDivId').innerHTML = 'Try again !';
						}
					}
				}	
				http_check.send(null);
		}
	}else{
		document.getElementById('errDivId').innerHTML = '';
	}
		
}

function bceventvalidate(){

	//alert("pawn");

	var err			='';

	

	if(document.getElementById("evtname").value == "")

	{

	err="All fields are required.";
		
	
	}

	if(document.getElementById("evthost").value=="")

	{

	err="All fields are required.";
	

	}

	if(document.getElementById("evtdesc").value=="")

	{

	err="All fields are required.";

	}

	if(document.getElementById("date13").value=="")

	{

	err="All fields are required.";

	}

	if(document.getElementById("date14").value == "")

	{

	err="All fields are required.";

	}
	if(document.getElementById("evt_ticket_no").value == "")

	{

	err="All fields are required.";

	}
	
	if(document.getElementById("itemAmtType").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtloc").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtstreet").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtcity").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtpno").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtmail").value == "")

	{

	err="All fields are required.";

	}else{

		if(!isEmail(document.getElementById("evtmail").value))

		 {

		 //alert('hello');

		 err="Please enter  valid email address.";

		 }

	}

	if(document.getElementById("ephoto").value == "")

	{

	err="All fields are required.";

	}



	

	if(err=='')

		{

			
			document.evt.submit();

		}

		else

		{

			var message="Sorry ! we are unable to complete your request.\nKindly complete the incorrect or missing information enclosed below:<br />"+err;

			document.getElementById('errDivId').innerHTML = err;
			document.getElementById('errDivId').style.display = 'block';
			parent.doIframe();
			return false;

		}



	

	}
	
	function editBCeventValidate(){

	//alert("pawn");

	var err			='';

	

	if(document.getElementById("evtname").value == "")

	{

	err="All fields are required.";
		
	
	}

	if(document.getElementById("evthost").value=="")

	{

	err="All fields are required.";
	

	}

	if(document.getElementById("evtdesc").value=="")

	{

	err="All fields are required.";

	}

	if(document.getElementById("date13").value=="")

	{

	err="All fields are required.";

	}

	if(document.getElementById("date14").value == "")

	{

	err="All fields are required.";

	}
	
	if(document.getElementById("evt_ticket_no").value == "")

	{

	err="All fields are required.";

	}
	
	if(document.getElementById("itemAmtType").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtloc").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtstreet").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtcity").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtpno").value == "")

	{

	err="All fields are required.";

	}

	if(document.getElementById("evtmail").value == "")

	{

	err="All fields are required.";

	}else{

		if(!isEmail(document.getElementById("evtmail").value))

		 {

		 //alert('hello');

		 err="Please enter  valid email address.";

		 }

	}

		

	if(err=='')

		{

			
			document.evt.submit();

		}

		else

		{

			var message="Sorry ! we are unable to complete your request.\nKindly complete the incorrect or missing information enclosed below:<br />"+err;

			document.getElementById('errDivId').innerHTML = err;
			document.getElementById('errDivId').style.display = 'block';
			parent.doIframe();
			return false;

		}



	

	}


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

function funeventPhouploadDiv(showDiv){

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

	var obj 		  	= document.getElementById(showDiv);

	obj.style.display 	= 'block';

		

	var det = getPageSize();

	cntWidth = det[0];

	cntHeight= det[1];

	

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

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

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

	

	var float_left = (SCREENWIDTH / 2) - 194;

	var float_top = (SCREENHEIGHT / 3) - 120;

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

	return false;

}

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

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

	

}

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

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

function closeEventMsgBox(divId){

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

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

	 window.location = 'events-view.php';

}

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

///////////////////function created by dinesh on 12 march 09////////////////////////////////////

function closeEventMsgBoxNew(divId,eventId){
 	var evtId	= eventId;
 	var check      = document.getElementById("check").value;
 	if(check == '')
	{
		document.getElementById("VidErrMsgDiv").innerHTML ="All fields are required.";
		return false;
	}
	
	if(check != '')
	{
	
		var casechanged  =	check.toUpperCase();
		var checkvalue = hex_md5(casechanged);
		var captchavalue = document.uploadVideoForm.captcha.value;
		if(checkvalue != captchavalue){
			document.getElementById("VidErrMsgDiv").innerHTML ="Invalid code, try again.";
			
			return false;
		}
	}
 	//document.getElementById(divId).style.display = 'none';
 	//document.getElementById("div_loading").style.display = 'none';
	$("#"+divId).fadeOut(2000);
	$("#div_loading").fadeOut(2000);
  	window.location = "events-view.php?eid="+evtId;

}

//////////////////function created by dinesh on 12 march 09 ends here////////////////////////////

function imageUpload(obj){

	

	//alert(obj.value);

	var eid=document.getElementById("HidEid").value;

	var cap=document.getElementById("imagecap").value;

	var fileVal = obj.value;

	//alert(eid);

	var ext 	= fileVal.substring(fileVal.lastIndexOf(".")+1,fileVal.length).toLowerCase();

	//alert(ext);	

	if(ext != 'jpg' && ext != 'jpeg' && ext != 'gif' && ext != 'png'){

		document.getElementById("errMsgDiv").innerHTML = "<font color='#FFA537' face='Arial' size='1'>Format not supported</font>";

		return false;		

	}else{

		

		document.getElementById("errMsgDiv").innerHTML = "";

		

		$('#proDivId')

			.ajaxStart(function(){

				//document.getElementById('doneButId').disabled = true;

				$(this).show();

			})

			.ajaxComplete(function(){

				//document.getElementById('doneButId').disabled = false;

				$(this).hide();

			});

	

			$.ajaxFileUpload

			(

				{

					/*url:"competition_photo_upload.php?caption="+caption+"&ctype="+comptype+"&caption="+caption,*/

					url:"event-photo-upload.php?eid="+eid+"&cap="+cap,

					secureuri:false,

					fileElementId:'image_file',

					dataType: 'json',

					success: function (data, status)

					{

						if(typeof(data.error) != 'undefined')

						{

							if(data.error != ''){							

								//alert("data error :"+data.error);

								document.getElementById("errMsgDiv").innerHTML = "<font color='#FFA537' face='Arial' size='1'>Please try again.</font>";

							}else{

								//alert('Your image has been uploaded successfully.');

								

								var retMsg = data.msg;

								var responseTxt = retMsg.split('~~');

								//alert(responseTxt[0]);

								if(responseTxt[0] == 'success'){

									

									//document.getElementById("hNewImgName").value 	= responseTxt[1];

									document.getElementById("errMsgDiv").innerHTML = "<font color='#FFA537' face='Arial' size='1'>Your image has been uploaded, now proceed further.</font>";

									//document.getElementById('image_file').disabled		= true;																										

									//document.getElementById('doneButId').disabled 		= false;

									//document.getElementById('dologin').style.display 	= 'block';

									

								}else if(responseTxt[0] == 'fail'){

									

									//document.getElementById('maintable').style.display = 'none';

									var message = "<font color='#FFA537' face='Verdana' size='1'>You are already uploaded your photo</font>";

									document.getElementById('errMsgDiv').innerHTML = message;

									//document.getElementById('closebuttn').style.display = 'block';

									

									

									

								}else if(responseTxt[0] == 'size' && responseTxt[1] == 'problem'){

									

									//alert('size problem');

									//document.getElementById('doneButId').disabled 	= false;

									document.getElementById("errMsgDiv").innerHTML 	= "<font color='#FFA537' face='Arial' size='1'>Image size not greater than 10Mb</font>";

									

								}

							}

						}

					},

					error: function (data, status, e)

					{

						///alert("error: "+e);

						document.getElementById("errMsgDiv").innerHTML = "<font color='#FFA537' face='Arial' size='1'>Incorrect path.</font>";

					}

				}

			)		

			return false;

	}

}



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

function funRemoveevent(showDiv,id){
 	//alert(id);
 	var pid = document.getElementById(id).value;
 	document.getElementById("HPEPOID").value=pid;
 	var obj 		= document.getElementById(showDiv);
   	var relObj		= document.getElementById(id);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
 	var openDivLeft = (divLeft);
	var openDivTop 	= (divTop);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;
}

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

}

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

}

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

function Deletephotos(){
  var pid=document.getElementById("HPEPOID").value;
  var eid=document.getElementById("HPEID").value;
  window.location = 'events-view.php?pid='+pid+'&eid='+eid;
 }

function DeleteEventPhoto(){
  var pid=document.getElementById("HPEPOID").value;
  var eid=document.getElementById("HPEID").value;
  window.location = 'event-photos.php?pid='+pid+'&eid='+eid;
 }

function DeleteVideo(){
  var vid=document.getElementById("VID").value;
  var eid=document.getElementById("EVENTID").value;
  window.location = 'events-view.php?vid='+vid+'&eid='+eid;
}


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

function funeventGuestPhoupload(showDiv,relativeDivId){
	document.getElementById("doneButGuestPhotoId").disabled=true;
 	document.getElementById("ErrMsgDivID").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+230);
	var openDivTop 	= (divTop-200);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;

}

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

function guestimageUpload(obj){

	

	var eid			=document.getElementById("HidEVTid").value;

	var caption		=document.getElementById("GtTtl").value;

	var fileVal 	= obj.value;

	

	var ext 	= fileVal.substring(fileVal.lastIndexOf(".")+1,fileVal.length).toLowerCase();

	//alert(ext);	

	if(ext != 'jpg' && ext != 'jpeg' && ext != 'gif' && ext != 'png'){

		document.getElementById("ErrMsgDivID").innerHTML = "<font color='#FF0000' face='Arial' size='1'>Format not supported</font>";

		return false;		

	}else{

		

		document.getElementById("ErrMsgDivID").innerHTML = "";

		

		$('#PreLoadDivId')

			.ajaxStart(function(){

				//document.getElementById('doneButId').disabled = true;

				$(this).show();

			})

			.ajaxComplete(function(){

				//document.getElementById('doneButId').disabled = false;

				$(this).hide();

			});

	

			$.ajaxFileUpload

			(

				{

					/*url:"competition_photo_upload.php?caption="+caption+"&ctype="+comptype+"&caption="+caption,*/

					url:"event-guestphoto-upload.php?eid="+eid+"&caption="+caption,

					secureuri:false,

					fileElementId:'IMG_FILE',

					dataType: 'json',

					success: function (data, status)

					{

						if(typeof(data.error) != 'undefined')

						{

							if(data.error != ''){							

								//alert("data error :"+data.error);

								document.getElementById("ErrMsgDivID").innerHTML = "<font color='#FF0000' face='Arial' size='1'>Try again.</font>";

							}else{

								//alert('Your image has been uploaded successfully.');

								

								var retMsg = data.msg;

								var responseTxt = retMsg.split('~~');

								//alert(responseTxt[0]);

								if(responseTxt[0] == 'success'){

									document.getElementById("doneButGuestPhotoId").disabled=false;

									document.getElementById("ErrMsgDivID").innerHTML = "<font color='#0000FF'>Your image has been uploaded, now proceed further.</font>";

									

								}else if(responseTxt[0] == 'fail'){

									

									var message = "<font color='#FF0000'>You are already uploaded your photo</font>";

									document.getElementById('ErrMsgDivID').innerHTML = message;

								}else if(responseTxt[0] == 'size' && responseTxt[1] == 'problem'){

									document.getElementById("ErrMsgDivID").innerHTML 	= "<font color='#FF0000'>Image size not greater than 10Mb</font>";

									

								}

							}

						}

					},

					error: function (data, status, e)

					{

						

						//alert("error: "+e);

						document.getElementById("ErrMsgDivID").innerHTML = "<font color='#FF0000'>Incorrect path.</font>";

					}

				}

			)		

			return false;

	}

}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GetLeftTopPosition(obj)
 {
     var topValue= 0,leftValue= 0;
     while(obj){
 		leftValue+= obj.offsetLeft;
 		topValue+= obj.offsetTop;
 		obj= obj.offsetParent;
     }
 	finalvalue = leftValue+"::"+topValue;
     return finalvalue;
 }



function funRemoveguestphoto(showDiv,id){

	//var pid = document.getElementById(id).value;//wrong
 	document.getElementById("HIDGSTPOTOID").value=id;
	
		var obj 		= document.getElementById(showDiv);
   	var relObj		= document.getElementById(id);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
 	var openDivLeft = (divLeft);
	var openDivTop 	= (divTop);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;

}



function Deleteguestphotos(){
  var guid=document.getElementById("HIDGSTPOTOID").value;
  var eid=document.getElementById("HPGESTEID").value;
  window.location = 'events-view.php?guid='+guid+'&eid='+eid;
 }



function funwarningdiv(showDiv,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+230);
	var openDivTop 	= (divTop-200);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;

}



function funVideoUploadDIV(showDiv,relativeDivId){
	document.getElementById("doneButViedioId").disabled=true;
	document.getElementById("VidErrMsgDiv").innerHTML = '';
	document.getElementById("check").value = '';
	document.getElementById("VidCaption").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+230);
	var openDivTop 	= (divTop-330);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;

}

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

function videoUploadComp(obj){

		

	var fileVal = obj.value;

	//alert(fileVal);

	var eid=document.getElementById("HidEvtVid").value;

	var cap=document.getElementById("VidCaption").value;

	

	var ext 	= fileVal.substring(fileVal.lastIndexOf(".")+1,fileVal.length).toLowerCase();

	

	if(ext != 'flv' && ext != 'mp4' && ext != 'mpg' && ext != 'mpeg' && ext != 'wmv' && ext != 'mpeg4' && ext != 'mov'){		

		

		document.getElementById("VidErrMsgDiv").innerHTML = "Format not supported";

		return false;		

	}else{

		

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

		$('#VideoProDivId')

			.ajaxStart(function(){

				//document.getElementById('viUplButton').disabled = true;

				$(this).show();

			})

			.ajaxComplete(function(){

				//document.getElementById('viUplButton').disabled = false;

				$(this).hide();

			});

	

			$.ajaxFileUpload

			(

				{

					url:"event-video-upload.php?eid="+eid+"&cap="+cap,

					//alert(url);

					secureuri:false,

					fileElementId:'video_file',

					dataType: 'json',

					success: function (data, status)

					{

						if(typeof(data.error) != 'undefined')

						{

							if(data.error != ''){							

								//alert("data error :"+data.error);

								document.getElementById("VidErrMsgDiv").innerHTML = "Please try again.";

							}else{

								//alert('Your image has been uploaded successfully.');

								//alert(data.msg);//return false;

								var retMsg = data.msg;

								var responseTxt = retMsg.split('~~');

								//alert(responseTxt[0]);						

								if(responseTxt[0] == 'success'){

								document.getElementById("VidErrMsgDiv").innerHTML = "<font color='#0000FF'>Your video has been uploaded, now proceed further.</font>";
								document.getElementById("video_file").disabled=true;
								document.getElementById("doneButViedioId").disabled=false;

								}else if(responseTxt[0] == 'fail'){	

								var message = "You are already uploded 2 video in this event";		
								document.getElementById('VidErrMsgDiv').innerHTML = message;

								return false;

								}else if(responseTxt[0] == 'size' && responseTxt[1] == 'problem'){									

									document.getElementById("VidErrMsgDiv").innerHTML = "Video size should not greater than 30Mb";									

								}

							}

						}

					},

					error: function (data, status, e)

					{

						//alert("error: "+e);

						document.getElementById("VidErrMsgDiv").innerHTML = "Try again.";

					}

				}

			)		

			return false;

	}

}



function showhide(div){

	

	//alert(div)

	if(div=='UserDiv'){

		document.getElementById("UserDiv").style.display='block'

		document.getElementById("UserNotDiv").style.display='none'

		

	}else{

		document.getElementById("UserDiv").style.display='none'

		document.getElementById("UserNotDiv").style.display='block'

		

	}

}

	

	

function funAttandevent(showDiv,relDiv,id){

 	document.getElementById("HPEPOID").value=id;
 	var obj 		= document.getElementById(showDiv);
   	var relObj		= document.getElementById(relDiv);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
 	var openDivLeft = (divLeft-300);
	var openDivTop 	= (divTop-100);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;
	
	

	/*document.getElementById("HPEPOID").value=id;

	var obj 		  	= document.getElementById(showDiv);

	obj.style.display 	= 'block';

		

	var det = getPageSize();

	cntWidth = det[0];

	cntHeight= det[1];

	

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

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

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

	

	var float_left = (SCREENWIDTH / 2) - 194;

	var float_top = (SCREENHEIGHT / 3) - 120;

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

	return false;*/

}



function fun_attendevent(){


document.getElementById("div_loading").style.display = 'none';
document.getElementById("attendEvent").style.display = 'none';
 var eid=document.getElementById("HPEPOID").value;

 

 window.location = 'bcevents.php?eid='+eid;

}



function fun_deleteeventpopup(showDiv,eid){
 	//alert(eid);
	//document.getElementById("sub").value='';
	//document.getElementById("mess").value='';
 	document.getElementById("HPEPOID").value=eid;
 	var obj 		= document.getElementById(showDiv);
   	var relObj		= document.getElementById(eid);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
 	var openDivLeft = (divLeft+300);
	var openDivTop 	= (divTop);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;

}

function fun_deleteeventcommitpopup(showDiv,relDivId,eid,uid){
	document.getElementById("HPEPOID").value=eid;
	document.getElementById("HidUid").value=uid;
 	var obj 		= document.getElementById(showDiv);
   	var relObj		= document.getElementById(relDivId);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
 	var openDivLeft = (divLeft+270);
	var openDivTop 	= (divTop-150);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;
}



function fun_DeleteMyEvent(frmName){
  var err			='';
  var eid=document.getElementById("HPEPOID").value;
  //var subj=document.getElementById("sub").value;
  //var mess= document.getElementById("mess").value;
  /* if(subj == "")
 	{
 	err="All fields are required";
 	}
 	if(mess=="")
 	{
 	err="All fields are required";
 	}*/
 	//alert(err);
 	if(err == '')
 		{
 			//alert(frmName);
 			document.frmName.submit();
 		}
 		else
 		{
 			var message=err;
 			document.getElementById('errDivId').innerHTML = message;
 			return false;
 		}
 }

function eventMsgBoxClose(divId,eventId){
 	var evtId	= eventId;
 	//document.getElementById(divId).style.display = 'none';
 	//document.getElementById("div_loading").style.display = 'none';
	$("#"+divId).fadeOut(2000);
	$("#div_loading").fadeOut(2000);
 	window.location = "events-view.php?eid="+evtId;

}



function fun_DeleteMyCommitment(){

	//alert();

 var err			='';

 var eid=document.getElementById("HPEPOID").value;

 var uid=document.getElementById("HidUid").value;

 /*var subj=document.getElementById("sub").value;

 var mess= document.getElementById("mess").value;

 

 if(subj == "")

	{

	err="all fields are required";

	}

	if(mess=="")

	{

	err="all fields are required";

	}*/

	//alert(err);

	if(err == '')

		{

			//alert('Hello ');

			document.sendMesscommit.submit();

		}

		else

		{

			var message=err;

			document.getElementById('errDivId').innerHTML = message;

			return false;

		}

}



function showHideInviteGuest(div){

	
	if(div=='guestlook'){

		document.getElementById("guestlook").style.display='block'

		document.getElementById("guestpro").style.display='none'

		document.getElementById('look').style.background='#E8E8E9';
		document.getElementById('mail').style.background='#FFFFFF';

	}else{

		document.getElementById("guestlook").style.display='none'

		document.getElementById("guestpro").style.display='block'

		document.getElementById('mail').style.background='#E8E8E9';
		document.getElementById('look').style.background='#FFFFFF';

	}
	parent.doIframe();


}

function limitChar(tapMsgId, liDivId, totChars){	

	

	var msg 	 = document.getElementById(tapMsgId).value;

	var msgLen	 = msg.length;

	

	if(msgLen > totChars){

		document.getElementById(tapMsgId).value = msg.substring(0, totChars);

	}else{

		document.getElementById(liDivId).innerHTML = totChars - msgLen;

	}	

}

function fun_AcceptRejectEventPopup(showDiv,relDiv,eid,uid){
	document.getElementById("EID").value=eid;
	document.getElementById("UserId").value=uid;
 	var obj 		= document.getElementById(showDiv);
   	var relObj		= document.getElementById(relDiv);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
 	var openDivLeft = (divLeft-350);
	var openDivTop 	= (divTop-100);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;
}

function hilighLink(id){

	if(id=='eGPhoto'){
	
	document.getElementById('gp').style.background='#E8E8E9';
	document.getElementById('ep').style.background='#ffffff';
	document.getElementById('ev').style.background='#ffffff';
	
	document.getElementById("eGPhoto").style.display = "block";
	document.getElementById("ePhoto").style.display = "none";
	document.getElementById("eVideo").style.display = "none";
	
	document.getElementById("eGPhotoData").style.display = "block";
	document.getElementById("ePhotoData").style.display = "none";
	document.getElementById("eVideoData").style.display = "none";
	
		
	}else if(id=='ePhoto'){
	
	document.getElementById('gp').style.background='#ffffff';
	document.getElementById('ep').style.background='#E8E8E9';
	document.getElementById('ev').style.background='#ffffff';
	
	document.getElementById("ePhoto").style.display = "block";
	document.getElementById("eGPhoto").style.display = "none";
	document.getElementById("eVideo").style.display = "none";
	
	document.getElementById("ePhotoData").style.display = "block";
	document.getElementById("eGPhotoData").style.display = "none";
	document.getElementById("eVideoData").style.display = "none";
	
	
	}else if(id=='eVideo'){
	
	document.getElementById('gp').style.background='#ffffff';
	document.getElementById('ev').style.background='#E8E8E9';
	document.getElementById('ep').style.background='#ffffff';
	
	document.getElementById("eVideo").style.display = "block";
	document.getElementById("eGPhoto").style.display = "none";
	document.getElementById("ePhoto").style.display = "none";
	
	document.getElementById("eVideoData").style.display = "block";
	document.getElementById("eGPhotoData").style.display = "none";
	document.getElementById("ePhotoData").style.display = "none";
	
	
	}
	parent.doIframe();

}

function showPurchasePopup(showDiv){

	document.getElementById("errMsgDiv").innerHTML='';
	document.getElementById("guestName").value = '';
	document.getElementById("check2").value = '';

	var obj 		  	= document.getElementById(showDiv);

	obj.style.display 	= 'block';

		

	var det = getPageSize();

	cntWidth = det[0];

	cntHeight= det[1];

	

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

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

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

	

	var float_left = (SCREENWIDTH / 2) - 194;

	var float_top = (SCREENHEIGHT / 3) - 120;

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

	return false;

}

function showPurchaseReceiptPopup(showDiv,eventName,date,dateFormat,timezone,country,location,ticketCost,ticketCostOther,ticketCostType,guestName,uniqueid){
var string = "eventName:"+eventName+"date:"+date+"dateFormat:"+dateFormat+"timezone:"+timezone+"country:"+country+"location:"+location+"ticketCost:"+ticketCost+"guestName:"+guestName+"uniqueid:"+uniqueid;
//alert(string);
   	document.getElementById("evName").innerHTML = eventName;
	document.getElementById("dt").innerHTML = date+' '+dateFormat+' '+timezone;
	document.getElementById("loc").innerHTML = location+' | '+country;
	if(ticketCostOther!='' && ticketCostType!='USD'){
	document.getElementById("tc").innerHTML = '$'+ticketCost+'&nbsp;|&nbsp;'+ticketCostType+'&nbsp;'+ticketCostOther;
	}else{
		document.getElementById("tc").innerHTML = '$'+ticketCost;
	}
	document.getElementById("gn").innerHTML = guestName;
	document.getElementById("tn").innerHTML = uniqueid;
		
	var obj 		= document.getElementById(showDiv);
   	var relObj		= document.getElementById(uniqueid);
	var divPos 		= GetLeftTopPosition(relObj);
	var posBody 	= divPos.split('::');
	var divLeft 	= parseInt(posBody[0]);
	var divTop 		= parseInt(posBody[1]);
 	var openDivLeft = (divLeft+240);
	var openDivTop 	= (divTop-230);
    obj.style.top 	  = openDivTop+'px';
 	obj.style.left 	  = openDivLeft+'px';
  	$("#"+showDiv).fadeIn(2000);
	var det = getPageSize();
	cntWidth = det[0];
	cntHeight= det[1];
 	document.getElementById("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;

}

function showPurchaseReceiptPopup2(showDiv,eventName,datetime,location,ticketCost,ticketCostOther,ticketCostType,guestName,uniqueId){

	
	var obj 		  	= document.getElementById(showDiv);

	obj.style.display 	= 'block';

	var det = getPageSize();

	cntWidth = det[0];

	cntHeight= det[1];

	document.getElementById("evName").innerHTML = eventName;
	document.getElementById("dt").innerHTML = datetime;
	document.getElementById("loc").innerHTML = location;
	if(ticketCostOther !='' && ticketCostType!='USD'){
	document.getElementById("tc").innerHTML = '$&nbsp;'+ticketCost+'&nbsp;|&nbsp;'+ticketCostType+'&nbsp;'+ticketCostOther;
	}else{
	document.getElementById("tc").innerHTML = '$&nbsp;'+ticketCost;
	}
	document.getElementById("gn").innerHTML = guestName;
	document.getElementById("tn").innerHTML = uniqueId;
		
	document.getElementById("maskDivMedia").style.height = cntHeight+"px";

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

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

	

	var float_left = (SCREENWIDTH / 2) - 194;

	var float_top = (SCREENHEIGHT / 3) - 120;

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

	return false;

}
function flagEventsPopUp(showDiv,relativeDivId)
{
	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);
	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("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';
	$("#div_loading").fadeIn(2000);
	return false;
}

function ShareEventsViewPopUp(divId,relativeDivId){
	document.getElementById("S_subject").value='';
	document.getElementById("S_description").value='';
	document.getElementById("shareE").innerHTML='';
   	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);
	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("maskDivMedia").style.height = cntHeight+"px";
	document.getElementById("maskDivMedia").style.width  = cntWidth+"px";	
	//document.getElementById("div_loading").style.display = 'block';	
	$("#div_loading").fadeIn(2000);
	return false;
}
function ShareEventsView(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>";
							$("#shareDiv").fadeOut(2000);
							$("#div_loading").fadeOut(2000);
							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;
   } 

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