$(document).ready(function()
{
	screenshotPreview();
	$('#goto_comment').click(function(){$('#comment').ScrollTo(1000);return false});
	$('#goto_comment_view').click(function(){$('#comment_view').ScrollTo(1000);return false});
	$('#goto_go_to_top').click(function(){$('#go_to_top').ScrollTo(1000);return false});
}); //close doc ready

function deleteReview(reviewID)
{
	var answer = confirm("Are you sure do you want to delete this Review and its all comment.")
	if (answer)
	{
		var url =siteURL+"delete_institution_review.php?reviewID="+reviewID;
		window.location = url;
	}
	else
	{
		return false;
	}
}

function deleteReviewInternationalSiteURL (reviewID)
{
	var answer = confirm("Are you sure do you want to delete this Review and its all comment.")
	if (answer)
	{
		var url =internationalSiteURL +"delete_institution_review.php?reviewID="+reviewID;
		window.location = url;
	}
	else
	{
		return false;
	}
}

var ajax	=	new sack()
function is_user_ermail_exists()
{
	if(document.getElementById('err_password_msg')!=null)
	{
		document.getElementById('err_password_msg').innerHTML = ''
	}
	var txtEmail	=	document.getElementById('txtEmail')
	var Pattern 	=	 /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	if(txtEmail.value=="")
	{
		document.getElementById('email_msg_div').innerHTML = 'Email Must be filled.'
		txtEmail.focus();
		return false;
	}
	else
	if(!Pattern.test(txtEmail.value))
	{
		document.getElementById('email_msg_div').innerHTML = 'Email Must be valid.'
		txtEmail.focus();
		return false
	}
	
	ajax.requestFile = siteURL+'user_check_availity.php?txtEmail='+txtEmail.value;	// Specifying which file to get
	
	ajax.onCompletion = stateAlertForUserEmail;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function	
}

function stateAlertForUserEmail() 
{ 
   if(ajax.response == '')
   {
		document.getElementById('email_msg_div').innerHTML = 'You are not registered. Please choose a password to auto-register.';
   }
   else
   {
		document.getElementById('email_msg_div').innerHTML = 'This email is already registred please enter your password.';
   }
   document.getElementById('passwordDiv').style.display	=	'block';
   document.frmWriteComment.txtPassword.focus();

}
var error_msg_div='';
var show_password_div='';
function is_user_email_reply_exists(email_id,email_child_div,txtPassword_div)
{
	error_msg_div		=	email_child_div
	show_password_div	=	txtPassword_div
	var txtEmail	=	document.getElementById(email_id)
	var Pattern 	=	 /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	if(txtEmail.value=="")
	{
		document.getElementById(email_child_div).innerHTML = 'Email Must be filled.'
		txtEmail.focus();
		return false;
	}
	else
	if(!Pattern.test(txtEmail.value))
	{
		document.getElementById(email_child_div).innerHTML = 'Email Must be valid.'
		txtEmail.focus();
		return false
	}
	
	ajax.requestFile = siteURL+'user_check_availity.php?txtEmail='+txtEmail.value;	// Specifying which file to get
	
	ajax.onCompletion = stateAlertForUserEmail_child;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function	
}
function stateAlertForUserEmail_child() 
{ 
   if(ajax.response == '')
   {
		document.getElementById(error_msg_div).innerHTML = 'You are not register please choose password for auto registartion.';
   }
   else
   {
		document.getElementById(error_msg_div).innerHTML = 'This email is already registred please enter your password.';
   }
   document.getElementById(show_password_div).style.visibility	=	'visible';

}



	function get_reply_validation(obj,did)
	{
		var msg	=	'';
		getstr	=	'?'
		var Pattern = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
		var txtComment		=	document.getElementById('txtComment'+did).value
		getstr	+=	"txtComment="+txtComment
		
		if(document.getElementById('txtName'+did) !=null)
		{
			var txtName			=	document.getElementById('txtName'+did).value
			var txtEmail		=	document.getElementById('txtEmail_'+did).value
			var txtPassword		=	document.getElementById('txtPassword_'+did).value
			getstr	+=	"&txtName="+txtName
			getstr	+=	"&txtEmail="+txtEmail
			getstr	+=	"&txtPassword="+txtPassword
		}


		if(txtComment=='')
		{
			msg = "Please Enter Reply"+"\n"
			alert(msg);
			document.getElementById('txtComment'+did).focus();
			return false;
		}
		else
		if(document.getElementById('txtName'+did) !=null)
		{
			if(txtName=='')
			{
				msg = "Please Enter Name"+"\n"
				alert(msg);
				document.getElementById('txtName'+did).focus();
				return false;
			}
			else
			if(txtEmail=='')
			{
				msg = "Please Enter Email"+"\n"
				alert(msg);
				document.getElementById('txtEmail_'+did).focus();
				return false;
			}
			else
			if(!Pattern.test(txtEmail))
			{
				msg = "Please Enter valid Email"+"\n"
				alert(msg);
				document.getElementById('txtEmail_'+did).focus();
				return false;
			}
			else
			if(txtPassword=='')
			{
				msg = "Please Enter Paasword"+"\n"
				alert(msg);
				document.getElementById('txtPassword_'+did).focus();
				return false;
			}
		}
		var hdnReviewID	= document.getElementById('hdnReviewID_'+did).value
		var parentID	= document.getElementById('parentID_'+did).value
		getstr	+=	"&hdnReviewID="+hdnReviewID
		getstr	+=	"&parentID="+parentID
		add_a_reply(siteURL+'save_comment.php',did, getstr);
	
   }

var load_area	=''
function add_a_reply(url,did, getstr)
{

	load_area	="error_"+did;
	ajax.requestFile = url+getstr	// Specifying which file to get
	
	ajax.onCompletion = stateAlertForUserRepply;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function	
}

function stateAlertForUserRepply() 
{ 
   if(ajax.response != '')
   {
		document.getElementById(load_area).innerHTML = '<span style="font-weight:bold;font-size:12px">'+ajax.response+'</span>';
   }
   else
   {
		document.getElementById(load_area).innerHTML = '<span style="font-weight:bold;font-size:12px">comment has been successfully added.</span>';
		window.location.reload();
   }
}

