var base_url = 'http://www.xeheronline.com/';
//var base_url = 'http://localhost/xeher/';

function doSiteSearch(SearchCategory,txtSearch,mid){
	if(SearchCategory == "Internet"){
		
		window.open("http://www.google.lk/search?q="+txtSearch+"&btnG=Search&meta=");	
		
	}else if(SearchCategory == "Matrimonial"){
		
		window.open(base_url+"searchResults.seo?keyword="+txtSearch);
		
	}else if(SearchCategory == "Networking"){
		
		if(mid != ""){
			window.open(base_url+"friends.seo?f=find&name="+txtSearch);
		}else{
			showMsg('Please loging to search Networking Members');
		}
		
	}else{
		document.frm_search.submit();
	}
}

function showPanel($id)
{
	if($id == "LoginPanel")
	{
		if(document.frm.loginStatus.value =='false')
		{
			document.getElementById('LoginPanel').style.display ='block';
			document.getElementById('SearchPanel').style.display ='none';
		}else
		{
			document.getElementById('LoginSuccess').style.display ='block';
			document.getElementById('SearchPanel').style.display ='none';
		}
			
		//document.getElementById('sp_m').style.color = '#000000';
		//document.getElementById('sp_s').style.color = '#ffffff';
		
		document.getElementById('sp_m').className = "sp_select";
		document.getElementById('sp_s').className = "sp_default";
		
	}else if($id == "SearchPanel")
	{
		document.getElementById('SearchPanel').style.display ='block';
		document.getElementById('LoginPanel').style.display ='none';
		document.getElementById('LoginSuccess').style.display ='none';
		//document.getElementById('sp_s').style.color = '#000000';
		//document.getElementById('sp_m').style.color = '#ffffff';		
		
		document.getElementById('sp_m').className = "sp_default";
		document.getElementById('sp_s').className = "sp_select";
	}
	
}

function number_format(a, b, c, d) {
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}

function coPrice(price)
{
	return number_format(price, 2, '.', ',');	
}



//to teller friend
function setKeyword(e,status,initValue)
{
	var keywordInput = e;
	if (keywordInput!=null)
	{
		if (status=='0')
		{
			if (keywordInput.value==initValue)
			{
				keywordInput.value='';
			}
		}
		else
		{
			if (keywordInput.value.replace(/ /,'').length==0)
			{
				keywordInput.value =initValue;
			}
		}
			
	}
}
function sendEmailCompleted()
{
	form_id = 'frmtelf';
	email = 'f_email';
	name = 'u_email';
	document.getElementById('emsg').innerHTML ="Email have been submitted";
	document.forms[form_id].elements[email].value = "Friend Email";
	document.forms[form_id].elements[name].value = "Your Email";
}
function sendEmail()
{
	form_id = 'frmtelf';
	email = 'f_email';
	name = 'u_email';

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
   var your_email = document.forms[form_id].elements[name].value;
   
   if(reg.test(your_email) == false) {
	document.getElementById('emsg').innerHTML = "Invalid Your Email";
    return false;	   
   }else if(reg.test(address) == false) {
	 document.getElementById('emsg').innerHTML = "Invalid Freind Email";
      return false;
   }else
   {

	var url = base_url+"tell_a_friend_email.php?friend_email="+address+"&your_email="+your_email;	
	
	ajax.requestFile = url;
	ajax.method = "post";
	ajax.onCompletion = sendEmailCompleted;
	ajax.runAJAX();
   }   
}

function getPageSize() {
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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;
	}	

	return [windowWidth,windowHeight];
}

//--------------------------------------------------------------------
// find array
// Examples
/*var test=[1,58,'blue','baby','boy','cat',35,'35',18,18,104]
result1=test.find(35);    //returns 6
result2=test.find(/^b/i); //returns 2,3,4
result3=test.find('35');  //returns 7
result4=test.find(18);    // returns 8,9
result5=test.find('zebra'); //returns false
*/
Array.prototype.find = function(searchStr) {
  var returnArray = false;
  for (i=0; i<this.length; i++) {
    if (typeof(searchStr) == 'function') {
      if (searchStr.test(this[i])) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    } else {
      if (this[i]===searchStr) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    }
  }
  return returnArray;
}
//---------------------------------------------------------------------

var minS=11;
var maxS=18;

