/*
 *  highlights the given item except if it is a header
 */
function liteon(obj) {
		obj.className = "hilighted";
}

/*
 *  dehighlights the given item
 */
 
function call_dwnlnk(id)
{
	document.pass_form.r1.value = id;
	document.pass_form.submit();
}

function showhide (show,hide) 
{
	show_obj = document.getElementById(show);
	hide_obj = document.getElementById(hide);
		
	show_obj.style.display = "block";
	hide_obj.style.display = "none";
}
 
function showhide1 (show,hide)
{
        show_obj = document.getElementById(show);
        hide_obj = document.getElementById(hide);

        show_obj.style.display = "";
        hide_obj.style.display = "none";
}

function liteoff(obj) {
		obj.className = "normal";
}

function forward(loc) {
		location.href = loc;
}

function forwardWithReturl(loc) {
	var i = location.href.indexOf("returl=");
	if (i< 0) {
		location.href = loc + '&returl=' + location.href;
	}
}

function openWin(internalURL,w,h) {
	openWinByName('mywindow',internalURL,w,h);
}

function openWinForum(internalURL,w,h) {
	openWinByName('forum',internalURL,w,h);
}

function openWinByName(internalName,internalURL,w,h) {
	var internalW = 640;
	var internalH = 480;
	if (w != undefined) {
		internalW = w;
	}
	if (h != undefined) {
		internalH = h;
	}
	internalArgs = 'scrollbars,resizable,toolbar,status,width=' + internalW + ',height=' + internalH + ',left=50,top=50';
	popupWin = window.open(internalURL,internalName,internalArgs);
 	popupWin.focus();
}

function openUA(internalURL) {
	internalURL += '&popup=1';
	internalName = 'popupWin';
	internalArgs = 'scrollbars,resizable,toolbar,status,width=660,height=480,left=50,top=50';
	popupWin = window.open(internalURL,internalName,internalArgs);
 	popupWin.focus();
}

function openSandbox(internalURL) {
	internalName = 'sandbox';
	internalArgs = 'scrollbars,resizable,toolbar,status,location,width=770,height=480,left=50,top=50';
	popupWin = window.open(internalURL,internalName,internalArgs);
 	popupWin.focus();
}

function getSelectedRadioBtn(radioGrp)
{
	// if only a single radio button, there is no group so check just that button
	if (!radioGrp.length && radioGrp.checked)
		return radioGrp;
	else if (!radioGrp.length)
		return null;

	for (var i = 0; i < radioGrp.length; i++) {
        if (radioGrp[i].checked) {
			return radioGrp[i];
		}
	}
	return null;
}

function launchSandbox(form, internalURL) {
	var email_id = getSelectedRadioBtn(form.account_id);

	if (email_id == null) {
			alert("Please select an account.");
			return;
	}
	
	var cellObj = document.getElementById('email_' + email_id.value);
//	var cellObj1 = document.getElementById('country_code_' + email_id.value).value;
	var cellObj1 = document.getElementById('country_code').value;

	//var cellObj = document.getElementById('email_' + email_id.value);
	//var cellObj1 = document.getElementById('country_code').value;
	
	//var cellObj1 = document.getElementById('country_code_' + email_id.value);
	
	var cellTextObj = cellObj.childNodes[0];
	var cellTextObj1="";
		if(cellObj.childNodes[2] != null){
			cellTextObj1= cellObj.childNodes[2];
			cellTextObj1 = cellTextObj1.data;
		}
	
	//var cellTextObj1 = cellObj1.childNodes[0];

	//openSandbox(internalURL +"/"+cellObj1+ "/?login_email=" + cellTextObj.data+cellTextObj1);
	openSandbox(internalURL +"/cgi-bin/webscr?_cmd=login_run&login_email=" + cellTextObj.data+cellTextObj1);
}	

function checkStrLength(strTagId, strLeng)
{ 
             var firstStr, SecondStr;
             if(document.all)
             {
                        var strcontent = document.getElementById(strTagId).innerText;
             }
             else
             {
                        var strcontent = document.getElementById(strTagId).textContent;
             }
            var strlen = strcontent.length;
            var strcutcnt = strLeng;
            var output = "";
            do {
                        output = output+strcontent.substring(0,strcutcnt)+"<br>";
                        strcontent = strcontent.substring(strcutcnt);
                        strlen = strcontent.length;
            } while (strlen > strcutcnt)
            output = output+strcontent;
            document.getElementById(strTagId).innerHTML = output;
}

function checkEmailLength(strTagId,strcutcnt)
{ 
	var str = document.getElementById(strTagId).innerHTML;
		var strLen = str.length;
		var strArr = str.split(" ");
		for (i=0; i<strArr.length;i++)
		{
			value = strArr[i];
			apos=value.indexOf("@");
			dotpos=value.lastIndexOf(".");
	
			if (apos<1||dotpos-apos<2) {
				//not an email
			}
			else {
				strcontent = strArr[i];
				var output = "";
			        do {
	                        output = output+strcontent.substring(0,strcutcnt)+"<br>";
	                        strcontent = strcontent.substring(strcutcnt);
	                        strlen = strcontent.length;
			            } while (strlen > strcutcnt)
			         output = output+strcontent;
				strArr[i] = output;
				
			}
	
	
		}
		newStr = strArr.join(" ");
		document.getElementById(strTagId).innerHTML = newStr;
            
}

function deleteConfirm(){

var delConf= confirm("Are you sure you want to delete this test account?");

	if (delConf == true){

			document.getElementById('delete').value='true';
			document.pass_form.submit();
			return true;
	}
	else
	{
			return false;
	}
}

/* STARTS HERE --- Spec 18883 - IPN Simulator */

function ipntype_submit(obj){
	
	//disableButton();

	var cmd = document.getElementById("set_cmd");
	cmd.setAttribute('value','_fill_ipn_form');
	document.ipnform.submit();
}

function buttonSubmit(obj)
{
	var cmd = document.getElementById("set_cmd");
	cmd.setAttribute('value',obj.name);
	document.ipnform.submit();
}

window.onload = function ()
{
	if (document.getElementById('send_ipn_but'))
	{
		disableButton();
	}
}

function disableButton()
{
	var but = document.getElementById('send_ipn_but');
	var txt = document.getElementById('notify_url');
	var opt = document.getElementById('ipn_type');
	
	if (txt.value == "" || opt.value=="-1")
	{
		but.disabled = true;
		but.className="btnDisabled";
		
	}
	else
	{
		but.disabled = false;
		but.className="formBtnOrange";
	}
}

var isFireFox = function ()
{
	var browser = navigator.appName;
	var b_version = navigator.appVersion;
	var version = parseFloat(b_version);
	if ((browser == "Netscape") && (version >= 4)){
		return true;
	}
	else {
		return false;
	}	
}

function checkSubmit(obj)
{
	var chk = obj;
	var container = document.getElementsByTagName('div');
	showAndHide(chk,container);
	var subHead = document.getElementsByTagName('label');
	showAndHide(chk,subHead);
	//myform.submit();
}

function showAndHide(chk,row)
{
	if (chk.checked == true)
	{
		for (var i=0; i < row.length; i++)
		{
			if (row[i].className == 'external'){
				row[i].style.display = "block";
			}
		}
	}
	else
	{
		for (var i=0; i < row.length; i++)
		{
			if (row[i].className == 'external')
			{
				row[i].style.display = "none";
			}
		}
	}
}

/* ENDS HERE --- Spec 18883 - IPN Simulator */
