var detect = navigator.userAgent.toLowerCase();
var clicked = 0;
small = new Image();
small.src="/images/save-button-small.gif";
grey = new Image();
grey.src="/images/save_grey.gif";

chargerbutton = new Image();
chargerbutton.src="/images/process_grey.gif";


function otherview()
{
	if(document.signup.responses.value!=0)
		document.signup.other.disabled=true;
	else 
		document.signup.other.disabled=false;
		
}



function sendmessage()
{
	if(clicked==0)
	{
	clicked = 1;
	document.sendmessageform.submit();
        }
       	else
	{
	alert('Please wait, your message is sending');
	}

}


    function set_recharge( string )
    {
        
	    var agree=confirm("Do you want to charge your card?");
	    
	    if (agree)
	    {
	         document.manualch.manualcharge.value ='go';
		 document.manualch.manualkey.value = string; 
		 document.manualch.manual.value = '1';  
	         show_progress('chargerbutton');    
	        // alert('here');
	     }
	    else
	    {
		//alert('here 11');
		return false ;
            }		

  
    }

 function start_paypal( string )
    {        
	    var agree=confirm("Would you like to recharge your account with Paypal?");
	    
	    if (agree)
	    {
	         document.manualch.manualcharge.value ='go_paypal';
		 document.manualch.manualkey.value = string; 
		 document.manualch.manual.value = '1';  
	        document.manualch.submit();
	     }
	    else
	    {
		//alert('here 11');
		return false ;
            }		

  
    }