function increase() {
   var p = document.getElementById('div_Article_para').getElementsByTagName('span');
   for(i=0;i<p.length;i++) {
	  if(p[i].style.fontSize) {
		 var s = parseInt(p[i].style.fontSize.replace("px",""));
	  } else {
		 var s = 12;
	  }
	  if(s!=maxS) {
		 s += 1;
	  }
	  p[i].style.fontSize = s+"px"
   }
}
function decrease() {
   var p = document.getElementById('div_Article_para').getElementsByTagName('span');
   for(i=0;i<p.length;i++) {
	  if(p[i].style.fontSize) {
		 var s = parseInt(p[i].style.fontSize.replace("px",""));
	  } else {
		 var s = 12;
	  }
	  if(s!=minS) {
		 s -= 1;
	  }
	  p[i].style.fontSize = s+"px"
   }   
}
function artical_print()
{
	var a = window.open('','','width=300,height=600');
	a.document.open("text/html");
	a.document.write('<html><head><title>printing Deepam TV</title><link rel="stylesheet" type="text/css" href="css/style.css" /><style>div#ArticleTools{display:none;}</style></head><body>');
	a.document.write(document.getElementById('div_Article_para').innerHTML);
	a.document.write('</body></html>');    	
	a.document.close();
	a.print();
}

//---------------------------------------------------------------------

function In_Completed()
{
	window.location.href = "profile.php";
}
function doConfirm(fid,status,member_id)
{
	var url = base_url+"friend_invite_ajax.php?fid="+fid+"&member_id="+member_id+"&status="+status;
	
	if(status == "false")
	{
		var userreq=confirm('Are you sure you want to ignore ?');
		if (userreq==true)
		{
			ajax.requestFile = url;
			ajax.method = "post";
			ajax.onCompletion = In_Completed;
			ajax.runAJAX();
		}
	}else
	{
		ajax.requestFile = url;
		ajax.method = "post";
		ajax.onCompletion = In_Completed;
		ajax.runAJAX();
	}	
}

function deleteInboxMsg_Completed()
{
	window.location.href = base_url+"inbox.php?f=inbox";
}
function deleteInboxMsg(id,t)
{
	var userreq=confirm('Are you sure you want to Delete ?');
	if (userreq==true)
	{
		var url = base_url+"deleteMsg_ajax.php?id="+id+"&t="+t;	
		ajax.requestFile = url;
		ajax.method = "post";
		ajax.onCompletion = deleteInboxMsg_Completed;
		ajax.runAJAX();
	}
}

function deleteSentMsg_Completed()
{
	window.location.href = "inbox.php?f=sent";
}
function deleteSentMsg(id,t)
{
	var userreq=confirm('Are you sure you want to Delete ?');
	if (userreq==true)
	{
		var url = base_url+"deleteMsg_ajax.php?id="+id+"&t="+t;	
		ajax.requestFile = url;
		ajax.method = "post";
		ajax.onCompletion = deleteSentMsg_Completed;
		ajax.runAJAX();
	}
}

function deleteMatrimonialSentMsg_Completed()
{
	window.location.href = base_url+"matrimonial_inbox.php?f=sent";
}
function deleteMatrimonialSentMsg(id,t)
{
	var userreq=confirm('Are you sure you want to Delete ?');
	if (userreq==true)
	{
		var url = base_url+"deleteMsg_ajax.php?id="+id+"&t="+t;	
		ajax.requestFile = url;
		ajax.method = "post";
		ajax.onCompletion = deleteMatrimonialSentMsg_Completed;
		ajax.runAJAX();
	}
}

