// JavaScript Document


function validate_captcha(captcha_value, frm){
	new ajax ('ajax.php', {postBody: 'method=validate_captcha&captcha_value='+captcha_value, onComplete: validate_captcha_callback, userVariable: frm});
	document.getElementById("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	document.getElementById("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	document.getElementById("WAIT").style.display = '';
	document.getElementById("COVER").style.display = '';
	document.getElementById("COVER").style.height = Screen.getDocumentHeight()+'px';
}

function validate_captcha_callback(request, uservar){
	document.getElementById("WAIT").style.display = 'none';
	document.getElementById("COVER").style.display = 'none';
	if(request!=null){
		if(request.responseText=="OK"){
			uservar.submit();
		}else if(request.responseText=="INVALID"){
			alert("Invalid Verification Code !!");
			captchaNew();
		}else{
			captchaNew();
			alert("There was a problem communicating with the server\n\nPlease try later on");
		}
	}else{
		captchaNew();
		alert("There was a problem communicating with the server\n\nPlease try later on");
	}
}



function get_maildata(request, frm, status){
		document.getElementById("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	document.getElementById("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	document.getElementById("WAIT").style.display = '';

	new ajax ('ajax.php', {postBody: 'method=maildata&EditID='+request+'&status='+status, onComplete: get_maildata_callback, userVariable: frm});
}

function get_maildata_callback(request, uservar1){
document.getElementById("WAIT").style.display = 'none';
		if(request.responseText!=""){
			
			document.getElementById(uservar1).innerHTML = request.responseText;
	}
	else{
		document.getElementById(uservar1).innerHTML = "<strong>There was a problem getting the mail from srever !!</strong>";
		}
}

function addsession(subject1,frm,message1){alert(message1);
new ajax ('ajax.php', {postBody: 'method=addsession&subject1='+subject1+'&message1='+message1, onComplete: addsession_callback, userVariable: frm});
}

function addsession_callback(s,ss){
if(request.responseText!=""){
			
			alert(request.responseText);
	}
	}
	
	function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
alert(document.cookie);
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
/*========================= My Images Upload Scripts ==============================*/
function start_album_image_upload(){
	document.getElementById('div_uploader').style.display = 'none';
    document.getElementById("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	document.getElementById("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	document.getElementById("WAIT").style.display = '';
	document.getElementById("COVER").style.display = '';
	document.getElementById("COVER").style.height = Screen.getDocumentHeight()+'px';
    return true;
}

function album_image_upload_done(success){
	document.getElementById("WAIT").style.display = 'none';
	document.getElementById("COVER").style.display = 'none';   
	if (success >= 1){
		alert("Newsletter Subscription successfull");
		window.location.reload();
	}else {
		alert("Subscription failed !!\n\nPlease try later on");
	}  
	return true;   
}
/*================================================================================*/