function show_progress(imagename)
{
if(document.images)
	{
	document.images[imagename].src=eval(imagename+".src");
	if(clicked==0)
		{
		clicked = 1;
						
		document.manualch.submit();
		
		return false;
		}	
	else
	{
	       
		return false;	
		
	}
	}	
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function change_button(imagename)
{
document.autoch.colorbutton.value='imagename';
document.autoch.autorecharge.value='changebutton';
document.autoch.submit();

//alert(objectsrc);
//if(document.images)
//document.images[imagename].src=eval(objectsrc+".src")
//document.images[imagename].disabled;
}

function echange_button(imagename)
{
document.autoch.colorbutton.value='imagename';
document.autoch.autorecharge.value='changebutton_fake';
document.autoch.submit();
//alert(objectsrc);
//if(document.images)
//document.images[imagename].src=eval(objectsrc+".src")
//document.images[imagename].disabled;
}


function check_browser()
{
        var validator = 0;

	if (checkIt('msie'))
		{
	        browser = "Internet Explorer";
		version = detect.charAt(place + thestring.length);
		 if(version < 6)
                    validator=1;
	        }
	/*
	else if (!checkIt('compatible'))
		{
		browser = "Netscape Navigators"
		version = detect.charAt(8);
	        }
	else if (checkIt('firefox') && )
		{
		browser = "FireFox";
		version = detect.charAt(place + thestring.length);
	        }
	*/

	if(validator)
	  window.location = "browser_error.php";
	  //window.open("browser_error.php", null,"status=yes,toolbar=no,menubar=no,location=no");

}


function poponload()
{
testwindow= window.open ("/recharge_fail.htm", "mywindow", 'titlebar=no, toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=no,location=center,width=400,height=400');
testwindow.moveTo(0,0);
}

function getCallHistory(page, order) {
 
        document.forms[0].elements[0].value = page;
        document.forms[0].elements[1].value = order;
        document.forms[0].submit();

        return true;
}

function poponload_index()
{
//testwindow= window.open ("/promotion.htm", "mywindow", 'titlebar=no, toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=no,location=center,width=475,height=365');
testwindow= window.open ("/promotion.htm", "mywindow", 'titlebar=no, toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=no,location=center,width=430,height=430');

//testwindow= window.open ("/promotion.htm", "mywindow", 'titlebar=no, toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=no,location=center,width=510,height=130');

testwindow.moveTo(0,0);
}

function getCallHistory(page, order) {
 
        document.forms[0].elements[0].value = page;
        document.forms[0].elements[1].value = order;
        document.forms[0].submit();

        return true;
}


function updateAccountField() {

	if (document.getElementById) {

		the_field	= document.getElementById('account_number');
		area_code	= document.getElementById('phone_areacode');
		middle		= document.getElementById('phone_middle');
		rest		= document.getElementById('phone_rest');

		the_field.value	= area_code.value + middle.value + rest.value;

		return true;
	}

	return false;
}
function checkalldial(counting, current)
{
       	var i, get=0;
	var somevalue = current.value;
	for(i=0; i< counting;i++)
	{
	if(document.getElementsByTagName('select')[i].value==somevalue)
		{
		get++;
	        }
        
        }
	
	
	if(get>1)
	{
	alert("Dial Eezy should be unique for each phone number");
	current.value = 'none';
	return false;
	}
}


function enableSave(counting) {
       	
       	if (document.getElementById) {

                savebutton              = document.getElementById('sync');
                savebutton.disabled     = false;

		return true;
	}

	return false;
}

function enableSave2(counting) {
       	
       	if (document.getElementById) {

                savebutton              = document.getElementById('sync2');
                savebutton.disabled     = false;

		return true;
	}

	return false;
}



function count_message(event, checkfild)
{

var prevalues = checkfild.value;

if(prevalues.length<95)
	{
	document.refer_fr.counter.value=(94-prevalues.length);
	return -1;
	}
else
	{
	checkfild.value = prevalues.substring(0,94);
	alert("Too many characters in Personal Message.");
	return prevalues;
	}
}



function check_field(event, checkfild, action)
{
//event - podiya yaka vyklykaetcya presskey
//checkfild - obekt polya yake pereviryaetsya
//action - typ polya dlya perevirky
//abc - bukvy tilky
//digit - cyfry tilky
//phone - cyfry, probil, tere
var prevalues= checkfild.value;
switch(action)
{

	case 'abc'://test for abcd only
///////////////for Netscape////////////////////////////
	
if(navigator.appName=='Netscape')
{

	if(!event.ctrlKey)
	{if((event.charCode<47)||(event.charCode>58) || (event.charCode==0)){return -1;}
	else{return prevalues;}}
	else{if((event.charCode==99)||(event.charCode==118) || (event.charCode==86)){return -1;}}
}
//////////////for Microsoft Internet Explorer///////////
if(navigator.appName=='Microsoft Internet Explorer')
{
	if((event.keyCode<47) || (event.keyCode>58)){return -1;}
	else{return prevalues;}
}
///////////////////////////////////////////////
    break;
	case 'digit':
///////////////////////////////////////////////
if(navigator.appName=='Netscape')
{
	if(!event.ctrlKey)
	{if(((event.charCode>47) && (event.charCode<58)) || (event.charCode==0)){return -1;}
	else{return prevalues;}}
	else{if((event.charCode==99)||(event.charCode==118) || (event.charCode==86)){return -1;}}
}
///////////////////////////////////////////////
if(navigator.appName=='Microsoft Internet Explorer')
	{if((event.keyCode>47)&&(event.keyCode<58)){return -1;}
	else{return prevalues;}}	
///////////////////////////////////////////////
	break;		
	case 'phone':
///////////////////////////////////////////////
if(navigator.appName=='Netscape')
{
	if(!event.ctrlKey)
	{if(((event.charCode>47) && (event.charCode<58)) || (event.charCode==43) || (event.charCode==32) || (event.charCode==45) || (event.charCode==0)){return -1;}
	else{return prevalues;}}
	else{if((event.charCode==99)||(event.charCode==118) || (event.charCode==86)){return -1;}}
}
///////////////////////////////////////////////
if(navigator.appName=='Microsoft Internet Explorer')
	{if( ((event.keyCode>47) && (event.keyCode<58)) || (event.keyCode==43) || (event.keyCode==32) || (event.keyCode==45) || (event.keyCode==0)){return -1;}
	else{return prevalues;}}	
///////////////////////////////////////////////
	break;	
}	
}

//--------------------------------------------------------------------

function checkpasw()
	{

	if (document.getElementById) {
	
			emaile	        = document.getElementById('email');
			agente	        = document.getElementById('agent');
			
			if(emaile.value==agente.value)
			   {
			   agente.value = '';
			   alert("Agent email can not be the same as user email")
			   return false;
			   }
			else
			   return false;
		}
	
	return false;
        
	}

//---------------------------------------------------------------------
function checkmail()
	{

	if (document.getElementById) {
	
 
			emaile	        = document.getElementById('email');
			cemaile          = document.getElementById('cemail');
			
			if(emaile.value!=cemaile.value)
			   {
			   cemaile.value = '';
			   alert("Please make sure, that you type the same email address");
			   return false;
			   }
			else
			   return false;
		}
	
	return false;
        
	}

 
function openWin(url, w, h) 
{ 
var winprop = "width=" + w + ",height=" + h; 
var newurl = "did.html";
var url = newurl
openwin = window.open(url,'',winprop); 
} 


function submit_action(actioname)
{      
       // alert(actioname);
        
	document.tester.action.value=actioname;
	document.tester.submit();
	return false;	
}


function del_action(actioname,itid)  // used in the phone book delete
{      
        
        var agree=confirm("Are you sure you want to delete this entry?");
         
        if (agree)
        {
		document.manualch.saction.value=actioname;
		document.manualch.itid.value  =itid;
		document.manualch.submit();
		//alert(actioname);
		return true;	
	}
	else
	{
	       //alert('here 11');
	       return false ;
	}		
}

function id_action(actioname,itid)  // used in the phone book delete
{      
       // alert(actioname);
        var agree=confirm("Are you sure you want to delete this entry?");
         
        if (agree)
        {
		document.tester.action.value=actioname;
		document.tester.itid.value  =itid;
		document.tester.submit();
		return false;	
	}
	else
	{
	       //alert('here 11');
	       return false ;
	}		
}

function save_speed(actioname,itid)  // used in the phone book delete
{ 
	document.tester.action.value=actioname;
	document.tester.itid.value  =itid;
	document.tester.submit();
	return false;
}

function submit_detail(list)
{      
        //alert(actioname);
        
	document.tester.action.value='viewd';
	document.tester.list.value=list;
	document.tester.submit();
	return false;	
}


function button_clicked(actioname)
{

	document.tester.action.value=actioname;
	document.tester.submit();
	//document.checkout.submit();

	document.tester.gift_cert.disabled=true;
	//alert('Disabled!');

	setTimeout('EnableButton()',1000);
	// return false;
}

function EnableButton()
{
	 document.tester.gift_cert.disabled=false;
	 //alert('Enabled!');
	 clearTimeout();
	 return false;
}


function ShowHide(id, visibility) { 
    obj = document.getElementsByTagName("div"); 
    obj[id].style.visibility = visibility; 
} 




function show(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=20; i++) {
		if (document.getElementById('answer_q'+i)) {document.getElementById('answer_q'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