function deleteMatrimonialInboxMsg_Completed()
{
	window.location.href = base_url+"matrimonial_inbox.php?f=inbox";
}
function deleteMatrimonialInboxMsg(id,t)
{
	var userreq=confirm('Are you sure you want to Delete ?');
	if (userreq==true)
	{
		var url = base_url+"deleteMsg_ajax.php?id="+id+"&t="+t;	
		ajax.requestFile = url;
		ajax.method = "post";
		ajax.onCompletion = deleteMatrimonialInboxMsg_Completed;
		ajax.runAJAX();
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function getCharLenth(textarea, textinput, maxLen)
{
	var iMax = (!maxLen) ? 100 : maxLen;
	var charLen  = document.getElementById(textarea).value.length;
	document.getElementById(textinput).value = charLen;

	if(charLen > iMax)
	{
		document.getElementById(textarea).value = document.getElementById(textarea).value.substring(0, iMax);
		document.getElementById(textinput).value = iMax;
		alert('You can enter only '+iMax+' characters.');

	}
}

function havechildren(value)
{
	if(value == "Divorced" || value == "Widowed" || value == "Separated" || value == "Annulled")
	{
		document.getElementById('div_havechildren').style.display = "block";
	}else{
		document.getElementById('div_havechildren').style.display = "none";
	}
}

function addToMyXeher(articalId,pageType,pageUrl,member_id)
{
	var url = base_url+"ajax_myXeher.php?articalId="+articalId+"&pageType="+pageType+"&pageUrl="+pageUrl+"&member_id="+member_id	;
	ajax.requestFile = url;
	ajax.method = "post";
	//ajax.onCompletion = addToMyXeher_Completed;
	ajax.runAJAX();
	
	showMsg('Page Added Successfully');
}
function addToXShare(articalId,pageType,pageUrl,member_id)
{
	var url = base_url+"ajax_xshare.php?articalId="+articalId+"&pageType="+pageType+"&pageUrl="+pageUrl+"&member_id="+member_id	;
	ajax.requestFile = url;
	ajax.method = "post";
	//ajax.onCompletion = addToMyXeher_Completed;
	ajax.runAJAX();
	
	showMsg('Page shared Successfully');
}


function addToAlbum(ac_id,autoid,imageId,member_id)
{
	var url = base_url+"ajax_addToAlbum.php?ac_id="+ac_id+"&autoid="+autoid+"&imageId="+imageId+"&member_id="+member_id;
	ajax.requestFile = url;
	ajax.method = "post";
	//ajax.onCompletion = addAlbumCOm;
	ajax.runAJAX();
	
	showMsg('Image Added to xeher network album');

}
// Member registration --------------------------------------------
function hideAll()
{
	document.getElementById("popupcontent").style.display = "none";	
	document.getElementById("popupLoginContent").style.display = "none";
	document.getElementById("popupcontent_getInTouch").style.display = "none";
	document.getElementById("popupcontent_feedback").style.display = "none";
	document.getElementById("popupcontent_makeComment").style.display = "none";
	document.getElementById("showMsg").style.display = "none";
	document.getElementById("popupNewFriend").style.display = "none";
	document.getElementById("popupcontent_sendMsg").style.display = "none";
	document.getElementById("popupcontent_tellAFriend").style.display = "none";
	document.getElementById("popupcontent_forgotPassword").style.display = "none";
	
}

function checkRegMemCompleted()
{
	if(ajax.response == 'false')
	{
		document.forms.frmMem.submit();
	}else{
	document.getElementById('inf_RegMem').innerHTML = 'Your E-Mail Address already exists in our records - please log in with the e-mail address or create an account with a different address.';
	}
}
function checkRegMem(email)
{
	var url = base_url+"checkMember.php?email="+email;	
	ajax.requestFile = url;
	ajax.method = "post";
	ajax.onCompletion = checkRegMemCompleted;
	ajax.runAJAX();
}

function checkPidCompleted()
{
	if(ajax.response == 'false')
	{
		checkRegMem(document.forms.frmMem.email.value);
	}else{
		document.getElementById('inf_RegMem').innerHTML = 'Your Profile ID exists in our records - Please enter different Profile ID.';
	}
}

function checkPid(pid)
{
	var url = base_url+"ajax_checkProfileId.php?pid="+pid;	
	ajax.requestFile = url;
	ajax.method = "post";
	ajax.onCompletion = checkPidCompleted;
	ajax.runAJAX();
}

function validateOnSubmit() {
	var elem;
	var errs=0;
	
	if (!validatePwd    (document.forms.frmMem.password.value, document.forms.frmMem.re_password.value ,'inf_password','inf_re_password',  false)) errs += 1; 	
	if (!validateEmail  (document.forms.frmMem.email, 'inf_email', 'Email is required', true)) errs += 1; 
	if (!validatePresent(document.forms.frmMem.lname,  'inf_lname', 'Last Name is required',true)) errs += 1;
	if (!validatePresent(document.forms.frmMem.fname,  'inf_fname', 'First Name is required',true)) errs += 1; 
	if (!validatePresent(document.forms.frmMem.pid,  'inf_proid', 'ProfileId is required',true)) errs += 1; 
	
	if(errs ==0){		
		checkPid(document.forms.frmMem.pid.value);
	}
	return (errs==0);
};

var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"

function memberRegistration(){
	hideAll();	
		
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupcontent.style');
	else if(ns)	popUp=eval('document.layers["popupcontent"]');
	else if(w3)	popUp=eval('document.getElementById("popupcontent").style');

        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";
		
	showReg();	
}

function hidePopup(){
	document.forms.frmMem.re_password.value = '';
	document.forms.frmMem.password.value = '';
	document.forms.frmMem.email.value = '';
	document.forms.frmMem.lname.value = '';
	document.forms.frmMem.fname.value = '';
	document.forms.frmMem.pid.value = '';
	msg ("inf_password", "warn", "");
	msg ("inf_re_password", "warn", "");
	msg ("inf_email", "warn", "");
	msg ("inf_lname", "warn", "");
	msg ("inf_fname", "warn", "");
	msg ("inf_proid", "warn", "");
	
	document.getElementById('inf_RegMem').innerHTML = '';	
	document.getElementById("popupcontent").style.display = 'none';
	document.getElementById("popupcontent_newsLetter").style.display = 'none';
	clearTimeout ( showRegId );

}

//----------------------------------------

function showReg(){
	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	} 
	w = parseInt(360);
	h = parseInt(465);
	
	popUp = document.getElementById("popupcontent");
	//var pageSize = getPageSize();
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;
	
	//popUp.left=documentWidth-200+calunit;
	//popUp.top =documentHeight-300+calunit;
	showRegId = setTimeout("showReg()",100);
}

function truebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

// Getin Touch --------------------------------------------
function getInTouchCompleted()
{
	document.getElementById('in_msg').innerHTML = 'Email has been successfully sent';	
	setTimeout("hidePopup_getInTouch()",1500)
}
function checkgetInTouch(email)
{
	var url = base_url+"ajax_getInTouch.php?email="+document.forms.frmGetInTouch.email.value
	+"&fname="+document.forms.frmGetInTouch.fname.value
	+"&lname="+document.forms.frmGetInTouch.lname.value
	+"&subject="+document.forms.frmGetInTouch.subject.value
	+"&comments="+document.forms.frmGetInTouch.comments.value;
		
	ajax.requestFile = url;
	ajax.method = "post";
	ajax.onCompletion = getInTouchCompleted;
	ajax.runAJAX();
}


function getInTouchValidate() {
	var elem;
	var errs=0;
	if (!validatePresent(document.forms.frmGetInTouch.comments,  'in_comments', 'Comments is required',true))        errs += 1; 
	if (!validatePresent(document.forms.frmGetInTouch.subject,  'in_subject', 'Subject is required',true))        errs += 1; 
	if (!validateEmail  (document.forms.frmGetInTouch.email, 'in_email', 'Email is required', true)) errs += 1; 
	if (!validatePresent(document.forms.frmGetInTouch.lname,  'in_lname', 'Last Name is required',true))        errs += 1; 
	if (!validatePresent(document.forms.frmGetInTouch.fname,  'in_fname', 'First Name is required',true))        errs += 1; 
	
	if(errs ==0)
	{
		checkgetInTouch(document.forms.frmGetInTouch.email);
	}
	return (errs==0);
};


function getInTouch(){

	document.getElementById('in_msg').innerHTML = '';
	hideAll();

	/*w = parseInt(360);
	h = parseInt(465);
	var popUp = document.getElementById("popupcontent_getInTouch_getInTouch");
	var pageSize = getPageSize();
	
	popUp.style.top = pageSize[1]/2 - h/2  +"px";
	popUp.style.left = 990/2 - w/2 + "px";
	popUp.style.width = w + "px";
	popUp.style.height = h + "px";

	popUp.style.display = 'block';*/
	
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupcontent_getInTouch.style');
	else if(ns)	popUp=eval('document.layers["popupcontent_getInTouch"]');
	else if(w3)	popUp=eval('document.getElementById("popupcontent_getInTouch").style');
	
        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";
	
	show_getInTouch();	
}

function show_getInTouch(){

	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	}
	
	w = parseInt(360);
	h = parseInt(465);
	var popUp = document.getElementById("popupcontent_getInTouch");
	//var pageSize = getPageSize();
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;
	
	//popUp.left=documentWidth-200+calunit;
	//popUp.top =documentHeight-300+calunit;
	show_getInTouchId = setTimeout("show_getInTouch()",100);

}

