// JavaScript Document

/// show hide edit field

function contact_for_inquiry(reqid)
{

	showPopWin('Contact Now','_contactrequirement.php?i='+reqid, 500, 280, null);
	
}

function subsribe_now(emailid)
{
	
	
	showPopWin('Subscribe Now','_emailform.php?t=s&emailid='+emailid, 500, 280, null);
	
}
function register_now(emailid)
{
	
	showPopWin('Send your information to us','_registerform.php?t=s&emailid='+emailid, 500, 300, null);
	
}

function set_book_mart(propertyid)
{
	abhurlwindow('Bookmark','_setbookmark.php?p='+propertyid,400,170);
}
function skipDisabled(id)
{
    var A=document.getElementById(id);
	if(A.options[A.selectedIndex].disabled)
	{
		
		if(A.options.length<=1)
		{
			A.selectedIndex=-1;
		}
		else
		{
			if(A.selectedIndex<A.options.length-1)
			{
				A.selectedIndex++;
			}
			else
			{
				A.selectedIndex--;
			}
			
		}
	
	}

}
function show_pwd_reminder_window()
{
	abhurlwindow('Reset Password','_password_reminder.php',750,300);
}

function view_inquiry_window(id)
{
	abhurlwindow('View Inquiry','_view_inquiry.php?i='+id,750,300);
}

function show_contact_now(i)
{
	
	showPopWin('Send Your Message','_send_inquiry_email.php?i='+i, 500, 400, null);
}

function attri_radio(fieldnm,attriname)
{

// for radio

		// set var radio_choice to false

		var my_attri_val;

		var radio_choice = false;

		

		// Loop from zero to the one minus the number of radio button selections

		for (counter = 0; counter < fieldnm.length; counter++)

		{

		// If a radio button has been selected it will return true

		// (If not it will return false)

				if (fieldnm[counter].checked)

				{

					radio_choice = true; 

				

				   var my_attri_val =  fieldnm[counter].getAttribute(attriname);

					

				}

		}

		



		return my_attri_val; /// means not selected





}



function attri_listbox(id,attriname)

{

// for listbox

var selected_index = document.getElementById(id).selectedIndex;



var my_attri_val = document.getElementById(id).options[selected_index].getAttribute(attriname);

if( my_attri_val)

{

  return my_attri_val;

}

else

{

  return "";

}



}



function attri(id,attriname)

{

// for text box, label, textarea

var my_attri_val= document.getElementById(id).getAttribute(attriname);





if( my_attri_val)

{

  return my_attri_val;

}

else

{

  return "";

}



}





function add_main_links()

{

	//showPopWin('_add_mainpage_link.php', 600, 300, null);

	window.location='_add_mainpage_link.php';

}



function add_sub_links(mainid)

{

	//showPopWin('_add_mainpage_link.php?mainid='+mainid, 400, 200, null);

	window.location='_add_mainpage_link.php?mainid='+mainid;

}


function set_html_value(sourceid,str)

{

document.getElementById(sourceid).innerHTML=str;	

}

function set_id_value(sourceid,str)

{

document.getElementById(sourceid).value=str;	

}

function copy_content(sourceid,targetid)

{

document.getElementById(targetid).value=document.getElementById(sourceid).value;

}

// remove blank space from value

function remove_space_all(str)

{

	var str=str;

	return (str.replace(/ /g, ""));

}

function remove_space_all(str)

{



var str=str;

return (str.replace(/ /g, ""));

}



function show_edit(rowid)

{

var x;

var rowid=rowid;

// table-row or none

if(document.getElementById(rowid).style.display=="none")

{

   try

   {

   document.getElementById(rowid).style.display="table-row";

   }

   catch(e)

   {

      document.getElementById(rowid).style.display="block";

   }

}

else

{

document.getElementById(rowid).style.display="none";

}

}



function roundNumber(pnumber,decimals)

{

	if (isNaN(pnumber)) { return 0};

	if (pnumber=='') { return 0};

	

	var snum = new String(pnumber);

	var sec = snum.split('.');

	var whole = parseFloat(sec[0]);

	var result = '';

	

	if(sec.length > 1){

		var dec = new String(sec[1]);

		dec = String(parseFloat(sec[1])/Math.pow(10,(dec.length - decimals)));

		dec = String(whole + Math.round(parseFloat(dec))/Math.pow(10,decimals));

		var dot = dec.indexOf('.');

		if(dot == -1){

			dec += '.'; 

			dot = dec.indexOf('.');

		}

		while(dec.length <= dot + decimals) { dec += '0'; }

		result = dec;

	} else{

		var dot;

		var dec = new String(whole);

		dec += '.';

		dot = dec.indexOf('.');		

		while(dec.length <= dot + decimals) { dec += '0'; }

		result = dec;

	}	

	return result;

}







function roundNumber_old(number,decimal_points) 

{

//

	if(!decimal_points) return Math.round(number);

	if(number == 0) {

		var decimals = "";

		for(var i=0;i<decimal_points;i++) decimals += "0";

		return "0."+decimals;

	}



	var exponent = Math.pow(10,decimal_points);

	var num = Math.round((number * exponent)).toString();

	

	return num.slice(0,-1*decimal_points) + "." + num.slice(-1*decimal_points)

}