function hidePopup_getInTouch(){
	document.forms.frmGetInTouch.comments.value = '';
	document.forms.frmGetInTouch.subject.value = '';
	document.forms.frmGetInTouch.email.value = '';
	document.forms.frmGetInTouch.lname.value = '';
	document.forms.frmGetInTouch.fname.value = '';
	msg ("in_comments", "warn", "");
	msg ("in_subject", "warn", "");
	msg ("in_email", "warn", "");
	msg ("in_lname", "warn", "");
	msg ("in_fname", "warn", "");
	
	var popUp = document.getElementById("popupcontent_getInTouch");
	popUp.style.display = 'none';
	
	clearTimeout ( show_getInTouchId );
}

// feedback --------------------------------------------
function feedbackCompleted()
{
	document.getElementById('infb_msg').innerHTML = 'Email has been successfully sent';	
	setTimeout("hidePopup_feedback()",1500)
}
function checkfeedback(email)
{
	var url = base_url+"ajax_feedback.php?email="+document.forms.frmFeedBack.email.value
	+"&fname="+document.forms.frmFeedBack.fname.value
	+"&lname="+document.forms.frmFeedBack.lname.value
	+"&subject="+document.forms.frmFeedBack.subject.value
	+"&comments="+document.forms.frmFeedBack.comments.value;
		
	ajax.requestFile = url;
	ajax.method = "post";
	ajax.onCompletion = feedbackCompleted;
	ajax.runAJAX();
}


function feedbackValidate() {
	var elem;
	var errs=0;
	if (!validatePresent(document.forms.frmFeedBack.comments,  'infb_comments', 'Comments is required',true))        errs += 1; 
	if (!validatePresent(document.forms.frmFeedBack.subject,  'infb_subject', 'Subject is required',true))        errs += 1; 
	if (!validateEmail  (document.forms.frmFeedBack.email, 'infb_email', 'Email is required', true)) errs += 1; 
	if (!validatePresent(document.forms.frmFeedBack.lname,  'infb_lname', 'Last Name is required',true))        errs += 1; 
	if (!validatePresent(document.forms.frmFeedBack.fname,  'infb_fname', 'First Name is required',true))        errs += 1; 
	
	if(errs ==0)
	{
		checkfeedback(document.forms.frmFeedBack.email);
	}
	return (errs==0);
};


function feedback(){

	document.getElementById('infb_fmsg').innerHTML = '';
	hideAll();

	/*w = parseInt(360);
	h = parseInt(465);
	var popUp = document.getElementById("popupcontent_feedback_feedback");
	var pageSize = getPageSize();
	
	popUp.style.top = pageSize[1]/2 - h/2  +"px";
	popUp.style.left = 990/2 - w/2 + "px";
	popUp.style.width = w + "px";
	popUp.style.height = h + "px";

	popUp.style.display = 'block';*/
	
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupcontent_feedback.style');
	else if(ns)	popUp=eval('document.layers["popupcontent_feedback"]');
	else if(w3)	popUp=eval('document.getElementById("popupcontent_feedback").style');
	
        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";
	
	show_feedback();	
}

function show_feedback(){

	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	}
	
	w = parseInt(360);
	h = parseInt(465);
	var popUpFB = document.getElementById("popupcontent_feedback");
	//var pageSize = getPageSize();
	
	popUpFB.style.top = (documentHeight - h/2)  +calunit;
	popUpFB.style.left = (980/2 - w/2) +calunit;
	
	//popUp.left=documentWidth-200+calunit;
	//popUp.top =documentHeight-300+calunit;
	show_feedbackId = setTimeout("show_feedback()",100);

}

function hidePopup_feedback(){
	document.forms.frmFeedBack.comments.value = '';
	document.forms.frmFeedBack.subject.value = '';
	document.forms.frmFeedBack.email.value = '';
	document.forms.frmFeedBack.lname.value = '';
	document.forms.frmFeedBack.fname.value = '';
	msg ("infb_comments", "warn", "");
	msg ("infb_subject", "warn", "");
	msg ("infb_email", "warn", "");
	msg ("infb_lname", "warn", "");
	msg ("infb_fname", "warn", "");
	
	var popUpFB = document.getElementById("popupcontent_feedback");
	popUpFB.style.display = 'none';
	
	clearTimeout ( show_feedbackId );
}
// tellAFriend --------------------------------------------
function tellAFriendCompleted()
{
	document.getElementById('inf_msg').innerHTML = 'Tell a Friend has been successfully sent';	
	setTimeout("hidePopup_tellAFriend()",1500)
}
var fid;
var fm;
var fmode;
function checktellAFriend(email)
{
	var url = base_url+"tell_a_friend_ajax.php?email="+document.forms.frmtellAFriend.email.value
	+"&fname="+document.forms.frmtellAFriend.fname.value
	+"&email="+document.forms.frmtellAFriend.email.value
	+"&yname="+document.forms.frmtellAFriend.yname.value
	+"&id="+fid
	+"&m="+fm
	+"&mode="+fmode;
	
	ajax.requestFile = url;
	ajax.method = "post";
	ajax.onCompletion = tellAFriendCompleted;
	ajax.runAJAX();
}