/// delete confir

function create() {

 var go = confirm("Are you sure to DELETE this record?");

 if (go == true) {

   return true;

 }

 else {

  return false;

 }

}

function confirm_msg(str) {

 var go = confirm(str);

 if (go == true) {

   return true;

 }

 else {

  return false;

 }

}



function pop_message(str) {

 var go = confirm(str);

 if (go == true) {

   return true;

 }

 else {

  return false;

 }

}





/// check is it blank

function ISBLANK(xx)

{ 

        var cc=0,tt;

		for(tt=0; tt<xx.length; tt++)

		{

		     if (xx.charAt(tt)==' ')

			 {

			 	cc=cc+1; // count blank character

			 }

		}

		if (cc==xx.length)

		{

			return true;  //// means it is BLANK

		}

	     return false;	//// means it is NOT BLANK

}



// is valid image file jpg/jpeg/gif

function IsValidimage(xx) 

	{   

	    var str=xx;

		

		var dotpos=str.lastIndexOf('.');

		var rr=(str.charAt(dotpos+1)+str.charAt(dotpos+2)+str.charAt(dotpos+3)+str.charAt(dotpos+4));

		

		if (rr.toLowerCase()=="jpg" || rr.toLowerCase()=="gif" || rr.toLowerCase()=="jpeg" || rr.toLowerCase()=="png")

		{

			return true;

		}

		else

		{

			return false;

		}

    }

	

///////// RADIO BUTTON VALIDATION ////////



/*

/// how to call in main function

function CheckAll(x)

{

if(!is_radio_button_selected(x.radiobutton_name))

{

  alert ("Please select radio button !!");

  return false;

}

}

*///



function selected_radio_value(fieldnm)

{

		// set var radio_choice to false

		var radio_choice = false;

		

		// Loop from zero to the one minus the number of radio button selections

		for (counter = 0; counter < fieldnm.length; counter++)

		{

		// If a radio button has been selected it will return true

		// (If not it will return false)

				if (fieldnm[counter].checked)

				{

					radio_choice = true; 

				

				    return fieldnm[counter].value

				}

		}

		



		return -1;; /// means not selected





			

}

function is_radio_button_selected(fieldnm)

{

	

		// set var radio_choice to false

		var radio_choice = false;

		

		// Loop from zero to the one minus the number of radio button selections

		for (counter = 0; counter < fieldnm.length; counter++)

		{

		// If a radio button has been selected it will return true

		// (If not it will return false)

		if (fieldnm[counter].checked)

		radio_choice = true; 

		}

		

		if (!radio_choice)

		{

		return (false); /// means not selected

		}

		return (true); /// means selected

}



///
function is_checkbox_button_selected_PHPARRAY(fieldnm)
{
// set var radio_choice to false
var radio_choice = false;
alert( fieldnm.length);

// Loop from zero to the one minus the number of radio button selections

for (counter = 0; counter < fieldnm.length; counter++)

{

// If a radio button has been selected it will return true

// (If not it will return false)

if (fieldnm[counter].checked)

radio_choice = true; 

}



if (!radio_choice)

{

return (false); /// means not selected

}

return (true); /// means selected

}

function is_checkbox_button_selected(fieldnm)

{

// set var radio_choice to false

var radio_choice = false;



// Loop from zero to the one minus the number of radio button selections

for (counter = 0; counter < fieldnm.length; counter++)

{

// If a radio button has been selected it will return true

// (If not it will return false)

if (fieldnm[counter].checked)

radio_choice = true; 

}



if (!radio_choice)

{

return (false); /// means not selected

}

return (true); /// means selected

}



///



function checkemail(myemail)

{

var str=myemail;

var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

if (filter.test(str))

{

testresults=true

}

else

{

testresults=false

}

return (testresults)

}


function showprocess_new(str)
{
    var content3 = str;
	TINY.box.show(content3,0,0,0,0,0);
	
}

function image_upload_process_abh_old()
{
	showprocess_new('<table width=\"700\" border=\"0\" cellspacing=\"2\" cellpadding=\"1\"><tr><td height=\"81\"><span class=abhpatient><center>Your pictures are being uploaded to our server. <br>Please be patient it could take some time depending on the size and number of the files.<br><br><img src=images/ajax3.gif></center></span></td>  </tr></table>');
}
function form_upload_process_abh_old()
{
	showprocess_new('<table width=\"412\" border=\"0\" cellspacing=\"2\" cellpadding=\"1\"><tr><td height=\"81\"><span class=abhpatient><center>Please be patient ....<br><br><img src=images/ajax3.gif></center></span></td>  </tr></table>');
}


function image_upload_process_abh()
{
  //	showPopWin('_upload_cotinue.php', 700, 220, null);
  // calling another file
//	procwindow=dhtmlmodal.open('processwindow', 'iframe', '_upload_cotinue.php', 'Please be patient', 'width=700px,height=220px,center=1,resize=0,scrolling=0');
agewindow=dhtmlmodal.open('Process', 'div', 'modalalertdiv', 'Please be patient', 'width=700px,height=220px,left=150px,top=100px,resize=0,scrolling=0')
}