function tellAFriendValidate() {
	var elem;
	var errs=0;
	if (!validatePresent(document.forms.frmtellAFriend.yname,  'intf_yname', 'Your Name is required',true))        errs += 1; 
	if (!validateEmail  (document.forms.frmtellAFriend.email, 'intf_email', 'Email is required', true)) errs += 1; 
	if (!validatePresent(document.forms.frmtellAFriend.fname,  'intf_fname', 'First Name is required',true))        errs += 1; 
	
	if(errs ==0)
	{
		checktellAFriend(document.forms.frmtellAFriend.email);
	}
	return (errs==0);
};


function tellAFriend(id,m,mode){
	fid = id;
	fm = m;
	fmode = mode;
	
	document.getElementById('in_msg').innerHTML = '';
	hideAll();

	/*w = parseInt(360);
	h = parseInt(465);
	var popUp = document.getElementById("popupcontent_getInTouch_getInTouch");
	var pageSize = getPageSize();
	
	popUp.style.top = pageSize[1]/2 - h/2  +"px";
	popUp.style.left = 990/2 - w/2 + "px";
	popUp.style.width = w + "px";
	popUp.style.height = h + "px";

	popUp.style.display = 'block';*/
	
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupcontent_tellAFriend.style');
	else if(ns)	popUp=eval('document.layers["popupcontent_tellAFriend"]');
	else if(w3)	popUp=eval('document.getElementById("popupcontent_tellAFriend").style');
	
        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";
	
	show_tellAFriend();	
}

function show_tellAFriend(){

	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	}
	
	w = parseInt(360);
	h = parseInt(465);
	var popUp = document.getElementById("popupcontent_tellAFriend");
	//var pageSize = getPageSize();
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;
	
	//popUp.left=documentWidth-200+calunit;
	//popUp.top =documentHeight-300+calunit;
	show_tellAFriendId = setTimeout("show_tellAFriend()",100);

}

function hidePopup_tellAFriend(){
	document.forms.frmtellAFriend.yname.value = '';
	document.forms.frmtellAFriend.email.value = '';
	document.forms.frmtellAFriend.fname.value = '';
	msg ("intf_yname", "warn", "");
	msg ("intf_email", "warn", "");
	msg ("intf_fname", "warn", "");
	
	document.getElementById('inf_msg').innerHTML = '';	
	var popUp = document.getElementById("popupcontent_tellAFriend");
	popUp.style.display = 'none';
	
	clearTimeout ( show_tellAFriendId );
}

// member-make-comment-login --------------------------------------------
var articalId;
var pageType;
var pageUrl;
var pte;
var show_LoginContentId;

function checkRegMemLogCompleted()
{
	mid = ajax.response;
	if(mid == 'false')
	{
		document.getElementById('infm_RegMem').innerHTML = 'Enter Correct Login Details';		
	}else{
		if(pte == 'comment')
		{
			makeComment();
		}else if(pte == 'myxeher'){
			pte = '';
			hideLoginContent();
			addToMyXeher(articalId,pageType,pageUrl,mid);
		}else if(pte == 'xshare'){
			pte = '';
			hideLoginContent();
			addToXShare(articalId,pageType,pageUrl,mid);
		}else if(pte == 'wishList'){
			pte = '';
			hideLoginContent();
			addToMyXeher(articalId,pageType,pageUrl,mid);
		}else if(pte == 'album'){
			pte = '';
			hideLoginContent();
			addToAlbum(articalId,autoid,pageUrl,mid);
		}
		
	}
}
function checkRegMemLog(email,password)
{
	var url = base_url+"checkMemberLogin.php?email="+email+"&password="+password;	
	ajax.requestFile = url;
	ajax.method = "post";
	ajax.onCompletion = checkRegMemLogCompleted;
	ajax.runAJAX();
}

function validateMLSubmit() {
	var elem;
	var errs=0;	
		
	if (!validatePresent(document.forms.frmMemLog.txtPassword,  'infm_password', 'Password is required',true)) errs += 1;
	if (!validateEmail  (document.forms.frmMemLog.txtEmail, 'infm_email', 'Email is required', true)) errs += 1; 
	
	if(errs ==0)
	{		
		email = document.forms.frmMemLog.txtEmail.value;
		password = document.forms.frmMemLog.txtPassword.value;
		
		checkRegMemLog(email,password);
	}

	return (errs==0);
};



function memberMakeCommentLogin(title,pt,aid,pty,url){

	hideAll();
	
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupLoginContent.style');
	else if(ns)	popUp=eval('document.layers["popupLoginContent"]');
	else if(w3)	popUp=eval('document.getElementById("popupLoginContent").style');
	
        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";
	
	document.getElementById('strtitle').innerHTML = title;
	
	articalId = aid;
	pageType = pty;
	pageUrl = url;
	pte = pt;
	
	if(pte == 'comment')
	{
		document.getElementById('lblDesc').innerHTML = 'In order to add a comment to the XEHER website you need to be logged on first. Once you have logged on please click on "Make A Comment".';
	}else if(pte == 'myxeher'){
		document.getElementById('lblDesc').innerHTML = 'Message Here Message Here Message Here Message Here Message Here ';
	}else if(pte == 'xshare'){
		document.getElementById('lblDesc').innerHTML = 'Message Here Message Here Message Here Message Here Message Here ';
	}else if(pte == 'wishList'){
		document.getElementById('lblDesc').innerHTML = 'Message Here Message Here Message Here Message Here Message Here ';
	}else if(pte == 'album'){
		document.getElementById('lblDesc').innerHTML = 'Message Here Message Here Message Here Message Here Message Here ';
	}	
	
	show_LoginContent();
}

function show_LoginContent(){

	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	}
	
	w = parseInt(360);
	h = parseInt(465);
	var popUp = document.getElementById("popupLoginContent");
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;
	
	show_LoginContentId = setTimeout("show_LoginContent()",100);
}

function hideLoginContent(){

	document.forms.frmMemLog.txtPassword.value = '';
	document.forms.frmMemLog.txtEmail.value = '';

	msg ("infm_password", "warn", "");
	msg ("infm_email", "warn", "");
	
	document.getElementById('infm_RegMem').innerHTML = '';
	var popUp = document.getElementById("popupLoginContent");
	popUp.style.display = 'none';
	
	clearTimeout ( show_LoginContentId );
}

// makeComment --------------------------------------------
function makeCommentValidate() {
	var elem;
	var errs=0;
	if (!validatePresent(document.forms.frmMakeCom.comment,  'infmc_comment', 'Comment should not be empty',true))        errs += 1; 
	if(errs ==0)
	{
		document.forms.frmMakeCom.submit();
	}
	return (errs==0);
};


function makeComment(){

	hideAll();
	
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupcontent_makeComment.style');
	else if(ns)	popUp=eval('document.layers["popupcontent_makeComment"]');
	else if(w3)	popUp=eval('document.getElementById("popupcontent_makeComment").style');
	
        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";
	
	show_makeComment();	
}

function show_makeComment(){

	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	}
	
	w = parseInt(360);
	h = parseInt(465);
	var popUp = document.getElementById("popupcontent_makeComment");
	//var pageSize = getPageSize();
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;
	
	//popUp.left=documentWidth-200+calunit;
	//popUp.top =documentHeight-300+calunit;
	show_makeCommentId = setTimeout("show_makeComment()",100);

}

function hide_makeComment(){
	document.forms.frmMakeCom.comment.value = '';
	msg ("infmc_comment", "warn", "");
	
	var popUp = document.getElementById("popupcontent_makeComment");
	popUp.style.display = 'none';
	
	clearTimeout ( show_makeCommentId );
}
// showMsg --------------------------------------------
var show_showMsgId;
var showshowMsgId;

function showMsg(msg){

	hideAll();
	
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.showMsg.style');
	else if(ns)	popUp=eval('document.layers["showMsg"]');
	else if(w3)	popUp=eval('document.getElementById("showMsg").style');
	
        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";

	document.getElementById('strMsg').innerHTML = msg;
	showshowMsgId = setTimeout("hide_showMsg()",2000);
	show_showMsg();	
	
}

function show_showMsg(){

	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	}
	
	w = parseInt(360);
	h = parseInt(200);
	var popUp = document.getElementById("showMsg");
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;

	show_showMsgId = setTimeout("show_showMsg()",100);
}

function hide_showMsg(){
		
	var popUp = document.getElementById("showMsg");
	popUp.style.display = 'none';
	clearTimeout ( show_showMsgId );
	clearTimeout ( showshowMsgId );
	document.getElementById('strMsg').innerHTML = "";
	
	window.location.href=window.location.href
}

// new-friend-send-messag --------------------------------------------
function sendNewFriendEmail()
{
	var url = base_url+"ajax_NewFriendSendMsg.php?subject="+document.forms.frmSM.subject.value+"&msg="+document.forms.frmSM.message.value+"&fid="+document.forms.frmSM.fid.value;		
	/*ajax.requestFile = url;
	ajax.method = "post";
	ajax.runAJAX();	*/
	
	showMsg('Email Send Successfully');
	hidePopup_sendMsg();
}

function validateOnSubmitSM() {
	var elem;
	var errs=0;
	
	if (!validatePresent(document.forms.frmSM.message,  'sm_message', 'Message is required',true)) errs += 1; 
	if (!validatePresent(document.forms.frmSM.subject,  'sm_subject', 'Subject is required',true)) errs += 1; 
	
	if(errs ==0){		
		sendNewFriendEmail();
	}
	return (errs==0);
};

function show_NFsendMsg()
{
	
	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	}
	
	w = parseInt(400);
	h = parseInt(270);
	var popUp = document.getElementById("popupcontent_sendMsg");
	//var pageSize = getPageSize();
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;
	
	show_NFsendMsgID = setTimeout("showNFsendMsg()",100);
}

function showNFsendMsg()
{
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupcontent_sendMsg.style');
	else if(ns)	popUp=eval('document.layers["popupcontent_sendMsg"]');
	else if(w3)	popUp=eval('document.getElementById("popupcontent_sendMsg").style');
	
        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";	
	
	show_NFsendMsg();
}

function show_sendMsg(id,nm){

	hideAll();	
	hidepopupNewFriend();
	document.getElementById('fid').value = id;
	document.getElementById('fnm').innerHTML = nm;
	
	showNFsendMsg();
}

function hidePopup_sendMsg(){
	document.forms.frmSM.message.value = '';
	document.forms.frmSM.subject.value = '';

	msg ("sm_subject", "warn", "");
	msg ("sm_message", "warn", "");
	
	var popUp = document.getElementById("popupcontent_sendMsg");
	popUp.style.display = 'none';
	
	clearTimeout ( show_NFsendMsgID );
}

// Forgot password --------------------------------------------

function forgotPasswordCompleted()
{
	document.getElementById('infp_msg').innerHTML = ajax.response;	
	setTimeout("hidePopup_forgotPassword()",2000)
}
function checkforgotPassword(email)
{
	var url = base_url+"ajax_forgotPassword.php?email="+document.forms.frmforgotPassword.fp_email.value;
		
	ajax.requestFile = url;
	ajax.method = "post";
	ajax.onCompletion = forgotPasswordCompleted;
	ajax.runAJAX();
	document.getElementById('infp_msg').innerHTML = 'sending..';	
}


function forgotPasswordValidate() {
	var elem;
	var errs=0;

	if (!validateEmail  (document.forms.frmforgotPassword.fp_email, 'infp_email', 'Email is required', true)) errs += 1; 
	
	if(errs ==0)
	{
		checkforgotPassword(document.forms.frmforgotPassword.fp_email);
	}
	return (errs==0);
};


function forgotPassword(){

	document.getElementById('infp_msg').innerHTML = '';
	hideAll();
	
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupcontent_forgotPassword.style');
	else if(ns)	popUp=eval('document.layers["popupcontent_forgotPassword"]');
	else if(w3)	popUp=eval('document.getElementById("popupcontent_forgotPassword").style');
	
        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";
	
	show_forgotPassword();	
}

function show_forgotPassword(){

	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	}
	
	w = parseInt(360);
	h = parseInt(465);
	var popUp = document.getElementById("popupcontent_forgotPassword");
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;
	
	show_forgotPasswordId = setTimeout("show_forgotPassword()",100);

}

function hidePopup_forgotPassword(){
	document.forms.frmforgotPassword.fp_email.value = '';

	msg ("infp_email", "warn", "");

	var popUp = document.getElementById("popupcontent_forgotPassword");
	popUp.style.display = 'none';
	
	clearTimeout ( show_forgotPasswordId );
}


function newsLetterRegistration(){
	hideAll();	
		
	if(!ns && !ie && !w3) return;
	if(ie)		popUp=eval('document.all.popupcontent_newsLetter.style');
	else if(ns)	popUp=eval('document.layers["popupcontent_newsLetter"]');
	else if(w3)	popUp=eval('document.getElementById("popupcontent_newsLetter").style');

        if (ie||w3)
        popUp.display="block";
        else
        popUp.display ="block";
		
	showRegNewsLetter();	
}


//----------------------------------------

function showRegNewsLetter(){
	if (ie){
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	}else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	}else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20
	} 
	w = parseInt(360);
	h = parseInt(465);
	
	popUp = document.getElementById("popupcontent_newsLetter");
	//var pageSize = getPageSize();
	
	popUp.style.top = (documentHeight - h/2)  +calunit;
	popUp.style.left = (980/2 - w/2) +calunit;
	
	//popUp.left=documentWidth-200+calunit;
	//popUp.top =documentHeight-300+calunit;
	showRegId = setTimeout("showRegNewsLetter()",100);
}

